add runvisitor hierarchy
[scilab.git] / scilab / modules / core / src / cpp / tasks.cpp
index 0499fd0..ea501cc 100644 (file)
@@ -24,7 +24,7 @@
 
 #define SCILAB_START "/etc/scilab.start"
 
-timer _timer;
+Timer _timer;
 
 //#define DEBUG
 
@@ -133,17 +133,26 @@ void printAstTask(bool timed)
 **
 ** Execute the stored AST.
 */
-void execAstTask(bool timed)
+void execAstTask(bool timed, bool ASTtimed)
 {
+       ast::ExecVisitor *exec;
        if(timed)
        {
                _timer.start();
-               ast::ExecVisitor::setDefaultVisitor(ast::TimedVisitor());
+       }
+
+       if(ASTtimed)
+       {
+               exec = (ast::ExecVisitor*)new ast::TimedVisitor();
+       }
+       else
+       {
+               exec = new ast::ExecVisitor();
        }
 
        try
        {
-               Parser::getInstance()->getTree()->accept(ast::ExecVisitor::getDefaultVisitor());
+               Parser::getInstance()->getTree()->accept(*exec);
                //Parser::getInstance()->freeTree();
        }
        catch(string sz)
@@ -152,6 +161,8 @@ void execAstTask(bool timed)
          YaspWrite("\n");
        }
 
+       delete exec;
+
        if(timed)
        {
                _timer.check("Execute AST");
@@ -196,5 +207,5 @@ void execScilabStartTask(void)
                return;
        }
 
-       execAstTask(false);
+       execAstTask(false, false);
 }