AST : Exp's children are store in a vector 49/15249/8
Antoine ELIAS [Fri, 19 Sep 2014 07:47:25 +0000 (09:47 +0200)]
Change-Id: I04533ef2fe1a0266bf36e96d74de55c3aefd5690

52 files changed:
scilab/modules/ast/includes/analysis/AnalysisVisitor.hxx
scilab/modules/ast/includes/analysis/Result.hxx
scilab/modules/ast/includes/ast/deserializervisitor.hxx
scilab/modules/ast/includes/ast/dummyvisitor.hxx
scilab/modules/ast/includes/ast/runvisitor.hxx
scilab/modules/ast/includes/ast/serializervisitor.hxx
scilab/modules/ast/includes/ast/stepvisitor.hxx
scilab/modules/ast/includes/exps/arraylistexp.hxx
scilab/modules/ast/includes/exps/arraylistvar.hxx
scilab/modules/ast/includes/exps/assignexp.hxx
scilab/modules/ast/includes/exps/assignlistexp.hxx
scilab/modules/ast/includes/exps/callexp.hxx
scilab/modules/ast/includes/exps/caseexp.hxx
scilab/modules/ast/includes/exps/cellcallexp.hxx
scilab/modules/ast/includes/exps/cellexp.hxx
scilab/modules/ast/includes/exps/constexp.hxx
scilab/modules/ast/includes/exps/decls.hxx
scilab/modules/ast/includes/exps/exp.hxx
scilab/modules/ast/includes/exps/fieldexp.hxx
scilab/modules/ast/includes/exps/forexp.hxx
scilab/modules/ast/includes/exps/functiondec.hxx
scilab/modules/ast/includes/exps/ifexp.hxx
scilab/modules/ast/includes/exps/listexp.hxx
scilab/modules/ast/includes/exps/matrixexp.hxx
scilab/modules/ast/includes/exps/matrixlineexp.hxx
scilab/modules/ast/includes/exps/notexp.hxx
scilab/modules/ast/includes/exps/opexp.hxx
scilab/modules/ast/includes/exps/returnexp.hxx
scilab/modules/ast/includes/exps/selectexp.hxx
scilab/modules/ast/includes/exps/seqexp.hxx
scilab/modules/ast/includes/exps/transposeexp.hxx
scilab/modules/ast/includes/exps/trycatchexp.hxx
scilab/modules/ast/includes/exps/vardec.hxx
scilab/modules/ast/includes/exps/whileexp.hxx
scilab/modules/ast/includes/parse/parsescilab.hxx
scilab/modules/ast/src/cpp/ast/debugvisitor.cpp
scilab/modules/ast/src/cpp/ast/macrovarvisitor.cpp
scilab/modules/ast/src/cpp/ast/mutevisitor.cpp
scilab/modules/ast/src/cpp/ast/printvisitor.cpp
scilab/modules/ast/src/cpp/ast/run_AssignExp.cpp
scilab/modules/ast/src/cpp/ast/run_CallExp.cpp
scilab/modules/ast/src/cpp/ast/run_MatrixExp.cpp
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/ast/visitor_common.cpp
scilab/modules/ast/src/cpp/parse/bison/parsescilab.yy
scilab/modules/ast/src/cpp/parse/parsescilab.cpp
scilab/modules/ast/src/cpp/types/macrofile.cpp
scilab/modules/core/src/cpp/tasks.cpp
scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp
scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp
scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp
scilab/modules/mexlib/src/cpp/mexlib.cpp

index 6a44269..f91f5bf 100644 (file)
@@ -279,11 +279,11 @@ private:
 
     void visit(ast::SimpleVar & e)
     {
-        symbol::Symbol & sym = e.getName();
+        symbol::Symbol & sym = e.getSymbol();
         TIType typ = get_ti(sym);
-        e.getDecorator().res = Result(typ, false);
+        e.getDecorator().res = Result(typ, false, false);
         setResult(e.getDecorator().res);
-        set_sym_use(e.getName(), SymInfo::READ);
+        set_sym_use(e.getSymbol(), SymInfo::READ);
     }
 
     void visit(ast::DollarVar & e)
@@ -298,8 +298,8 @@ private:
 
     void visit(ast::ArrayListVar & e)
     {
-        const std::list<ast::Var *> & vars = e.getVars();
-        for (std::list<ast::Var *>::const_iterator i = vars.begin(), end = vars.end(); i != end ; ++i)
+        const ast::exps_t vars = e.getVars();
+        for (ast::exps_t::const_iterator i = vars.begin(), end = vars.end(); i != end ; ++i)
         {
             (*i)->accept(*this);
         }
@@ -336,8 +336,8 @@ private:
     void visit(ast::CallExp & e)
     {
         e.getName().accept(*this);
-        const std::list<ast::Exp *> & args = e.args_get();
-        for (std::list<ast::Exp *>::const_iterator i = args.begin(), end = args.end(); i != end; ++i)
+        const ast::exps_t args = e.getArgs();
+        for (ast::exps_t::const_iterator i = args.begin(), end = args.end(); i != end; ++i)
         {
             (*i)->accept(*this);
         }
@@ -350,39 +350,40 @@ private:
 
     void visit(ast::OpExp & e)
     {
-        e.left_get().accept(*this);
+        e.getLeft().accept(*this);
         Result LR = getResult();
-        e.right_get().accept(*this);
+        e.getRight().accept(*this);
         Result & RR = getResult();
-        const TIType & LT = LR.get_type();
-        const TIType & RT = RR.get_type();
+        const TIType & LType = LR.getType();
+        const TIType & RType = RR.getType();
         TIType resT;
         bool allocTmp = false;
+        bool constant = false;
 
         // We can released the temp vars
-        if (LR.istemp())
+        if (LR.isTemp())
         {
-            add_tmp(LT, -1);
+            add_tmp(LType, -1);
         }
-        if (RR.istemp())
+        if (RR.isTemp())
         {
-            add_tmp(RT, -1);
+            add_tmp(RType, -1);
         }
 
-        switch (e.oper_get())
+        switch (e.getOper())
         {
             case ast::OpExp::plus :
             case ast::OpExp::minus :
             case ast::OpExp::dottimes :
             {
                 // TODO: check if the rules for addition and subtraction are the same
-                resT = check_add(LT, RT);
+                resT = check_add(LType, RType);
                 break;
             }
             case ast::OpExp::times :
             {
                 // multiplication is not commutative for matrice pxq
-                resT = check_times(LT, RT);
+                resT = check_times(LType, RType);
                 break;
             }
         }
@@ -394,14 +395,19 @@ private:
             allocTmp = true;
         }
 
-        e.getDecorator().res = Result(resT, allocTmp);
+        if (e.getLeft().isConstExp() && e.getRight().isConstExp())
+        {
+            constant = true;
+        }
+
+        e.getDecorator().res = Result(resT, allocTmp, true);
         setResult(e.getDecorator().res);
     }
 
     void visit(ast::LogicalOpExp & e)
     {
-        e.left_get().accept(*this);
-        e.right_get().accept(*this);
+        e.getLeft().accept(*this);
+        e.getRight().accept(*this);
     }
 
     void visit(ast::AssignExp & e)
@@ -409,13 +415,13 @@ private:
         if (e.getLeftExp().isSimpleVar())
         {
             ast::SimpleVar & var = static_cast<ast::SimpleVar &>(e.getLeftExp());
-            symbol::Symbol & sym = var.getName();
+            symbol::Symbol & sym = var.getSymbol();
 
             e.getRightExp().accept(*this);
             var.getDecorator().res = getResult();
 
             set_sym_use(sym, SymInfo::REPLACE);
-            set_sym_type(sym, getResult().get_type());
+            set_sym_type(sym, getResult().getType());
         }
         else
         {
@@ -444,10 +450,10 @@ private:
         e.getVardec().accept(*this);
         e.getBody().accept(*this);
 
-        MapSymInfo::const_iterator it = symsinfo.find(e.getVardec().getName());
+        MapSymInfo::const_iterator it = symsinfo.find(e.getVardec().getAs<ast::VarDec>()->getSymbol());
         if (it->second.read)
         {
-            e.getVardec().list_info_get().set_read_in_loop(true);
+            e.getVardec().getAs<ast::VarDec>()->getListInfo().setReadInLoop(true);
         }
     }
 
@@ -463,19 +469,19 @@ private:
 
     void visit(ast::TryCatchExp & e)
     {
-        e.try_get().accept(*this);
-        e.catch_get().accept(*this);
+        e.getTry().accept(*this);
+        e.getCatch().accept(*this);
     }
 
     void visit(ast::SelectExp & e)
     {
         e.getSelect()->accept(*this);
-        ast::cases_t * cases = e.getCases();
-        for (ast::cases_t::const_iterator i = cases->begin(), end = cases->end(); i != end; ++i)
+        ast::exps_t* cases = e.getCases();
+        for (ast::exps_t::const_iterator i = cases->begin(), end = cases->end(); i != end; ++i)
         {
             (*i)->accept(*this);
         }
-        e.default_case_get()->accept(*this);
+        e.getDefaultCase()->accept(*this);
     }
 
     void visit(ast::CaseExp & e)
@@ -486,7 +492,7 @@ private:
 
     void visit(ast::ReturnExp & e)
     {
-        e.exp_get().accept(*this);
+        e.getExp().accept(*this);
     }
 
     void visit(ast::FieldExp & e)
@@ -499,18 +505,18 @@ private:
 
     void visit(ast::NotExp & e)
     {
-        e.exp_get().accept(*this);
+        e.getExp().accept(*this);
     }
 
     void visit(ast::TransposeExp & e)
     {
-        e.exp_get().accept(*this);
+        e.getExp().accept(*this);
     }
 
     void visit(ast::MatrixExp & e)
     {
-        const std::list<ast::MatrixLineExp *> & lines = e.lines_get();
-        for (std::list<ast::MatrixLineExp *>::const_iterator i = lines.begin(), end = lines.end(); i != end; ++i)
+        const ast::exps_t lines = e.getLines();
+        for (ast::exps_t::const_iterator i = lines.begin(), itEnd = lines.end(); i != itEnd; ++i)
         {
             (*i)->accept(*this);
         }
@@ -518,8 +524,8 @@ private:
 
     void visit(ast::MatrixLineExp & e)
     {
-        const std::list<ast::Exp *> & columns = e.columns_get();
-        for (std::list<ast::Exp *>::const_iterator i = columns.begin(), end = columns.end(); i != end; ++i)
+        const ast::exps_t columns = e.getColumns();
+        for (ast::exps_t::const_iterator i = columns.begin(), itEnd = columns.end(); i != itEnd; ++i)
         {
             (*i)->accept(*this);
         }
@@ -532,7 +538,8 @@ private:
 
     void visit(ast::SeqExp & e)
     {
-        for (std::list<ast::Exp *>::const_iterator i = e.getExps().begin(), end = e.getExps().end(); i != end; ++i)
+        const ast::exps_t exps = e.getExps();
+        for (ast::exps_t::const_iterator i = exps.begin(), itEnd = exps.end(); i != itEnd; ++i)
         {
             (*i)->accept(*this);
         }
@@ -540,8 +547,8 @@ private:
 
     void visit(ast::ArrayListExp & e)
     {
-        const std::list<ast::Exp *> & exps = e.getExps();
-        for (std::list<ast::Exp *>::const_iterator i = exps.begin(), end = exps.end(); i != end; ++i)
+        const ast::exps_t exps = e.getExps();
+        for (ast::exps_t::const_iterator i = exps.begin(), itEnd = exps.end(); i != itEnd; ++i)
         {
             (*i)->accept(*this);
         }
@@ -559,14 +566,14 @@ private:
         if (e.getInit().isListExp())
         {
             ast::ListExp & le = static_cast<ast::ListExp &>(e.getInit());
-            if (le.start_get().isDoubleExp() && le.step_get().isDoubleExp() && le.end_get().isDoubleExp())
+            if (le.getStart().isDoubleExp() && le.getStep().isDoubleExp() && le.getEnd().isDoubleExp())
             {
-                ForList64 fl(static_cast<const ast::DoubleExp &>(le.start_get()).value_get(),
-                             static_cast<const ast::DoubleExp &>(le.step_get()).value_get(),
-                             static_cast<const ast::DoubleExp &>(le.end_get()).value_get());
+                ForList64 fl(static_cast<const ast::DoubleExp &>(le.getStart()).getValue(),
+                             static_cast<const ast::DoubleExp &>(le.getStep()).getValue(),
+                             static_cast<const ast::DoubleExp &>(le.getEnd()).getValue());
                 e.setListInfo(fl);
                 set_sym_use(sym, SymInfo::REPLACE, SymInfo::FOR_IT);
-                set_sym_type(sym, fl.get_type());
+                set_sym_type(sym, fl.getType());
                 // No need to visit the list (it has been visited just before)
             }
             else
@@ -579,8 +586,8 @@ private:
 
     void visit(ast::FunctionDec & e)
     {
-        e.args_get().accept(*this);
-        e.returns_get().accept(*this);
+        e.getArgs().accept(*this);
+        e.getReturns().accept(*this);
         e.getBody().accept(*this);
     }
 
@@ -590,22 +597,22 @@ private:
         double step = std::numeric_limits<double>::quiet_NaN();
         double end = std::numeric_limits<double>::quiet_NaN();
 
-        if (e.start_get().isDoubleExp())
+        if (e.getStart().isDoubleExp())
         {
-            start = static_cast<const ast::DoubleExp &>(e.start_get()).value_get();
+            start = static_cast<const ast::DoubleExp &>(e.getStart()).getValue();
         }
 
-        if (e.step_get().isDoubleExp())
+        if (e.getStep().isDoubleExp())
         {
-            step = static_cast<ast::DoubleExp &>(e.step_get()).value_get();
+            step = static_cast<ast::DoubleExp &>(e.getStep()).getValue();
         }
 
-        if (e.end_get().isDoubleExp())
+        if (e.getEnd().isDoubleExp())
         {
-            end = static_cast<ast::DoubleExp &>(e.end_get()).value_get();
+            end = static_cast<ast::DoubleExp &>(e.getEnd()).getValue();
         }
 
-        const_cast<ast::ListExp &>(e).set_values(start, step, end);
+        const_cast<ast::ListExp &>(e).setValues(start, step, end);
     }
 };
 
index 1d81ae9..88c27e3 100644 (file)
@@ -23,11 +23,12 @@ class Result
 {
     TIType type;
     bool temp;
+    bool constant;
 
 public:
 
     Result() : type(), temp(false) { }
-    Result(const TIType & _type, const bool _temp) : type(_type), temp(_temp) { }
+    Result(const TIType & _type, const bool _temp, const bool constant) : type(_type), temp(_temp), constant(constant) { }
     Result(TIType && _type, const bool _temp) : type(_type), temp(_temp) { }
 
     inline bool isTemp() const
index f5fd13a..17b5c4b 100644 (file)
@@ -67,10 +67,10 @@ private :
         return loc;
     }
 
-    std::list<Exp*>* get_exps(void)
+    exps_t* get_exps(void)
     {
         int nitems = get_uint32();
-        std::list<Exp*> *list = new std::list<Exp*>;
+        exps_t *list = new exps_t;
         for (int i = 0; i < nitems; i++)
         {
             Exp* exp = get_exp();
@@ -79,28 +79,26 @@ private :
         return list;
     }
 
-    std::list<MatrixLineExp*>* get_MatrixLines(void)
+    exps_t* get_MatrixLines(void)
     {
         int nitems = get_uint32();
-        std::list<MatrixLineExp*> *list = new std::list<MatrixLineExp*>;
+        exps_t* list = new exps_t;
         for (int i = 0; i < nitems; i++)
         {
             Location line_loc = get_location();
-            std::list<Exp*>* columns = get_exps();
-            MatrixLineExp* line = new MatrixLineExp(line_loc, * columns);
+            MatrixLineExp* line = new MatrixLineExp(line_loc, *get_exps());
             list->push_back(line);
         }
         return list;
     }
 
-    std::list<Var*>* get_vars(void)
+    ast::exps_t* get_vars(void)
     {
         int nitems = get_uint32();
-        std::list<Var*> *list = new  std::list<Var*>;
+        ast::exps_t* list = new ast::exps_t;
         for (int i = 0; i < nitems; i++)
         {
-            Var* var = static_cast<Var*>(get_exp());
-            list->push_back(var);
+            list->push_back(get_exp());
         }
         return list;
     }
@@ -241,7 +239,7 @@ private :
         {
             case 1:
             {
-                std::list<Exp *>* l_body = get_exps();
+                exps_t* l_body = get_exps();
                 exp = new SeqExp(loc, *l_body);
                 break;
             }
@@ -278,8 +276,7 @@ private :
             }
             case 9:
             {
-                symbol::Symbol *name = get_Symbol();
-                exp = new SimpleVar(loc, *name);
+                exp = new SimpleVar(loc, *get_Symbol());
                 break;
             }
             case 10:
@@ -294,8 +291,7 @@ private :
             }
             case 12:
             {
-                std::list<Var*>* vars = get_vars();
-                exp = new ArrayListVar(loc, *vars);
+                exp = new ArrayListVar(loc, *get_vars());
                 break;
             }
             case 13:
@@ -327,8 +323,8 @@ private :
             {
                 Location try_location = get_location();
                 Location catch_location = get_location();
-                std::list<Exp *>* try_exps = get_exps();
-                std::list<Exp *>* catch_exps = get_exps();
+                exps_t* try_exps = get_exps();
+                exps_t* catch_exps = get_exps();
                 SeqExp *tryexp = new SeqExp(try_location, *try_exps);
                 SeqExp *catchexp = new SeqExp(catch_location, *catch_exps);
                 exp = new TryCatchExp(loc, *tryexp, *catchexp);
@@ -380,21 +376,21 @@ private :
                 if ( has_default )
                 {
                     Location default_case_location = get_location();
-                    std::list<Exp *>* default_case_exps = get_exps();
+                    exps_t* default_case_exps = get_exps();
                     default_case = new SeqExp(default_case_location,
                                               *default_case_exps);
                 }
                 Exp* select = get_exp();
 
                 int nitems = get_uint32();
-                std::list<CaseExp*> *cases = new  std::list<CaseExp*>;
+                exps_t* cases = new  exps_t;
                 for (int i = 0; i < nitems; i++)
                 {
 
                     Location case_location = get_location();
                     Location body_location = get_location();
                     Exp* test = get_exp();
-                    std::list<Exp *>* body_exps = get_exps();
+                    exps_t* body_exps = get_exps();
                     SeqExp *body = new SeqExp(body_location,  *body_exps);
 
                     CaseExp* _case = new CaseExp(case_location, *test, *body);
@@ -420,19 +416,19 @@ private :
             */
             case 23:
             {
-                std::list<MatrixLineExp *>* lines = get_MatrixLines();
+                ast::exps_t* lines = get_MatrixLines();
                 exp = new CellExp(loc, *lines);
                 break;
             }
             case 24:
             {
-                std::list<Exp *>* exps = get_exps();
+                exps_t* exps = get_exps();
                 exp = new ArrayListExp(loc, *exps);
                 break;
             }
             case 25:
             {
-                std::list<Exp *>* exps = get_exps();
+                exps_t* exps = get_exps();
                 exp = new AssignListExp(loc, *exps);
                 break;
             }
@@ -460,8 +456,8 @@ private :
                 Location args_loc = get_location();
                 Location returns_loc = get_location();
                 Exp* body = get_exp();
-                std::list <Var*>* args_list = get_vars();
-                std::list <Var*>* returns_list = get_vars();
+                exps_t* args_list = get_vars();
+                exps_t* returns_list = get_vars();
                 ArrayListVar *args = new ArrayListVar(args_loc, *args_list);
                 ArrayListVar *returns = new ArrayListVar(returns_loc, *returns_list);
                 exp = new FunctionDec(loc, *name, *args, *returns, *body);
@@ -503,14 +499,14 @@ private :
             }
             case 34:
             {
-                std::list<MatrixLineExp *>* lines = get_MatrixLines();
+                exps_t* lines = get_MatrixLines();
                 exp = new MatrixExp(loc, *lines);
                 break;
             }
             case 35:
             {
                 Exp* name = get_exp();
-                std::list<Exp *> * args = get_exps();
+                exps_t* args = get_exps();
                 exp = new CallExp(loc, *name, *args);
                 break;
             }
@@ -523,7 +519,7 @@ private :
             case 37:
             {
                 Exp* name = get_exp();
-                std::list<Exp *>* args = get_exps();
+                exps_t* args = get_exps();
                 exp = new CellCallExp(loc, *name, *args);
                 break;
             }
index 5ce00ea..ec91bb4 100644 (file)
@@ -32,36 +32,31 @@ protected:
 
     virtual void visit (const MatrixExp &e)
     {
-        std::list<MatrixLineExp *>::const_iterator i;
-        for (i = e.getLines().begin() ; i != e.getLines().end() ; ++i )
+        exps_t lines = e.getLines();
+        for (exps_t::const_iterator it = lines.begin(), itEnd = lines.end(); it != itEnd ; ++it)
         {
-            (*i)->accept (*this);
+            (*it)->accept (*this);
         }
     }
 
     virtual void visit (const MatrixLineExp &e)
     {
-        std::list<Exp *>::const_iterator i;
-        for (i = e.getColumns().begin() ; i != e.getColumns().end() ; ++i)
+        exps_t columns = e.getColumns();
+        for (exps_t::const_iterator it = columns.begin(), itEnd = columns.end(); it != itEnd ; ++it)
         {
-            (*i)->accept (*this);
+            (*it)->accept (*this);
         }
     }
-    /** \} */
 
     virtual void visit (const CellExp &e)
     {
-        std::list<MatrixLineExp *>::const_iterator i;
-        for (i = e.getLines().begin() ; i != e.getLines().end() ; ++i )
+        exps_t lines = e.getLines();
+        for (exps_t::const_iterator it = lines.begin(), itEnd = lines.end(); it != itEnd ; ++it)
         {
-            (*i)->accept (*this);
+            (*it)->accept (*this);
         }
     }
 
-    /** \} */
-
-    /** \name Visit Constant Expressions nodes.
-     ** \{ */
     virtual void visit (const StringExp &/*e*/)
     {
         // Nothing to follow up ...
@@ -86,10 +81,7 @@ protected:
     {
         // Nothing to follow up ...
     }
-    /** \} */
 
-    /** \name Visit Variable related nodes.
-     ** \{ */
     virtual void visit (const SimpleVar &/*e*/)
     {
         // Nothing to follow up ...
@@ -107,16 +99,12 @@ protected:
 
     virtual void visit (const ArrayListVar &e)
     {
-        std::list<Var *>::const_iterator i;
-        for (i = e.getVars().begin() ; i != e.getVars().end() ; ++i)
+        exps_t vars = e.getVars();
+        for (exps_t::const_iterator it = vars.begin (), itEnd = vars.end(); it != itEnd; ++it)
         {
-            (*i)->accept (*this);
+            (*it)->accept(*this);
         }
     }
-    /** \} */
-
-    /** \name Visit Control Expressions or Instructions nodes.
-     ** \{ */
 
     virtual void visit (const FieldExp &e)
     {
@@ -127,14 +115,12 @@ protected:
     virtual void visit(const OpExp &e)
     {
         e.getLeft().accept(*this);
-        //e.oper_get();
         e.getRight().accept(*this);
     }
 
     virtual void visit(const LogicalOpExp &e)
     {
         e.getLeft().accept(*this);
-        //e.oper_get();
         e.getRight().accept(*this);
     }
 
@@ -148,10 +134,10 @@ protected:
     {
         e.getName().accept (*this);
 
-        std::list<Exp *>::const_iterator i;
-        for (i = e.getArgs().begin (); i != e.getArgs().end (); ++i)
+        exps_t args = e.getArgs();
+        for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
         {
-            (*i)->accept (*this);
+            (*it)->accept(*this);
         }
     }
 
@@ -159,10 +145,10 @@ protected:
     {
         e.getName().accept (*this);
 
-        std::list<Exp *>::const_iterator i;
-        for (i = e.getArgs().begin (); i != e.getArgs().end (); ++i)
+        exps_t args = e.getArgs();
+        for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
         {
-            (*i)->accept (*this);
+            (*it)->accept (*this);
         }
     }
 
@@ -216,11 +202,12 @@ protected:
     {
         e.getSelect()->accept(*this);
 
-        ast::cases_t::iterator it;
-        for (it = e.getCases()->begin() ; it !=  e.getCases()->end() ; ++it)
+        exps_t* cases = e.getCases();
+        for (exps_t::iterator it = cases->begin(), itEnd = cases->end(); it !=  itEnd ; ++it)
         {
             (*it)->accept(*this);
         }
+
         if (e.getDefaultCase() != NULL)
         {
             e.getDefaultCase()->accept(*this);
@@ -235,28 +222,25 @@ protected:
 
     virtual void visit (const SeqExp  &e)
     {
-        std::list<Exp *>::const_iterator i;
-        for (i = e.getExps().begin (); i != e.getExps().end (); ++i)
+        for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
         {
-            (*i)->accept (*this);
+            (*it)->accept(*this);
         }
     }
 
     virtual void visit (const ArrayListExp  &e)
     {
-        std::list<Exp *>::const_iterator i;
-        for (i = e.getExps().begin (); i != e.getExps().end (); ++i)
+        for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
         {
-            (*i)->accept (*this);
+            (*it)->accept (*this);
         }
     }
 
     virtual void visit (const AssignListExp  &e)
     {
-        std::list<Exp *>::const_iterator i;
-        for (i = e.getExps().begin (); i != e.getExps().end (); ++i)
+        for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
         {
-            (*i)->accept (*this);
+            (*it)->accept (*this);
         }
     }
     /** \} */
index 26466fc..aee807d 100644 (file)
@@ -314,10 +314,10 @@ public :
     {
     }
 
-    types::typed_list* GetArgumentList(std::list<Exp *>const& _plstArg)
+    types::typed_list* GetArgumentList(exps_t const & _plstArg)
     {
         types::typed_list* pArgs = new types::typed_list();
-        for (std::list<Exp *>::const_iterator it = _plstArg.begin() ; it != _plstArg.end() ; ++it)
+        for (exps_t::const_iterator it = _plstArg.begin() ; it != _plstArg.end() ; ++it)
         {
             (*it)->accept(*this);
             if (getResultSize() > 1)
@@ -489,7 +489,7 @@ public :
 
     void visitprivate(const ArrayListExp  &e)
     {
-        std::list<Exp *>::const_iterator it;
+        exps_t::const_iterator it;
         int i = 0;
 
         std::list<InternalType*> lstIT;
index 771167f..98efffe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Scilab (http://www.scilab.org/) - This file is part of Scilab
  *  Copyright (C) 2012-2013 - OCAMLPRO INRIA - Fabrice LE FESSANT
  *  Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
  *
@@ -26,7 +26,7 @@ namespace ast
 class SerializeVisitor : public DummyVisitor
 {
 private :
-    ast::Exp* ast;
+    Exp* ast;
     unsigned char *buf;
     int buflen;
     int bufsize;
@@ -76,7 +76,7 @@ private :
         add_uint32(loc.last_line);
         add_uint32(loc.last_column);
     }
-    void add_ast(unsigned int code, const ast::Exp& e)
+    void add_ast(unsigned int code, const Exp& e)
     {
         add_uint8(code);
         if (saveNodeNumber)
@@ -102,24 +102,24 @@ private :
     /* ensure that we have [size] bytes in the buffer */
     void need(int size)
     {
-        if ( bufsize - buflen < size )
+        if (bufsize - buflen < size)
         {
             bufsize = 2 * bufsize + size + FAGMENT_SIZE;
             unsigned char *newbuf = (unsigned char*) malloc(bufsize * sizeof(unsigned char));
             // std::cerr << "malloc " << (void*) newbuf << " " << bufsize << " " << (void*) buf << " " << buflen << std::endl;
-            if ( buflen > 0 )
+            if (buflen > 0)
             {
                 // std::cerr << "memcpy " << (void*) newbuf << " " << bufsize << " " << (void*) buf << " " << buflen << std::endl;
                 memcpy(newbuf, buf, buflen);
             }
-            if ( buf != NULL)
+            if (buf != NULL)
             {
                 // std::cerr << "free " << (void*) newbuf << " " << bufsize << " " << (void*) buf << " " << buflen << std::endl;
                 free(buf);
             }
             else
             {
-                buflen = 8;    /* Header length. Header =  final size of buf ( 4 bytes ) + scilab version ( 4 bytes )*/
+                buflen = 8;    /* Header length. Header =  final size of buf (4 bytes) + scilab version (4 bytes)*/
             }
             buf = newbuf;
         }
@@ -180,21 +180,20 @@ private :
 
     /** @} */
 
-    void add_exps(const std::list<Exp *> exps)
+    void add_exps(const exps_t& exps)
     {
         add_uint32((unsigned int)exps.size());
-        std::list<Exp *>::const_iterator it;
-        for (it = exps.begin() ; it != exps.end() ; it++)
+        for (exps_t::const_iterator it = exps.begin(), itEnd = exps.end(); it != itEnd ; ++it)
         {
             (*it)->accept(*this);
         }
     }
 
-    void add_vars(const ast::ArrayListVar& var)
+    void add_vars(const ArrayListVar& var)
     {
-        add_uint32((unsigned int)var.getVars().size());
-        std::list<Var *>::const_iterator it;
-        for (it = var.getVars().begin() ; it != var.getVars().end() ; it++)
+        exps_t vars = var.getVars();
+        add_uint32((unsigned int)vars.size());
+        for (exps_t::const_iterator it = vars.begin (), itEnd = vars.end(); it != itEnd; ++it)
         {
             (*it)->accept(*this);
         }
@@ -205,121 +204,121 @@ private :
         add_wstring(e.getName());
     }
 
-    void add_exp(const ast::Exp* e)
+    void add_exp(const Exp* e)
     {
         e->accept(*this);
     }
 
-    void add_exp(const ast::Exp& e)
+    void add_exp(const Exp& e)
     {
         e.accept(*this);
     }
 
-    void add_OpExp_Oper(const ast::OpExp::Oper oper)
+    void add_OpExp_Oper(const OpExp::Oper oper)
     {
         int code = 253;
         switch (oper)
         {
-            case ast::OpExp::plus :
+            case OpExp::plus :
                 code = (1);
                 break;
-            case ast::OpExp::minus:
+            case OpExp::minus:
                 code = (2);
                 break;
-            case ast::OpExp::times:
+            case OpExp::times:
                 code = (3);
                 break;
-            case ast::OpExp::rdivide:
+            case OpExp::rdivide:
                 code = (4);
                 break;
-            case ast::OpExp::ldivide:
+            case OpExp::ldivide:
                 code = (5);
                 break;
-            case ast::OpExp::power:
+            case OpExp::power:
                 code = (6);
                 break;
 
-            case ast::OpExp::dottimes:
+            case OpExp::dottimes:
                 code = (7);
                 break;
-            case ast::OpExp::dotrdivide:
+            case OpExp::dotrdivide:
                 code = (8);
                 break;
-            case ast::OpExp::dotldivide:
+            case OpExp::dotldivide:
                 code = (9);
                 break;
-            case ast::OpExp::dotpower:
+            case OpExp::dotpower:
                 code = (10);
                 break;
 
-            case ast::OpExp::krontimes:
+            case OpExp::krontimes:
                 code = (11);
                 break;
-            case ast::OpExp::kronrdivide:
+            case OpExp::kronrdivide:
                 code = (12);
                 break;
-            case ast::OpExp::kronldivide:
+            case OpExp::kronldivide:
                 code = (13);
                 break;
 
-            case ast::OpExp::controltimes:
+            case OpExp::controltimes:
                 code = (14);
                 break;
-            case ast::OpExp::controlrdivide:
+            case OpExp::controlrdivide:
                 code = (15);
                 break;
-            case ast::OpExp::controlldivide:
+            case OpExp::controlldivide:
                 code = (16);
                 break;
 
-            case ast::OpExp::eq:
+            case OpExp::eq:
                 code = (17);
                 break;
-            case ast::OpExp::ne:
+            case OpExp::ne:
                 code = (18);
                 break;
-            case ast::OpExp::lt:
+            case OpExp::lt:
                 code = (19);
                 break;
-            case ast::OpExp::le:
+            case OpExp::le:
                 code = (20);
                 break;
-            case ast::OpExp::gt:
+            case OpExp::gt:
                 code = (21);
                 break;
-            case ast::OpExp::ge:
+            case OpExp::ge:
                 code = (22);
                 break;
 
-            case ast::OpExp::unaryMinus:
+            case OpExp::unaryMinus:
                 code = (23);
                 break;
 
-            case ast::OpExp::logicalAnd:
+            case OpExp::logicalAnd:
                 code = (24);
                 break;
-            case ast::OpExp::logicalOr:
+            case OpExp::logicalOr:
                 code = (25);
                 break;
-            case ast::OpExp::logicalShortCutAnd:
+            case OpExp::logicalShortCutAnd:
                 code = (26);
                 break;
-            case ast::OpExp::logicalShortCutOr:
+            case OpExp::logicalShortCutOr:
                 code = (27);
                 break;
         }
         add_uint8(code);
     }
 
-    void add_TransposeExp_Kind(const ast::TransposeExp::Kind kind)
+    void add_TransposeExp_Kind(const TransposeExp::Kind kind)
     {
         int code = 249;
         switch (kind)
         {
-            case ast::TransposeExp::_Conjugate_ :
+            case TransposeExp::_Conjugate_ :
                 code = (1);
                 break;
-            case ast::TransposeExp::_NonConjugate_:
+            case TransposeExp::_NonConjugate_:
                 code = (2);
                 break;
         }
@@ -331,20 +330,19 @@ private :
         add_uint8(b);
     }
 
-    void add_varDec(const ast::VarDec& varDec)
+    void add_varDec(const VarDec& varDec)
     {
         add_Symbol(varDec.getSymbol());
         add_exp(varDec.getInit());
     }
 
-    void add_MatrixLines(const  std::list<ast::MatrixLineExp*> *lines)
+    void add_MatrixLines(const exps_t* lines)
     {
         add_uint32((unsigned int)lines->size());
-        std::list<MatrixLineExp *>::const_iterator it;
-        for (it = lines->begin() ; it != lines->end() ; it++)
+        for (exps_t::const_iterator it = lines->begin(), itEnd = lines->end(); it != itEnd ; ++it)
         {
             add_location((*it)->getLocation());
-            add_exps((*it)->getColumns());
+            add_exps((*it)->getAs<MatrixLineExp>()->getColumns());
         }
     }
 
@@ -408,7 +406,7 @@ private :
         add_bool(hasElse);
         add_exp(& e.getTest());
         add_exp(& e.getThen());
-        if ( hasElse )
+        if (hasElse)
         {
             add_exp(& e.getElse());
         }
@@ -418,8 +416,8 @@ private :
         add_ast(15, e);
         add_location(e.getTry().getLocation());
         add_location(e.getCatch().getLocation());
-        add_exps(e.getTry().getExps());
-        add_exps(e.getCatch().getExps());
+        add_exps(e.getTry().getAs<SeqExp>()->getExps());
+        add_exps(e.getCatch().getAs<SeqExp>()->getExps());
     }
     void visit(const WhileExp& e)  /* done */
     {
@@ -431,8 +429,8 @@ private :
     {
         add_ast(17, e);
         add_location(e.getVardec().getLocation());
-        add_varDec(e.getVardec());
-        add_exp(& e.getBody());
+        add_varDec(*e.getAs<ForExp>()->getVardec().getAs<VarDec>());
+        add_exp(&e.getBody());
     }
     void visit(const BreakExp& e)  /* done */
     {
@@ -447,7 +445,7 @@ private :
         add_ast(20, e);
         bool is_global = e.isGlobal();
         add_bool(is_global);
-        if ( !is_global ) /* otherwise exp is NULL */
+        if (!is_global) /* otherwise exp is NULL */
         {
             add_exp(& e.getExp());
         }
@@ -455,25 +453,24 @@ private :
     void visit(const SelectExp& e)
     {
         add_ast(21, e);
-        ast::SeqExp *default_case = e.getDefaultCase();
-        bool has_default = default_case != NULL;
-        add_bool( has_default );
-        if ( has_default )
+        Exp *default_case = e.getDefaultCase();
+        add_bool(e.hasDefault());
+        if (e.hasDefault())
         {
             add_location(default_case->getLocation());
-            add_exps(default_case->getExps());
+            add_exps(default_case->getAs<SeqExp>()->getExps());
         }
         add_exp(e.getSelect());
 
         add_uint32((unsigned int)e.getCases()->size());
-        cases_t::const_iterator it;
-        for (it = e.getCases()->begin() ; it != e.getCases()->end() ; it++)
+        exps_t* cases = e.getCases();
+        for (exps_t::iterator it = cases->begin(), itEnd = cases->end(); it !=  itEnd ; ++it)
         {
-            const ast::CaseExp *ce = *it;
-            add_location(ce->getLocation() );
-            add_location(ce->getBody()->getLocation() );
+            const CaseExp *ce = (*it)->getAs<CaseExp>();
+            add_location(ce->getLocation());
+            add_location(ce->getBody()->getLocation());
             add_exp(ce->getTest());
-            add_exps(ce->getBody()->getExps() );
+            add_exps(ce->getBody()->getAs<SeqExp>()->getExps());
         }
     }
     void visit(const CellExp& e)  /* done */
@@ -494,7 +491,7 @@ private :
     void visit(const NotExp& e)  /* done */
     {
         add_ast(26, e);
-        add_exp(e.getExp() );
+        add_exp(e.getExp());
     }
     void visit(const TransposeExp& e)  /* done */
     {
@@ -514,15 +511,15 @@ private :
         add_location(e.getArgs().getLocation());
         add_location(e.getReturns().getLocation());
         add_exp(e.getBody());
-        add_vars(e.getArgs());
-        add_vars(e.getReturns());
+        add_vars(*e.getArgs().getAs<ArrayListVar>());
+        add_vars(*e.getReturns().getAs<ArrayListVar>());
     }
     void visit(const ListExp& e)  /* done */
     {
         add_ast(30, e);
-        add_exp(e.getStart() );
-        add_exp(e.getStep() );
-        add_exp(e.getEnd() );
+        add_exp(e.getStart());
+        add_exp(e.getStep());
+        add_exp(e.getEnd());
     }
     void visit(const AssignExp& e)
     {
@@ -552,7 +549,7 @@ private :
     void visit(const CallExp& e)  /* done */
     {
         add_ast(35, e);
-        add_exp( e.getName());
+        add_exp(e.getName());
         add_exps(e.getArgs());
     }
     void visit(const MatrixLineExp& e)  /* SHOULD NEVER HAPPEN */
@@ -562,12 +559,12 @@ private :
     void visit(const CellCallExp& e)  /* done */
     {
         add_ast(37, e);
-        add_exp( e.getName());
+        add_exp(e.getName());
         add_exps(e.getArgs());
     }
 
 public :
-    SerializeVisitor(ast::Exp* _ast) : ast(_ast), buf(NULL), buflen(0), bufsize(0), saveNodeNumber(true) {}
+    SerializeVisitor(Exp* _ast) : ast(_ast), buf(NULL), buflen(0), bufsize(0), saveNodeNumber(true) {}
 
     unsigned char* serialize(bool _saveNodeNumber = true)
     {
index 3127e59..3b39bcb 100644 (file)
@@ -25,14 +25,11 @@ class EXTERN_AST StepVisitor : public RunVisitorT<StepVisitor>
 {
     void visit(const SeqExp &e)
     {
-        std::list<Exp*>::const_iterator it;
-        for (it = e.getExps().begin() ; it != e.getExps().end() ; ++it)
+        for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
         {
             PrintVisitor *pv = new PrintVisitor(std::wcerr);
             (*it)->accept(*pv);
             std::wcerr << std::endl;
-            //ExecVisitor *pe = new ast::ExecVisitor();
-            //(*it)->accept(*pe);
         }
         visitprivate(e);
     }
index 14497fd..ab0ef17 100644 (file)
@@ -36,31 +36,25 @@ public:
     ** \param body EXP LIST intruction
     */
     ArrayListExp (const Location& location,
-                  std::list<Exp *>& exps)
-        : Exp (location),
-          _exps (&exps)
+                  exps_t& exps)
+        : Exp (location)
     {
-    }
-
-    virtual ~ArrayListExp ()
-    {
-        for (std::list<Exp *>::const_iterator it = _exps->begin(), itEnd = _exps->end(); it != itEnd ; ++it)
+        for (exps_t::const_iterator it = exps.begin(), itEnd = exps.end(); it != itEnd ; ++it)
         {
-            delete *it;
+            _exps.push_back(*it);
+            (*it)->setParent(this);
         }
-
-        delete _exps;
     }
 
     virtual ArrayListExp* clone()
     {
-        std::list<Exp *>* exps = new std::list<Exp *>;
-        for (std::list<Exp *>::const_iterator it = _exps->begin(), itEnd = _exps->end(); it != itEnd ; ++it)
+        exps_t exps;
+        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
         {
-            exps->push_back((*it)->clone());
+            exps.push_back((*it)->clone());
         }
 
-        ArrayListExp* cloned = new ArrayListExp(getLocation(), *exps);
+        ArrayListExp* cloned = new ArrayListExp(getLocation(), exps);
         cloned->setVerbose(isVerbose());
         return cloned;
     }
@@ -83,14 +77,14 @@ public:
     /** \name Accessors.
     ** \{ */
 public:
-    const std::list<Exp *>&    getExps() const
+    const exps_t& getExps() const
     {
-        return *_exps;
+        return _exps;
     }
 
-    std::list<Exp *>&  getExps()
+    exps_t&    getExps()
     {
-        return *_exps;
+        return _exps;
     }
     /** \} */
 
@@ -103,8 +97,6 @@ public:
     {
         return true;
     }
-protected:
-    std::list<Exp *>* _exps;
 };
 
 } // namespace ast
index c6e5652..70c4939 100644 (file)
@@ -36,31 +36,25 @@ public:
     ** \param body VAR LIST intruction
     */
     ArrayListVar (const Location& location,
-                  std::list<Var *>& vars)
-        : Var (location),
-          _vars (&vars)
+                  exps_t& vars)
+        : Var (location)
     {
-    }
-
-    virtual ~ArrayListVar ()
-    {
-        for (std::list<Var *>::iterator it = _vars->begin(), itEnd = _vars->end(); it != itEnd ; ++it)
+        for (exps_t::iterator it = vars.begin(), itEnd = vars.end(); it != itEnd ; ++it)
         {
-            delete *it;
+            (*it)->setParent(this);
+            _exps.push_back(*it);
         }
-
-        delete _vars;
     }
 
     virtual ArrayListVar* clone()
     {
-        std::list<Var *>* vars = new std::list<Var *>;
-        for (std::list<Var *>::const_iterator it = _vars->begin(), itEnd = _vars->end(); it != itEnd ; ++it)
+        exps_t exps;
+        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
         {
-            vars->push_back(static_cast<Var*>((*it)->clone()));
+            exps.push_back((*it)->clone());
         }
 
-        ArrayListVar* cloned = new ArrayListVar(getLocation(), *vars);
+        ArrayListVar* cloned = new ArrayListVar(getLocation(), exps);
         cloned->setVerbose(isVerbose());
         return cloned;
     }
@@ -84,14 +78,14 @@ public:
     /** \name Accessors.
     ** \{ */
 public:
-    const std::list<Var *>&    getVars() const
+    const exps_t& getVars() const
     {
-        return *_vars;
+        return _exps;
     }
 
-    std::list<Var *>& getVars()
+    exps_t& getVars()
     {
-        return *_vars;
+        return _exps;
     }
     /** \} */
 
@@ -105,7 +99,6 @@ public:
     }
 
 protected:
-    std::list<Var *>* _vars;
 };
 
 } // namespace ast
index bbb9056..78858b3 100644 (file)
@@ -26,35 +26,26 @@ class AssignExp : public Exp
 public:
     AssignExp (const Location& location,
                Exp& left_exp,
-               Exp& right_exp)
-        : Exp (location),
-          _left_exp (&left_exp),
-          _right_exp (&right_exp),
-          lr_owner(true),
-          _pIT(NULL)
-    {
-    }
-
-    AssignExp (const Location& location,
-               Exp& left_exp,
                Exp& right_exp,
-               types::InternalType* pIT)
+               types::InternalType* pIT = NULL)
         : Exp (location),
-          _left_exp (&left_exp),
-          _right_exp (&right_exp),
           lr_owner(true),
           _pIT(pIT)
     {
+        left_exp.setParent(this);
+        right_exp.setParent(this);
+        _exps.push_back(&left_exp);
+        _exps.push_back(&right_exp);
     }
     /** \brief Destroy an Assign Exp node.
     **
-    ** Delete var et exp (see constructor). */
+    ** Delete var and exp (see constructor). */
     virtual ~AssignExp ()
     {
         if (lr_owner)
         {
-            delete  _left_exp;
-            delete  _right_exp;
+            delete _exps[0];
+            delete _exps[1];
         }
     }
     /** \} */
@@ -87,23 +78,23 @@ public:
     /** \brief Return the name of the size (read only). */
     Exp& getLeftExp() const
     {
-        return *_left_exp;
+        return *_exps[0];
     }
     /** \brief Return the name of the size */
     Exp& getLeftExp()
     {
-        return *_left_exp;
+        return *_exps[0];
     }
 
     /** \brief Return the name of the init (read only). */
     Exp& getRightExp() const
     {
-        return *_right_exp;
+        return *_exps[1];
     }
     /** \brief Return the name of the init */
     Exp& getRightExp()
     {
-        return *_right_exp;
+        return *_exps[1];
     }
 
     types::InternalType* getRightVal()
@@ -133,10 +124,6 @@ public:
     }
 
 protected:
-    /** \brief Left variable which is affected. */
-    Exp* _left_exp;
-    /** \brief Right expression which affect var. */
-    Exp* _right_exp;
     bool lr_owner;
     types::InternalType* _pIT;
 };
index 412ac30..ded9756 100644 (file)
@@ -35,20 +35,20 @@ public:
     ** \param body EXP LIST intruction
     */
     AssignListExp (const Location& location,
-                   std::list<Exp *>& exps) :
+                   exps_t& exps) :
         ArrayListExp (location, exps)
     {
     }
 
     virtual AssignListExp* clone()
     {
-        std::list<Exp *>* exps = new std::list<Exp *>;
-        for (std::list<Exp *>::const_iterator it = _exps->begin() ; it != _exps->end() ; ++it)
+        exps_t exps;
+        for (exps_t::const_iterator it = _exps.begin() ; it != _exps.end() ; ++it)
         {
-            exps->push_back((*it)->clone());
+            exps.push_back((*it)->clone());
         }
 
-        AssignListExp* cloned = new AssignListExp(getLocation(), *exps);
+        AssignListExp* cloned = new AssignListExp(getLocation(), exps);
         cloned->setVerbose(isVerbose());
         return cloned;
     }
index 62bf890..19189a8 100644 (file)
@@ -35,33 +35,28 @@ public:
     */
     CallExp (const Location& location,
              Exp& name,
-             std::list<Exp *>& args) :
-        Exp (location),
-        _name (&name),
-        _args (&args)
+             exps_t& args) :
+        Exp (location)
     {
-    }
+        _exps.push_back(&name);
+        name.setParent(this);
 
-    virtual ~CallExp ()
-    {
-        for (std::list<Exp *>::const_iterator it = _args->begin(), itEnd = _args->end(); it != itEnd; ++it)
+        for (exps_t::const_iterator it = args.begin(), itEnd = args.end(); it != itEnd; ++it)
         {
-            delete *it;
+            (*it)->setParent(this);
+            _exps.push_back(*it);
         }
-
-        delete _args;
-        delete _name;
     }
 
     virtual CallExp* clone()
     {
-        std::list<Exp *>* args = new std::list<Exp *>;
-        for (std::list<Exp *>::const_iterator it = _args->begin() ; it != _args->end() ; ++it)
+        exps_t args;
+        for (exps_t::const_iterator it = ++(_exps.begin()); it != _exps.end() ; ++it)
         {
-            args->push_back((*it)->clone());
+            args.push_back((*it)->clone());
         }
 
-        CallExp* cloned = new CallExp(getLocation(), *getName().clone(), *args);
+        CallExp* cloned = new CallExp(getLocation(), *getName().clone(), args);
         cloned->setVerbose(isVerbose());
         return cloned;
     }
@@ -82,29 +77,33 @@ public:
 
     // \brief Accessors.
 public:
-    const Exp& getName() const
+    const Exp& getName() const
     {
-        return *_name;
+        return *_exps[0];
     }
 
-    Exp&       getName()
+    Exp& getName()
     {
-        return *_name;
+        return *_exps[0];
     }
 
-    void setName (Exp *name)
+    void setName(Exp *name)
     {
-        _name = name;
+        _exps[0] = name;
     }
 
-    const std::list<Exp *>&    getArgs() const
+    const exps_t& getArgs() const
     {
-        return *_args;
+        exps_t* args = new exps_t;
+        std::copy(++(_exps.begin()), _exps.end(), args->begin());
+        return *args;
     }
 
-    std::list<Exp *>&  getArgs()
+    exps_t& getArgs()
     {
-        return *_args;
+        exps_t* args = new exps_t;
+        std::copy(++(_exps.begin()), _exps.end(), args->begin());
+        return *args;
     }
 
     virtual ExpType getType()
@@ -117,8 +116,6 @@ public:
     }
 
 protected:
-    Exp* _name;
-    std::list<Exp *>* _args;
 };
 
 } // namespace ast
index 22fc001..1853df2 100644 (file)
@@ -23,17 +23,19 @@ class CaseExp : public ControlExp
 public :
     CaseExp(const Location& location,
             Exp& test,
-            SeqExp& body) :
-        ControlExp (location),
-        _test (&test),
-        _body (&body)
+            Exp& body) :
+        ControlExp (location)
     {
+        test.setParent(this);
+        body.setParent(this);
+        _exps.push_back(&test);
+        _exps.push_back(&body);
     }
 
     ~CaseExp()
     {
-        delete _test;
-        delete _body;
+        delete _exps[0];
+        delete _exps[1];
     }
 
     virtual CaseExp* clone()
@@ -60,28 +62,24 @@ public:
 public :
     Exp* getTest() const
     {
-        return _test;
+        return _exps[0];
     }
-    SeqExp* getBody() const
+
+    Exp* getBody() const
     {
-        return _body;
+        return _exps[1];
     }
 
     virtual ExpType getType()
     {
         return CASEEXP;
     }
+
     inline bool isCaseExp() const
     {
         return true;
     }
-private :
-    Exp* _test;
-    SeqExp *_body;
 };
-
-/** \brief Define a shorthand for list of CaseExp* manipulation. */
-typedef std::list<CaseExp *> cases_t;
 }
 
 #endif /* !__AST_CASE_EXP_HXX__ */
index c2d9e03..45b64d4 100644 (file)
@@ -39,20 +39,20 @@ public:
     */
     CellCallExp (const Location& location,
                  Exp& name,
-                 std::list<Exp *>& args)
+                 exps_t& args)
         : CallExp(location, name, args)
     {
     }
 
     virtual CellCallExp* clone()
     {
-        std::list<Exp *>* args = new std::list<Exp *>;
-        for (std::list<Exp *>::const_iterator it = _args->begin() ; it != _args->end() ; ++it)
+        exps_t args;
+        for (exps_t::const_iterator it = ++(_exps.begin()); it != _exps.end() ; ++it)
         {
-            args->push_back((*it)->clone());
+            args.push_back((*it)->clone());
         }
 
-        CellCallExp* cloned = new CellCallExp(getLocation(), *getName().clone(), *args);
+        CellCallExp* cloned = new CellCallExp(getLocation(), *getName().clone(), args);
         cloned->setVerbose(isVerbose());
         return cloned;
     }
index f90c202..4195f41 100644 (file)
@@ -37,16 +37,16 @@ public:
     ** \param body EXP LIST intruction
     */
     CellExp (const Location& location,
-             std::list<MatrixLineExp *>& lines)
+             exps_t& lines)
         : MatrixExp (location, lines)
     {
     }
 
     virtual CellExp* clone()
     {
-        std::list<MatrixLineExp *>* lines = new std::list<MatrixLineExp *>;
-        std::copy(getLines().begin(), getLines().end(), lines->begin());
-        CellExp* cloned = new CellExp(getLocation(), *lines);
+        exps_t lines;
+        std::copy(getLines().begin(), getLines().end(), lines.begin());
+        CellExp* cloned = new CellExp(getLocation(), lines);
         cloned->setVerbose(isVerbose());
         return cloned;
     }
index 7a6e73b..3b0828d 100644 (file)
@@ -31,6 +31,11 @@ public:
     virtual ~ConstExp ()
     {
     }
+
+    inline bool isConstExp() const
+    {
+        return true;
+    }
 };
 } // namespace ast
 #endif
index f678493..e5af6da 100644 (file)
@@ -25,7 +25,6 @@ namespace ast
 class Ast;
 
 class Exp;
-typedef std::list<Exp *> exps_t;
 // Low Level Expressions.
 
 // Const Exp
index 37ec016..d539f98 100644 (file)
 #define AST_EXP_HXX
 
 #include <list>
+#include <vector>
 
 #include "ast.hxx"
 
 namespace ast
 {
 
+/** \brief Define a shorthand for list of Exp* manipulation. */
+typedef std::vector<Exp *> exps_t;
+
 /** \brief Abstract an Expression node. */
 class Exp : public Ast
 {
@@ -48,6 +52,10 @@ public:
     /** \brief Destroys an Expression node. */
     virtual ~Exp ()
     {
+        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd; ++it)
+        {
+            delete *it;
+        }
     }
     /** \} */
 
@@ -173,6 +181,7 @@ public:
         BOOLEXP,
         STRINGEXP,
         COMMENTEXP,
+        CONSTEXP,
         NILEXP,
         CALLEXP,
         CELLCALLEXP,
@@ -211,6 +220,12 @@ public:
         return static_cast<T*>(this);
     }
 
+    template <class T>
+    inline const T* getAs(void) const
+    {
+        return static_cast<const T*>(this);
+    }
+
     inline virtual bool isSimpleVar() const
     {
         return false;
@@ -251,6 +266,11 @@ public:
         return false;
     }
 
+    inline virtual bool isConstExp() const
+    {
+        return false;
+    }
+
     inline virtual bool isNilExp() const
     {
         return false;
@@ -394,11 +414,10 @@ private:
     bool _bReturnable;
     bool _bContinue;
     bool _bContinuable;
+protected:
+    exps_t _exps;
+    Exp* _original;
 };
-
-/** \brief Define a shorthand for list of Exp* manipulation. */
-typedef std::list<Exp *> exps_t;
-
 } // namespace ast
 
 #endif // !AST_EXP_HXX
index 0c44469..6b12fed 100644 (file)
@@ -44,10 +44,12 @@ public:
     ** \li "2097" is the initial value of the field */
     FieldExp (const Location& location,
               Exp& head, Exp& tail)
-        : Exp (location),
-          _head (&head),
-          _tail (&tail)
+        : Exp (location)
     {
+        head.setParent(this);
+        tail.setParent(this);
+        _exps[0] = &head;
+        _exps[1] = &tail;
     }
 
     /** \brief Destroy a Field Expression node.
@@ -55,8 +57,8 @@ public:
     ** Delete name and init (see constructor). */
     virtual ~FieldExp()
     {
-        delete _head;
-        delete _tail;
+        delete _exps[0];
+        delete _exps[1];
     }
     /** \}*/
 
@@ -89,25 +91,25 @@ public:
     /** \brief Return the name of the field (read only). */
     const Exp* getHead() const
     {
-        return _head;
+        return _exps[0];
     }
 
     /** \brief Return the initial value of the field (read only). */
     const Exp* getTail() const
     {
-        return _tail;
+        return _exps[1];
     }
 
     /** \brief Return the initial value of the field (read and write). */
     Exp* getHead()
     {
-        return _head;
+        return _exps[0];
     }
 
     /** \brief Return the initial value of the field (read and write). */
     Exp* getTail()
     {
-        return _tail;
+        return _exps[1];
     }
     /** \} */
 
@@ -115,15 +117,12 @@ public:
     {
         return FIELDEXP;
     }
+
     inline bool isFieldExp() const
     {
         return true;
     }
 protected:
-    /** \brief Name of the field. */
-    Exp* _head;
-    /** \brief Initial value of the field. */
-    Exp* _tail;
 };
 
 /** \brief Define shortand type for Field Expression list. */
index b551b45..ba873ff 100644 (file)
@@ -42,11 +42,13 @@ public:
     ** \li "print("WipeOut")" is the body
     */
     ForExp (const Location& location,
-            VarDec& vardec, Exp& body)
-        : ControlExp (location),
-          _vardec (&vardec),
-          _body (&body)
+            Exp& vardec, Exp& body)
+        : ControlExp (location)
     {
+        vardec.setParent(this);
+        body.setParent(this);
+        _exps[0] = &vardec;
+        _exps[1] = &body;
     }
 
     /** \brief Destroy a For Expression node.
@@ -54,8 +56,8 @@ public:
     ** Delete vardec, hi and body (see constructor). */
     virtual ~ForExp ()
     {
-        delete  _vardec;
-        delete  _body;
+        delete _exps[0];
+        delete _exps[1];
     }
     /** \} */
 
@@ -86,25 +88,25 @@ public:
     ** \{ */
 public:
     /** \brief Return the implicit variable declaration (read only) */
-    VarDec& getVardec() const
+    Exp& getVardec() const
     {
-        return *_vardec;
+        return *_exps[0];
     }
     /** \brief Return the implicit variable declaration (read and write) */
-    VarDec& getVardec()
+    Exp& getVardec()
     {
-        return *_vardec;
+        return *_exps[0];
     }
 
     /** \brief Return the body of the loop (read only) */
     const Exp& getBody() const
     {
-        return *_body;
+        return *_exps[1];
     }
     /** \brief Return the body of the loop (read and write) */
     Exp& getBody()
     {
-        return *_body;
+        return *_exps[1];
     }
     /** \} */
 
@@ -116,12 +118,6 @@ public:
     {
         return true;
     }
-
-protected:
-    /** \brief Implicit variable declaration. */
-    VarDec* _vardec;
-    /** \brief Instructions executed in the loop. */
-    Exp* _body;
 };
 
 } // namespace ast
index 01f7573..62430a3 100644 (file)
@@ -48,25 +48,28 @@ public:
     */
     FunctionDec (const Location& location,
                  symbol::Symbol& name,
-                 ArrayListVar& args,
-                 ArrayListVar& returns,
+                 Exp& args,
+                 Exp& returns,
                  Exp& body)
         : Dec (location),
           _name (name),
-          _args (&args),
-          _returns (&returns),
-          _body (&body),
           _stack(NULL)
     {
+        args.setParent(this);
+        returns.setParent(this);
+        body.setParent(this);
+        _exps[0] = &args;
+        _exps[1] = &returns;
+        _exps[2] = &body;
     }
 
     virtual ~FunctionDec ()
     {
         //body will be deleted by types::Macro
-        //delete _body;
-        delete _args;
-        delete _returns;
-        delete &_name;
+        //delete _exps[2];
+        delete _exps[0];
+        delete _exps[1];
+
     }
 
     virtual FunctionDec* clone()
@@ -99,37 +102,37 @@ public:
 
     const Exp& getBody(void) const
     {
-        return *_body;
+        return *_exps[2];
     }
 
     Exp& getBody (void)
     {
-        return *_body;
+        return *_exps[2];
     }
 
-    const ArrayListVar& getArgs() const
+    const Exp& getArgs() const
     {
-        return *_args;
+        return *_exps[0];
     }
 
-    ArrayListVar& getArgs()
+    Exp& getArgs()
     {
-        return *_args;
+        return *_exps[0];
     }
 
-    const ArrayListVar& getReturns() const
+    const Exp& getReturns() const
     {
-        return *_returns;
+        return *_exps[1];
     }
 
-    ArrayListVar& getReturns()
+    Exp& getReturns()
     {
-        return *_returns;
+        return *_exps[1];
     }
 
     void setBody(Exp *body)
     {
-        _body = body;
+        _exps[2] = body;
     }
 
     symbol::Variable* getStack()
@@ -151,12 +154,8 @@ public:
         return true;
     }
 protected:
-    symbol::Symbol&     _name;
-    ArrayListVar*       _args;
-    ArrayListVar*       _returns;
-    Exp*                _body;
-    symbol::Variable*   _stack;
-
+    symbol::Symbol& _name;
+    symbol::Variable* _stack;
 };
 
 } // namespace ast
index c45ef0a..5d4ea01 100644 (file)
@@ -36,29 +36,35 @@ public:
     IfExp(const Location& location,
           Exp& test, Exp& t, Exp& e)
         : ControlExp (location),
-          _test (&test),
-          _then (&t),
-          _else (&e),
           _hasElse (true)
     {
+        test.setParent(this);
+        t.setParent(this);
+        e.setParent(this);
+        _exps[0] = &test;
+        _exps[1] = &t;
+        _exps[2] = &e;
     }
 
     IfExp(const Location& location,
           Exp& test, Exp& t)
         : ControlExp (location),
-          _test (&test),
-          _then (&t),
-          _else (new ast::CommentExp(location, new std::wstring(L"No else !!"))),
-          // For first display in order to see what appends
           _hasElse (false)
     {
+        test.setParent(this);
+        t.setParent(this);
+
+        _exps[0] = &test;
+        _exps[1] = &t;
+        _exps[2] = new ast::CommentExp(location, new std::wstring(L"No else !!"));
+        _exps[2]->setParent(this);
     }
 
     virtual ~IfExp()
     {
-        delete _test;
-        delete _then;
-        delete _else;
+        delete _exps[0];
+        delete _exps[1];
+        delete _exps[2];
     }
 
     virtual IfExp* clone()
@@ -84,43 +90,43 @@ public:
     // \brief Return the select condition of the loop (read only).
     const Exp& getTest() const
     {
-        return *_test;
+        return *_exps[0];
     }
     // \brief Return the select condition of the loop (read and write).
     Exp& getTest()
     {
-        return *_test;
+        return *_exps[0];
     }
 
     // \brief Return the intructions if test is true (read only).
     const Exp& getThen() const
     {
-        return *_then;
+        return *_exps[1];
     }
     // \brief Return the instructions if test is true (read and write).
     Exp& getThen()
     {
-        return *_then;
+        return *_exps[1];
     }
 
     // \brief Return the instruction if test is false (read only).
     const Exp& getElse() const
     {
-        return *_else;
+        return *_exps[2];
     }
     // \brief Return the instruction if test is false (read and write).
     Exp& getElse()
     {
-        return *_else;
+        return *_exps[2];
     }
 
     // \brief Return if there is an else body
-    bool       hasElse()
+    bool hasElse()
     {
         return _hasElse;
     }
     // \brief Return if there is an else body
-    bool       hasElse() const
+    bool hasElse() const
     {
         return _hasElse;
     }
@@ -135,10 +141,7 @@ public:
     }
 protected:
     // \brief "has a value" qualifier.
-    Exp*       _test;
-    Exp*       _then;
-    Exp*       _else;
-    bool       _hasElse;
+    bool _hasElse;
 };
 
 } // namespace ast
index aefb38a..487e65d 100644 (file)
@@ -41,11 +41,23 @@ public:
     ListExp (const Location& location,
              Exp& start, Exp& step, Exp& end, bool explicitStep = false)
         : Exp (location),
-          _start (&start),
-          _step (&step),
-          _end (&end),
           _explicitStep(explicitStep)
     {
+        start.setParent(this);
+        step.setParent(this);
+        end.setParent(this);
+        _exps[0] = &start;
+        _exps[1] = &step;
+        _exps[2] = &end;
+
+        values[0] = std::numeric_limits<double>::quiet_NaN();
+        values[1] = std::numeric_limits<double>::quiet_NaN();
+        values[2] = std::numeric_limits<double>::quiet_NaN();
+
+        is_values_int[0] = false;
+        is_values_int[1] = false;
+        is_values_int[2] = false;
+
     }
 
     /** \brief Destroy a Operation Expression node.
@@ -53,9 +65,9 @@ public:
     ** Delete left and right, see constructor. */
     virtual ~ListExp ()
     {
-        delete _start;
-        delete _step;
-        delete _end;
+        delete _exps[0];
+        delete _exps[1];
+        delete _exps[2];
     }
     /** \} */
 
@@ -88,34 +100,46 @@ public:
     /** \brief Return the expression (read only) */
     const Exp& getStart () const
     {
-        return *_start;
+        return *_exps[0];
     }
     /** \brief Return the expression (read and write) */
     Exp& getStart ()
     {
-        return *_start;
+        return *_exps[0];
     }
 
     /** \brief Return the expression (read only) */
     const Exp& getStep () const
     {
-        return *_step;
+        return *_exps[1];
     }
     /** \brief Return the expression (read and write) */
     Exp& getStep ()
     {
-        return *_step;
+        return *_exps[1];
     }
 
     /** \brief Return the expression (read only) */
     const Exp& getEnd () const
     {
-        return *_end;
+        return *_exps[2];
     }
     /** \brief Return the expression (read and write) */
     Exp& getEnd ()
     {
-        return *_end;
+        return *_exps[2];
+    }
+
+    inline void setValues(double start, double step, double end)
+    {
+        values[0] = start;
+        values[1] = step;
+        values[2] = end;
+    }
+
+    inline const double * getValues() const
+    {
+        return values;
     }
 
     /** \brief Return if expression has explicit step defined */
@@ -135,12 +159,8 @@ public:
     }
 
 protected:
-    /** \brief start expression of the list. */
-    Exp* _start;
-    /** \brief step expression of the list. */
-    Exp* _step;
-    /** \brief end expression of the list. */
-    Exp* _end;
+    double values[3];
+    bool is_values_int[3];
     /** \brief has list explicit step. */
     bool _explicitStep;
 };
index 28dd030..c52dc14 100644 (file)
@@ -36,30 +36,33 @@ public:
     ** \param body EXP LIST intruction
     */
     MatrixExp (const Location& location,
-               std::list<MatrixLineExp *>& lines)
-        : MathExp (location),
-          _lines (&lines)
+               exps_t& lines)
+        : MathExp (location)
     {
+        for (exps_t::const_iterator it = lines.begin(), itEnd = lines.end(); it != itEnd ; ++it)
+        {
+            (*it)->setParent(this);
+            _exps.push_back(*it);
+        }
     }
 
     virtual ~MatrixExp ()
     {
-        for (std::list<MatrixLineExp *>::const_iterator i = _lines->begin() ; i != _lines->end() ; ++i)
+        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
         {
-            delete *i;
+            delete *it;
         }
-        delete _lines;
     }
 
     virtual MatrixExp* clone()
     {
-        std::list<MatrixLineExp *>* lines = new std::list<MatrixLineExp *>;
-        for (std::list<MatrixLineExp *>::const_iterator it = getLines().begin(), end = getLines().end(); it != end; ++it)
+        exps_t lines;
+        for (exps_t::const_iterator it = getLines().begin(), itEnd = getLines().end(); it != itEnd; ++it)
         {
-            lines->push_back((*it)->clone());
+            lines.push_back((*it)->clone());
         }
 
-        MatrixExp* cloned = new MatrixExp(getLocation(), *lines);
+        MatrixExp* cloned = new MatrixExp(getLocation(), lines);
         cloned->setVerbose(isVerbose());
         return cloned;
     }
@@ -82,14 +85,14 @@ public:
     /** \name Accessors.
     ** \{ */
 public:
-    const std::list<MatrixLineExp *>& getLines() const
+    const exps_t& getLines() const
     {
-        return *_lines;
+        return _exps;
     }
 
-    std::list<MatrixLineExp *>& getLines()
+    exps_t& getLines()
     {
-        return *_lines;
+        return _exps;
     }
     /** \} */
 
@@ -102,8 +105,6 @@ public:
     {
         return true;
     }
-protected:
-    std::list<MatrixLineExp *>* _lines;
 };
 
 } // namespace ast
index 1d2bb0e..1a6ef4b 100644 (file)
@@ -36,33 +36,33 @@ public:
     ** \param columns EXP LIST intruction
     */
     MatrixLineExp (const Location& location,
-                   std::list<Exp *>& columns)
-        : MathExp (location),
-          _columns (&columns)
+                   exps_t& columns)
+        : MathExp (location)
     {
+        for (exps_t::const_iterator it = columns.begin(), itEnd = columns.end(); it != itEnd ; ++it)
+        {
+            (*it)->setParent(this);
+            _exps.push_back(*it);
+        }
     }
 
     virtual ~MatrixLineExp ()
     {
-        std::list<Exp *>::const_iterator it = _columns->begin();
-        std::list<Exp *>::const_iterator itEnd = _columns->end();
-        for (; it != itEnd ; ++it)
+        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
         {
             delete *it;
         }
-
-        delete _columns;
     }
 
     virtual MatrixLineExp* clone()
     {
-        std::list<Exp *>* columns = new std::list<Exp *>;
-        for (std::list<Exp *>::const_iterator it = getColumns().begin() ; it != getColumns().end() ; ++it)
+        exps_t columns;
+        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd; ++it)
         {
-            columns->push_back((*it)->clone());
+            columns.push_back((*it)->clone());
         }
 
-        MatrixLineExp* cloned = new MatrixLineExp(getLocation(), *columns);
+        MatrixLineExp* cloned = new MatrixLineExp(getLocation(), columns);
         cloned->setVerbose(isVerbose());
         return cloned;
     }
@@ -86,14 +86,14 @@ public:
     /** \name Accessors.
     ** \{ */
 public:
-    const std::list<Exp *>&    getColumns() const
+    const exps_t&      getColumns() const
     {
-        return *_columns;
+        return _exps;
     }
 
-    std::list<Exp *>& getColumns()
+    exps_t& getColumns()
     {
-        return *_columns;
+        return _exps;
     }
     /** \} */
 
@@ -106,8 +106,6 @@ public:
     {
         return true;
     }
-protected:
-    std::list<Exp *>* _columns;
 };
 
 } // namespace ast
index c06e498..7a9132b 100644 (file)
@@ -34,9 +34,10 @@ public:
     */
     NotExp (const Location& location,
             Exp& exp)
-        : MathExp (location),
-          _exp (&exp)
+        : MathExp (location)
     {
+        exp.setParent(this);
+        _exps[0] = &exp;
     }
 
     /** \brief Destroy a Not Operation Expression node.
@@ -44,7 +45,7 @@ public:
     ** Delete expression, see constructor. */
     virtual ~NotExp ()
     {
-        delete _exp;
+        delete _exps[0];
     }
     /** \} */
 
@@ -77,12 +78,12 @@ public:
     /** \brief Return the expression of the operation (read only) */
     const Exp& getExp() const
     {
-        return *_exp;
+        return *_exps[0];
     }
     /** \brief Return the expression of the operation (read and write) */
     Exp& getExp()
     {
-        return *_exp;
+        return *_exps[0];
     }
 
     virtual ExpType getType()
@@ -93,9 +94,6 @@ public:
     {
         return true;
     }
-protected:
-    /** \brief Left expression of the operation. */
-    Exp* _exp;
 };
 
 } // namespace ast
index 36f9e99..d8f162b 100644 (file)
@@ -88,10 +88,12 @@ public:
     OpExp (const Location& location,
            Exp& left, Oper oper, Exp& right)
         : MathExp (location),
-          _left (&left),
-          _oper (oper),
-          _right (&right)
+          _oper (oper)
     {
+        left.setParent(this);
+        right.setParent(this);
+        _exps[0] = &left;
+        _exps[1] = &right;
     }
 
     /** \brief Destroy a Operation Expression node.
@@ -99,8 +101,8 @@ public:
     ** Delete left and right, see constructor. */
     virtual ~OpExp ()
     {
-        delete _left;
-        delete _right;
+        delete _exps[0];
+        delete _exps[1];
     }
     /** \} */
 
@@ -127,12 +129,18 @@ public:
     /** \} */
 
 
-    /** \name Setters.
-    ** \{ */
+    /** \name Setters. */
 public :
     virtual void setLeft(Exp& left)
     {
-        _left = &left;
+        _exps[0] = &left;
+        left.setParent(this);
+    }
+
+    virtual void setRight(Exp& right)
+    {
+        _exps[1] = &right;
+        right.setParent(this);
     }
     /** \} */
 
@@ -143,12 +151,12 @@ public:
     /** \brief Return the left expression of the operation (read only) */
     const Exp& getLeft() const
     {
-        return *_left;
+        return *_exps[0];
     }
     /** \brief Return the left expression of the operation (read and write) */
     Exp& getLeft()
     {
-        return *_left;
+        return *_exps[0];
     }
 
     /** \brief Return the operator description (read only) */
@@ -160,12 +168,12 @@ public:
     /** \brief Return the right expression of the operation (read only) */
     const Exp& getRight() const
     {
-        return *_right;
+        return *_exps[1];
     }
     /** \brief Return the right expression of the operation (read and write) */
     Exp& getRight()
     {
-        return *_right;
+        return *_exps[1];
     }
 
     virtual ExpType getType()
@@ -178,12 +186,8 @@ public:
     }
 
 protected:
-    /** \brief Left expression of the operation. */
-    Exp* _left;
     /** \brief Operator. */
     Oper _oper;
-    /** \brief Right expression of the operation. */
-    Exp* _right;
 };
 
 } // namespace ast
index 2637f73..ee55569 100644 (file)
@@ -19,6 +19,7 @@
 #define AST_RETURNEXP_HXX
 
 #include "controlexp.hxx"
+#include "commentexp.hxx"
 
 namespace ast
 {
@@ -34,30 +35,27 @@ public:
     ** \param location scanner position informations
     ** \param exp the returned exp
     */
-    ReturnExp (const Location& location, Exp  *exp)
+    ReturnExp (const Location& location, Exp* exp = NULL)
         : ControlExp (location),
-          _exp (exp),
           _is_global(true)
     {
         if (exp)
         {
             _is_global = false;
+            exp->setParent(this);
+            _exps[0] = exp;
+        }
+        else
+        {
+            _exps[0] = new ast::CommentExp(location, new std::wstring(L"No return !!"));
+            _exps[0]->setParent(this);
         }
-    }
 
-    ReturnExp (const Location& location)
-        : ControlExp (location),
-          _exp (NULL),
-          _is_global(true)
-    {
     }
 
     virtual ~ReturnExp ()
     {
-        if (_exp != NULL)
-        {
-            delete _exp;
-        }
+        delete _exps[0];
     }
 
     virtual ReturnExp* clone()
@@ -96,12 +94,12 @@ public:
 public:
     const Exp &        getExp() const
     {
-        return *_exp;
+        return *_exps[0];
     }
 
     Exp &      getExp()
     {
-        return *_exp;
+        return *_exps[0];
     }
 
     bool isGlobal() const
@@ -118,7 +116,6 @@ public:
         return true;
     }
 protected:
-    Exp                *_exp;
     bool       _is_global;
 };
 
index 090d5b4..a3180b3 100644 (file)
@@ -30,58 +30,71 @@ class SelectExp : public ControlExp
 public :
     SelectExp(const Location& location,
               Exp& select,
-              cases_t& cases,
-              SeqExp& defaultCase)
+              exps_t& cases,
+              Exp& defaultCase)
         : ControlExp (location),
-          _selectme (&select),
-          _cases (&cases),
-          _default (&defaultCase)
+          _hasDefault(true)
     {
+        select.setParent(this);
+        _exps.push_back(&select);
+
+        for (exps_t::const_iterator it = cases.begin(), itEnd = cases.end(); it != itEnd ; ++it)
+        {
+            (*it)->setParent(this);
+            _exps.push_back(*it);
+        }
+
+        defaultCase.setParent(this);
+        _exps.push_back(&defaultCase);
     }
 
     SelectExp(const Location& location,
               Exp& select,
-              cases_t& cases)
+              exps_t& cases)
         : ControlExp (location),
-          _selectme (&select),
-          _cases (&cases),
-          _default(NULL)
+          _hasDefault(false)
     {
+        select.setParent(this);
+        _exps.push_back(&select);
+
+        for (exps_t::const_iterator it = cases.begin(), itEnd = cases.end(); it != itEnd ; ++it)
+        {
+            (*it)->setParent(this);
+            _exps.push_back(*it);
+        }
     }
 
     ~SelectExp()
     {
-        delete _selectme;
-
-        for (cases_t::const_iterator it = _cases->begin(), itEnd = _cases->end(); it != itEnd ; ++it)
+        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
         {
             delete *it;
         }
-
-        delete _cases;
-
-        if (_default != NULL)
-        {
-            delete _default;
-        }
     }
 
     virtual SelectExp* clone()
     {
-        cases_t* cases = new cases_t;
-        for (cases_t::const_iterator it = getCases()->begin() ; it != getCases()->end() ; it++)
+        exps_t cases;
+        exps_t::const_iterator it = ++(_exps.begin());
+        exps_t::const_iterator itEnd = _exps.end();
+        if (_hasDefault)
         {
-            cases->push_back((*it)->clone());
+            --itEnd;
+        }
+
+        for (; it != itEnd ; ++it)
+        {
+            cases.push_back((*it)->clone());
         }
 
         SelectExp* cloned = NULL;
-        if (_default != NULL)
+        if (_hasDefault)
         {
-            cloned = new SelectExp(getLocation(), *getSelect()->clone(), *cases, *getDefaultCase()->clone());
+            cloned = new SelectExp(getLocation(), *getSelect()->clone(), cases, *getDefaultCase()->clone());
         }
         else
         {
-            cloned = new SelectExp(getLocation(), *getSelect()->clone(), *cases);
+            cloned = new SelectExp(getLocation(), *getSelect()->clone(), cases);
         }
 
         cloned->setVerbose(isVerbose());
@@ -91,15 +104,37 @@ public :
 public :
     Exp* getSelect() const
     {
-        return _selectme;
+        return _exps[0];
     }
-    cases_t* getCases() const
+
+    exps_t* getCases() const
     {
-        return _cases;
+        exps_t* cases = new exps_t;
+        exps_t::const_iterator it = ++(_exps.begin());
+        exps_t::const_iterator itEnd = _exps.end();
+        if (_hasDefault)
+        {
+            --itEnd;
+        }
+
+        for (; it != itEnd ; ++it)
+        {
+            cases->push_back((*it)->clone());
+        }
+
+        return cases;
     }
-    SeqExp* getDefaultCase() const
+
+    Exp* getDefaultCase() const
     {
-        return _default;
+        if (_hasDefault)
+        {
+            return _exps.back();
+        }
+        else
+        {
+            return NULL;
+        }
     }
 
     /** \name Visitors entry point.
@@ -121,14 +156,23 @@ public:
     {
         return SELECTEXP;
     }
+
     inline bool isSelectExp() const
     {
         return true;
     }
-private :
-    Exp* _selectme;
-    cases_t* _cases;
-    SeqExp* _default;
+
+    bool hasDefault()
+    {
+        return _hasDefault;
+    }
+
+    bool hasDefault() const
+    {
+        return _hasDefault;
+    }
+
+    bool _hasDefault;
 };
 
 }
index fc6badf..b71c621 100644 (file)
@@ -37,30 +37,33 @@ public:
     ** \param body EXP LIST intruction
     */
     SeqExp (const Location& location,
-            std::list<Exp *>& l_body)
-        : Exp (location),
-          _l_body (&l_body)
+            exps_t& body)
+        : Exp (location)
     {
+        for (exps_t::const_iterator it = body.begin(), itEnd = body.end(); it != itEnd ; ++it)
+        {
+            (*it)->setParent(this);
+            _exps.push_back(*it);
+        }
     }
 
     virtual ~SeqExp ()
     {
-        for (std::list<Exp *>::const_iterator i = _l_body->begin() ; i != _l_body->end() ; ++i)
+        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
         {
-            delete *i;
+            delete *it;
         }
-        delete _l_body;
     }
 
     virtual SeqExp* clone()
     {
-        std::list<Exp *>* exp = new std::list<Exp *>;
-        for (std::list<Exp *>::const_iterator it = getExps().begin() ; it != getExps().end() ; ++it)
+        exps_t exp;
+        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd; ++it)
         {
-            exp->push_back((*it)->clone());
+            exp.push_back((*it)->clone());
         }
 
-        SeqExp* cloned = new SeqExp(getLocation(), *exp);
+        SeqExp* cloned = new SeqExp(getLocation(), exp);
         cloned->setVerbose(isVerbose());
         return cloned;
     }
@@ -83,19 +86,20 @@ public:
     /** \name Accessors.
     ** \{ */
 public:
-    const std::list<Exp *>&    getExps() const
+    const exps_t& getExps() const
     {
-        return *_l_body;
+        return _exps;
     }
 
-    std::list<Exp *>& gExps()
+    exps_t& getExps()
     {
-        return *_l_body;
+        return _exps;
     }
 
     void clearExps()
     {
-        _l_body->clear();
+        //no delete ?
+        _exps.clear();
     }
     /** \} */
 
@@ -108,8 +112,6 @@ public:
     {
         return true;
     }
-protected:
-    std::list<Exp *>* _l_body;
 };
 
 } // namespace ast
index b7ef261..45f007e 100644 (file)
@@ -43,9 +43,10 @@ public:
                   Exp& exp,
                   Kind kind)
         : MathExp (location),
-          _exp (&exp),
           _conjugate (kind)
     {
+        exp.setParent(this);
+        _exps[0] = &exp;
     }
 
     /** \brief Destroy a Transpose Operation Expression node.
@@ -53,7 +54,7 @@ public:
     ** Delete expression, see constructor. */
     virtual ~TransposeExp ()
     {
-        delete _exp;
+        delete _exps[0];
     }
     /** \} */
 
@@ -86,12 +87,12 @@ public:
     /** \brief Return the expression of the operation (read only) */
     const Exp& getExp() const
     {
-        return *_exp;
+        return *_exps[0];
     }
     /** \brief Return the expression of the operation (read and write) */
     Exp& getExp()
     {
-        return *_exp;
+        return *_exps[0];
     }
     /** \brief Return the conjugate kind of the transposition */
     Kind getConjugate() const
@@ -108,8 +109,6 @@ public:
         return true;
     }
 protected:
-    /** \brief Left expression of the operation. */
-    Exp* _exp;
     Kind _conjugate;
 };
 
index 5140a8a..a114fe8 100644 (file)
@@ -37,18 +37,20 @@ public:
     ** \param body EXP LIST intruction
     */
     TryCatchExp (const Location& location,
-                 SeqExp& tried,
-                 SeqExp& catched)
-        : ControlExp (location),
-          _tryme (&tried),
-          _catchme (&catched)
+                 Exp& tryme,
+                 Exp& catchme)
+        : ControlExp (location)
     {
+        tryme.setParent(this);
+        catchme.setParent(this);
+        _exps[0] = &tryme;
+        _exps[1] = &catchme;
     }
 
     virtual ~TryCatchExp ()
     {
-        delete _tryme;
-        delete _catchme;
+        delete _exps[0];
+        delete _exps[1];
     }
 
     virtual TryCatchExp* clone()
@@ -76,23 +78,24 @@ public:
     /** \name Accessors.
     ** \{ */
 public:
-    const SeqExp& getTry() const
+    const Exp& getTry() const
     {
-        return *_tryme;
+        return *_exps[0];
     }
 
-    SeqExp& getTry()
+    Exp& getTry()
     {
-        return *_tryme;
+        return *_exps[0];
     }
-    const SeqExp& getCatch() const
+
+    const Exp& getCatch() const
     {
-        return *_catchme;
+        return *_exps[1];
     }
 
-    SeqExp& getCatch()
+    Exp& getCatch()
     {
-        return *_catchme;
+        return *_exps[1];
     }
     /** \} */
 
@@ -104,10 +107,6 @@ public:
     {
         return true;
     }
-
-protected:
-    SeqExp* _tryme;
-    SeqExp* _catchme;
 };
 
 } // namespace ast
index 4baa80d..355cbb7 100644 (file)
@@ -51,9 +51,10 @@ public:
             symbol::Symbol& name, Exp& init)
         : Dec (location),
           _name (name),
-          _init (&init),
           _stack(NULL)
     {
+        init.setParent(this);
+        _exps[0] = &init;
     }
 
     /** \brief Destroy a Variable Declaration node.
@@ -62,7 +63,7 @@ public:
     virtual ~VarDec()
     {
         delete &_name;
-        delete _init;
+        delete _exps[0];
     }
     /** \} */
 
@@ -110,12 +111,12 @@ public:
     /** \brief Return the initial expression value (read only). */
     const Exp& getInit (void) const
     {
-        return *_init;
+        return *_exps[0];
     }
     /** \brief Return the initial expression value (read and write). */
     Exp& getInit (void)
     {
-        return *_init;
+        return *_exps[0];
     }
 
     analysis::ForList64 getListInfo() const
@@ -151,8 +152,6 @@ protected:
     /** \brief Name of the declared variable. */
     symbol::Symbol& _name;
     symbol::Variable* _stack;
-    /** \brief The initial value (expression) assigned to the variable. */
-    Exp* _init;
 };
 
 } // namespace ast
index 85cc414..fcc300e 100644 (file)
@@ -41,10 +41,12 @@ public:
     */
     WhileExp (const Location& location,
               Exp& test, Exp& body)
-        : ControlExp (location),
-          _test (&test),
-          _body (&body)
+        : ControlExp (location)
     {
+        test.setParent(this);
+        body.setParent(this);
+        _exps[0] = &test;
+        _exps[1] = &body;
     }
 
     /** \brief Destroy a While Expression node.
@@ -52,8 +54,8 @@ public:
     ** Delete test and body (see constructor). */
     virtual ~WhileExp ()
     {
-        delete _test;
-        delete _body;
+        delete _exps[0];
+        delete _exps[1];
     }
     /** \}*/
 
@@ -86,23 +88,23 @@ public:
     /** \brief Return the exit condition of the loop (read only). */
     const Exp& getTest() const
     {
-        return *_test;
+        return *_exps[0];
     }
     /** \brief Return the exit condition of the loop (read and write). */
     Exp& getTest()
     {
-        return *_test;
+        return *_exps[0];
     }
 
     /** \brief Return the body of the loop (read only). */
     const Exp& getBody() const
     {
-        return *_body;
+        return *_exps[1];
     }
     /** \brief Return the body of the loop (read and write). */
     Exp& getBody()
     {
-        return *_body;
+        return *_exps[1];
     }
     /** \} */
 
@@ -114,11 +116,6 @@ public:
     {
         return true;
     }
-protected:
-    /** \brief Exit condition of the loop. */
-    Exp* _test;
-    /** \brief Instructions executed in the loop. */
-    Exp* _body;
 };
 
 } // namespace ast
index a6634d6..c3ad3bc 100644 (file)
@@ -228,7 +228,7 @@ union YYSTYPE
 
     LineBreakStr*               mute;
 
-    ast::vars_t*                t_list_var;
+    ast::exps_t*                t_list_var;
     ast::exps_t*                t_list_exp;
     ast::Exp*                   t_exp;
 
@@ -241,7 +241,7 @@ union YYSTYPE
     ast::TryCatchExp*           t_try_exp;
     ast::SelectExp*             t_select_exp;
     ast::CaseExp*               t_case_exp;
-    ast::cases_t*               t_list_case;
+    ast::exps_t*                t_list_case;
 
     ast::CallExp*               t_call_exp;
 
@@ -259,8 +259,7 @@ union YYSTYPE
 
     ast::MatrixExp*             t_matrix_exp;
     ast::MatrixLineExp*         t_matrixline_exp;
-    std::list<ast::MatrixLineExp *>*            \
-                                t_list_mline;
+    ast::exps_t*                t_list_mline;
 
     ast::CellExp*               t_cell_exp;
 
index de22ce4..0ffd5cc 100644 (file)
@@ -63,10 +63,10 @@ void DebugVisitor::visit (const MatrixExp &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec MatrixExp", e);
-    list<MatrixLineExp *>::const_iterator      i;
-    for (i = e.getLines().begin() ; i != e.getLines().end() ; ++i )
+    exps_t lines = e.getLines();
+    for (exps_t::const_iterator it = lines.begin(), itEnd = lines.end(); it != itEnd ; ++it)
     {
-        (*i)->accept (*this);
+        (*it)->accept (*this);
     }
     DEBUG_END_NODE();
 }
@@ -75,31 +75,26 @@ void DebugVisitor::visit (const MatrixLineExp &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec MatrixLineExp", e);
-    list<Exp *>::const_iterator        i;
-    for (i = e.getColumns().begin() ; i != e.getColumns().end() ; ++i)
+    exps_t columns = e.getColumns();
+    for (exps_t::const_iterator it = columns.begin(), itEnd = columns.end(); it != itEnd ; ++it)
     {
-        (*i)->accept (*this);
+        (*it)->accept (*this);
     }
     DEBUG_END_NODE();
 }
-/** \} */
 
 void DebugVisitor::visit (const CellExp &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec CellExp", e);
-    list<MatrixLineExp *>::const_iterator      i;
-    for (i = e.getLines().begin() ; i != e.getLines().end() ; ++i )
+    exps_t lines = e.getLines();
+    for (exps_t::const_iterator it = lines.begin(), itEnd = lines.end(); it != itEnd ; ++it)
     {
-        (*i)->accept (*this);
+        (*it)->accept (*this);
     }
     DEBUG_END_NODE();
 }
 
-/** \} */
-
-/** \name Visit Constant Expressions nodes.
-** \{ */
 void DebugVisitor::visit (const StringExp &e)
 {
     DEBUG_START_NODE(e);
@@ -138,10 +133,7 @@ void DebugVisitor::visit (const NilExp &e)
     DEBUG(L"Exec NilExp", e);
     DEBUG_END_NODE();
 }
-/** \} */
 
-/** \name Visit Variable related nodes.
-** \{ */
 void DebugVisitor::visit (const SimpleVar &e)
 {
     DEBUG_START_NODE(e);
@@ -167,27 +159,20 @@ void DebugVisitor::visit (const ArrayListVar &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec ArrayListVar", e);
-    list<Var *>::const_iterator        i;
-    for (i = e.getVars().begin() ; i != e.getVars().end() ; ++i)
+    exps_t vars = e.getVars();
+    for (exps_t::const_iterator it = vars.begin (), itEnd = vars.end(); it != itEnd; ++it)
     {
-        (*i)->accept (*this);
+        (*it)->accept(*this);
     }
     DEBUG_END_NODE();
 }
-/** \} */
-
-/** \name Visit Control Expressions or Instructions nodes.
-** \{ */
 
 void DebugVisitor::visit (const FieldExp &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec FieldExp", e);
-    // FIXME
-    {
-        e.getHead()->accept(*this);
-        e.getTail()->accept(*this);
-    }
+    e.getHead()->accept(*this);
+    e.getTail()->accept(*this);
     DEBUG_END_NODE();
 }
 
@@ -195,12 +180,8 @@ void DebugVisitor::visit(const OpExp &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec OpExp", e);
-    // FIXME
-    {
-        e.getLeft().accept(*this);
-        //e.oper_get();
-        e.getRight().accept(*this);
-    }
+    e.getLeft().accept(*this);
+    e.getRight().accept(*this);
     DEBUG_END_NODE();
 }
 
@@ -208,12 +189,8 @@ void DebugVisitor::visit(const LogicalOpExp &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec LogicalOpExp", e);
-    // FIXME
-    {
-        e.getLeft().accept(*this);
-        //e.oper_get();
-        e.getRight().accept(*this);
-    }
+    e.getLeft().accept(*this);
+    e.getRight().accept(*this);
     DEBUG_END_NODE();
 }
 
@@ -221,11 +198,8 @@ void DebugVisitor::visit (const AssignExp  &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec AssignExp", e);
-    //FIXME
-    {
-        e.getLeftExp().accept (*this);
-        e.getRightExp().accept (*this);
-    }
+    e.getLeftExp().accept (*this);
+    e.getRightExp().accept (*this);
     DEBUG_END_NODE();
 }
 
@@ -234,14 +208,11 @@ void DebugVisitor::visit(const CellCallExp &e)
     DEBUG_START_NODE(e);
     DEBUG(L"Exec CellCallExp", e);
     e.getName().accept (*this);
-    // FIXME
-    {
-        list<Exp *>::const_iterator    i;
 
-        for (i = e.getArgs().begin (); i != e.getArgs().end (); ++i)
-        {
-            (*i)->accept (*this);
-        }
+    exps_t args = e.getArgs();
+    for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
+    {
+        (*it)->accept(*this);
     }
     DEBUG_END_NODE();
 }
@@ -251,14 +222,11 @@ void DebugVisitor::visit(const CallExp &e)
     DEBUG_START_NODE(e);
     DEBUG(L"Exec CallExp", e);
     e.getName().accept (*this);
-    // FIXME
-    {
-        list<Exp *>::const_iterator    i;
 
-        for (i = e.getArgs().begin (); i != e.getArgs().end (); ++i)
-        {
-            (*i)->accept (*this);
-        }
+    exps_t args = e.getArgs();
+    for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
+    {
+        (*it)->accept (*this);
     }
     DEBUG_END_NODE();
 }
@@ -267,14 +235,11 @@ void DebugVisitor::visit (const IfExp  &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec IfExp", e);
-    // FIXME
+    e.getTest ().accept(*this);
+    e.getThen ().accept(*this);
+    if (e.hasElse())
     {
-        e.getTest ().accept(*this);
-        e.getThen ().accept(*this);
-        if (e.hasElse())
-        {
-            e.getElse ().accept(*this);
-        }
+        e.getElse ().accept(*this);
     }
     DEBUG_END_NODE();
 }
@@ -283,11 +248,8 @@ void DebugVisitor::visit (const TryCatchExp  &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec TryCatchExp", e);
-    // FIXME
-    {
-        e.getTry ().accept(*this);
-        e.getCatch ().accept(*this);
-    }
+    e.getTry ().accept(*this);
+    e.getCatch ().accept(*this);
     DEBUG_END_NODE();
 }
 
@@ -295,7 +257,6 @@ void DebugVisitor::visit (const WhileExp  &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec WhileExp", e);
-    // FIMXE
     e.getTest().accept (*this);
     e.getBody().accept (*this);
     DEBUG_END_NODE();
@@ -340,11 +301,13 @@ void DebugVisitor::visit (const SelectExp &e)
     DEBUG_START_NODE(e);
     DEBUG(L"Exec SelectExp", e);
     e.getSelect()->accept(*this);
-    ast::cases_t::iterator it;
-    for (it = e.getCases()->begin() ; it !=  e.getCases()->end() ; ++it)
+
+    exps_t* cases = e.getCases();
+    for (exps_t::iterator it = cases->begin(), itEnd = cases->end(); it !=  itEnd ; ++it)
     {
         (*it)->accept(*this);
     }
+
     if (e.getDefaultCase() != NULL)
     {
         e.getDefaultCase()->accept(*this);
@@ -365,14 +328,9 @@ void DebugVisitor::visit (const SeqExp  &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec SeqExp", e);
-    list<Exp *>::const_iterator        i;
-    for (i = e.getExps().begin (); i != e.getExps().end (); ++i)
+    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
     {
-        if (!(*i)->isVerbose())
-        {
-            DEBUG(L"__MUTE__");
-        }
-        (*i)->accept (*this);
+        (*it)->accept(*this);
     }
     DEBUG_END_NODE();
 }
@@ -381,10 +339,9 @@ void DebugVisitor::visit (const ArrayListExp  &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec ArrayListExp", e);
-    list<Exp *>::const_iterator        i;
-    for (i = e.getExps().begin (); i != e.getExps().end (); ++i)
+    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
     {
-        (*i)->accept (*this);
+        (*it)->accept (*this);
     }
     DEBUG_END_NODE();
 }
@@ -393,17 +350,13 @@ void DebugVisitor::visit (const AssignListExp  &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec AssignListExp", e);
-    list<Exp *>::const_iterator        i;
-    for (i = e.getExps().begin (); i != e.getExps().end (); ++i)
+    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
     {
-        (*i)->accept (*this);
+        (*it)->accept (*this);
     }
     DEBUG_END_NODE();
 }
-/** \} */
 
-/** \name Visit Single Operation nodes.
-** \{ */
 void DebugVisitor::visit (const NotExp &e)
 {
     DEBUG_START_NODE(e);
@@ -419,20 +372,14 @@ void DebugVisitor::visit (const TransposeExp &e)
     e.getExp().accept (*this);
     DEBUG_END_NODE();
 }
-/** \} */
 
-/** \name Visit Declaration nodes.
-** \{ */
-/** \brief Visit Var declarations. */
 void DebugVisitor::visit (const VarDec  &e)
 {
     DEBUG_START_NODE(e);
     DEBUG(L"Exec VarDec", e);
-    {
-        DEBUG_START_NODE(e);
-        DEBUG(L"Exec Symbol : " + e.getSymbol().getName(), e);
-        DEBUG_END_NODE();
-    }
+    DEBUG_START_NODE(e);
+    DEBUG(L"Exec Symbol : " + e.getSymbol().getName(), e);
+    DEBUG_END_NODE();
     e.getInit().accept(*this);
     DEBUG_END_NODE();
 }
@@ -457,10 +404,7 @@ void DebugVisitor::visit (const FunctionDec  &e)
 
     DEBUG_END_NODE();
 }
-/** \} */
 
-/** \name Visit Type dedicated Expressions related node.
-** \{ */
 void DebugVisitor::visit(const ListExp &e)
 {
     DEBUG_START_NODE(e);
@@ -470,5 +414,4 @@ void DebugVisitor::visit(const ListExp &e)
     e.getEnd().accept(*this);
     DEBUG_END_NODE();
 }
-/** \} */
 }
index eea9f94..4a0a548 100644 (file)
@@ -28,10 +28,10 @@ void MacrovarVisitor::visit(const CallExp &e)
     e.getName().accept (*this);
     add();
 
-    std::list<Exp *>::const_iterator i;
-    for (i = e.getArgs().begin (); i != e.getArgs().end (); ++i)
+    exps_t args = e.getArgs();
+    for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
     {
-        (*i)->accept (*this);
+        (*it)->accept (*this);
         add();
     }
 }
index 379db8c..ed56ec5 100644 (file)
@@ -17,34 +17,31 @@ namespace ast
 
 void MuteVisitor::visit (const MatrixExp &e)
 {
-    std::list<MatrixLineExp *>::const_iterator row;
-    for (row = e.getLines().begin() ; row != e.getLines().end() ; ++row )
+    exps_t lines = e.getLines();
+    for (exps_t::const_iterator it = lines.begin(), itEnd = lines.end(); it != itEnd ; ++it)
     {
-        (*row)->mute();
-        MuteVisitor mute;
-        (*row)->accept(mute);
+        (*it)->mute();
+        (*it)->accept(*this);
     }
 }
 
 void MuteVisitor::visit (const MatrixLineExp &e)
 {
-    std::list<Exp *>::const_iterator   col;
-    for (col = e.getColumns().begin() ; col != e.getColumns().end() ; ++col)
+    exps_t columns = e.getColumns();
+    for (exps_t::const_iterator it = columns.begin(), itEnd = columns.end(); it != itEnd ; ++it)
     {
-        (*col)->mute();
-        MuteVisitor mute;
-        (*col)->accept(mute);
+        (*it)->mute();
+        (*it)->accept(*this);
     }
 }
 
 void MuteVisitor::visit (const CellExp &e)
 {
-    std::list<MatrixLineExp *>::const_iterator row;
-    for (row = e.getLines().begin() ; row != e.getLines().end() ; ++row )
+    exps_t lines = e.getLines();
+    for (exps_t::const_iterator it = lines.begin(), itEnd = lines.end(); it != itEnd ; ++it)
     {
-        (*row)->mute();
-        MuteVisitor mute;
-        (*row)->accept(mute);
+        (*it)->mute();
+        (*it)->accept(*this);
     }
 }
 
@@ -82,12 +79,11 @@ void MuteVisitor::visit (const DollarVar &/*e*/)
 
 void MuteVisitor::visit (const ArrayListVar &e)
 {
-    std::list<Var *>::const_iterator var;
-    for (var = e.getVars().begin() ; var != e.getVars().end() ; var++)
+    exps_t vars = e.getVars();
+    for (exps_t::const_iterator it = vars.begin (), itEnd = vars.end(); it != itEnd; ++it)
     {
-        (*var)->mute();
-        MuteVisitor mute;
-        (*var)->accept(mute);
+        (*it)->mute();
+        (*it)->accept(*this);
     }
 }
 
@@ -96,9 +92,8 @@ void MuteVisitor::visit (const FieldExp &e)
     const_cast<Exp*>(e.getHead())->mute();
     const_cast<Exp*>(e.getTail())->mute();
 
-    MuteVisitor mute;
-    e.getHead()->accept(mute);
-    e.getTail()->accept(mute);
+    e.getHead()->accept(*this);
+    e.getTail()->accept(*this);
 }
 
 void MuteVisitor::visit(const OpExp &e)
@@ -106,9 +101,8 @@ void MuteVisitor::visit(const OpExp &e)
     const_cast<Exp&>(e.getLeft()).mute();
     const_cast<Exp&>(e.getRight()).mute();
 
-    MuteVisitor mute;
-    e.getLeft().accept(mute);
-    e.getRight().accept(mute);
+    e.getLeft().accept(*this);
+    e.getRight().accept(*this);
 }
 
 void MuteVisitor::visit(const LogicalOpExp &e)
@@ -116,9 +110,8 @@ void MuteVisitor::visit(const LogicalOpExp &e)
     const_cast<Exp&>(e.getLeft()).mute();
     const_cast<Exp&>(e.getRight()).mute();
 
-    MuteVisitor mute;
-    e.getLeft().accept(mute);
-    e.getRight().accept(mute);
+    e.getLeft().accept(*this);
+    e.getRight().accept(*this);
 }
 
 void MuteVisitor::visit (const AssignExp  &e)
@@ -126,30 +119,27 @@ void MuteVisitor::visit (const AssignExp  &e)
     const_cast<Exp&>(e.getLeftExp()).mute();
     const_cast<Exp&>(e.getRightExp()).mute();
 
-    MuteVisitor mute;
-    e.getLeftExp().accept(mute);
-    e.getRightExp().accept(mute);
+    e.getLeftExp().accept(*this);
+    e.getRightExp().accept(*this);
 }
 
 void MuteVisitor::visit(const CallExp &e)
 {
-    std::list<Exp *>::const_iterator arg;
-    for (arg = e.getArgs().begin() ; arg != e.getArgs().end() ; arg++)
+    exps_t args = e.getArgs();
+    for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
     {
-        (*arg)->mute();
-        MuteVisitor mute;
-        (*arg)->accept(mute);
+        (*it)->mute();
+        (*it)->accept(*this);
     }
 }
 
 void MuteVisitor::visit(const CellCallExp &e)
 {
-    std::list<Exp *>::const_iterator arg;
-    for (arg = e.getArgs().begin() ; arg != e.getArgs().end() ; arg++)
+    exps_t args = e.getArgs();
+    for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
     {
-        (*arg)->mute();
-        MuteVisitor mute;
-        (*arg)->accept(mute);
+        (*it)->mute();
+        (*it)->accept(*this);
     }
 }
 
@@ -162,23 +152,21 @@ void MuteVisitor::visit (const IfExp  &e)
         const_cast<Exp&>(e.getElse()).mute();
     }
 
-    MuteVisitor mute;
-    e.getTest().accept(mute);
-    e.getThen().accept(mute);
+    e.getTest().accept(*this);
+    e.getThen().accept(*this);
     if (e.hasElse())
     {
-        e.getElse().accept(mute);
+        e.getElse().accept(*this);
     }
 }
 
 void MuteVisitor::visit (const TryCatchExp  &e)
 {
-    const_cast<SeqExp&>(e.getTry()).mute();
-    const_cast<SeqExp&>(e.getCatch()).mute();
+    const_cast<Exp&>(e.getTry()).mute();
+    const_cast<Exp&>(e.getCatch()).mute();
 
-    MuteVisitor mute;
-    e.getTry().accept(mute);
-    e.getCatch().accept(mute);
+    e.getTry().accept(*this);
+    e.getCatch().accept(*this);
 }
 
 void MuteVisitor::visit (const WhileExp  &e)
@@ -186,17 +174,14 @@ void MuteVisitor::visit (const WhileExp  &e)
     const_cast<Exp&>(e.getTest()).mute();
     const_cast<Exp&>(e.getBody()).mute();
 
-    MuteVisitor mute;
-    e.getTest().accept(mute);
-    e.getBody().accept(mute);
+    e.getTest().accept(*this);
+    e.getBody().accept(*this);
 }
 
 void MuteVisitor::visit (const ForExp  &e)
 {
     const_cast<Exp&>(e.getBody()).mute();
-
-    MuteVisitor mute;
-    e.getBody().accept(mute);
+    e.getBody().accept(*this);
 }
 
 void MuteVisitor::visit (const BreakExp &/*e*/)
@@ -221,23 +206,19 @@ void MuteVisitor::visit (const CaseExp &/*e*/)
 
 void MuteVisitor::visit (const SeqExp  &e)
 {
-    std::list<Exp *>::const_iterator seq;
-    for (seq = e.getExps().begin() ; seq != e.getExps().end() ; seq++)
+    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
     {
-        (*seq)->mute();
-        MuteVisitor mute;
-        (*seq)->accept(mute);
+        (*it)->mute();
+        (*it)->accept(*this);
     }
 }
 
 void MuteVisitor::visit (const ArrayListExp  &e)
 {
-    std::list<Exp *>::const_iterator exp;
-    for (exp = e.getExps().begin() ; exp != e.getExps().end() ; exp++)
+    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
     {
-        (*exp)->mute();
-        MuteVisitor mute;
-        (*exp)->accept(mute);
+        (*it)->mute();
+        (*it)->accept(*this);
     }
 }
 
@@ -260,9 +241,7 @@ void MuteVisitor::visit (const VarDec  &/*e*/)
 void MuteVisitor::visit (const FunctionDec  &e)
 {
     const_cast<Exp&>(e.getBody()).mute();
-
-    MuteVisitor mute;
-    e.getBody().accept(mute);
+    e.getBody().accept(*this);
 }
 
 void MuteVisitor::visit(const ListExp &/*e*/)
index 59e43ba..b339dac 100644 (file)
@@ -19,11 +19,12 @@ namespace ast
  ** \{ */
 void PrintVisitor::visit (const MatrixExp &e)
 {
-    std::list<MatrixLineExp *>::const_iterator i, j;
+    ast::exps_t::const_iterator        i, j;
     *ostr << SCI_OPEN_MATRIX;
     ++indent;
     this->is_last_matrix_line = false;
-    for (i = e.getLines().begin() ; i != e.getLines().end() ; )
+    ast::exps_t lines = e.getLines();
+    for (i = lines.begin() ; i != lines.end() ; )
     {
         j = i;
         if (++j == e.getLines().end())
@@ -45,10 +46,11 @@ void PrintVisitor::visit (const MatrixExp &e)
 
 void PrintVisitor::visit (const MatrixLineExp &e)
 {
-    std::list<Exp *>::const_iterator        i;
-    bool                                    last_column_is_comment = false;
+    ast::exps_t::const_iterator        i, j;
+    bool last_column_is_comment = false;
 
-    for (i = e.getColumns().begin() ; i != e.getColumns().end() ; )
+    ast::exps_t cols = e.getColumns();
+    for (i = cols.begin() ; i != cols.end() ; )
     {
         (*i)->accept (*this);
         if (dynamic_cast<ast::CommentExp*>(*i) != NULL)
@@ -75,10 +77,12 @@ void PrintVisitor::visit (const MatrixLineExp &e)
  ** \{ */
 void PrintVisitor::visit (const CellExp &e)
 {
-    std::list<MatrixLineExp *>::const_iterator i;
+    ast::exps_t::const_iterator        i, j;
+
     *ostr << SCI_OPEN_CELL;
     ++indent;
-    for (i = e.getLines().begin() ; i != e.getLines().end() ; )
+    ast::exps_t lines = e.getLines();
+    for (i = lines.begin() ; i != lines.end() ; )
     {
         (*i)->accept (*this);
         if (++i != e.getLines().end())
@@ -161,11 +165,11 @@ void PrintVisitor::visit (const DollarVar &/*e*/)
 
 void PrintVisitor::visit (const ArrayListVar &e)
 {
-    std::list<Var *>::const_iterator   i;
-    for (i = e.getVars().begin() ; i != e.getVars().end() ; )
+    exps_t vars = e.getVars();
+    for (exps_t::const_iterator it = vars.begin (), itEnd = vars.end(); it != itEnd; ++it)
     {
-        (*i)->accept (*this);
-        if (++i != e.getVars().end())
+        (*it)->accept (*this);
+        if (++it != e.getVars().end())
         {
             *ostr << ", ";
         }
@@ -350,12 +354,11 @@ void PrintVisitor::visit(const CellCallExp &e)
 {
     e.getName().accept (*this);
     *ostr << SCI_OPEN_CELL;
-    std::list<Exp *>::const_iterator   i;
-
-    for (i = e.getArgs().begin (); i != e.getArgs().end ();)
+    exps_t args = e.getArgs();
+    for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
     {
-        (*i)->accept (*this);
-        if (++i != e.getArgs().end ())
+        (*it)->accept (*this);
+        if (++it != e.getArgs().end ())
         {
             *ostr << SCI_COMMA << " ";
         }
@@ -369,10 +372,11 @@ void PrintVisitor::visit(const CallExp &e)
     *ostr << SCI_OPEN_CALL;
     std::list<Exp *>::const_iterator   i;
 
-    for (i = e.getArgs().begin(); i != e.getArgs().end();)
+    exps_t args = e.getArgs();
+    for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
     {
-        (*i)->accept (*this);
-        if (++i != e.getArgs().end())
+        (*it)->accept (*this);
+        if (++it != e.getArgs().end())
         {
             *ostr << SCI_COMMA << " ";
         }
@@ -471,12 +475,12 @@ void PrintVisitor::visit (const SelectExp &e)
     e.getSelect()->accept(*this);
     *ostr << SCI_CLOSE_TEST << std::endl;
     ++indent;
-    cases_t::const_iterator it;
-    for (it = e.getCases()->begin() ; it != e.getCases()->end() ; ++it)
+    exps_t* cases = e.getCases();
+    for (exps_t::iterator it = cases->begin(), itEnd = cases->end(); it !=  itEnd ; ++it)
     {
         (*it)->accept (*this);
     }
-    if (e.getDefaultCase() != NULL)
+    if (e.hasDefault())
     {
         this->apply_indent();
         *ostr << SCI_DEFAULT_CASE << std::endl;
@@ -503,12 +507,11 @@ void PrintVisitor::visit (const CaseExp &e)
 
 void PrintVisitor::visit (const SeqExp  &e)
 {
-    std::list<Exp *>::const_iterator   i;
-    for (i = e.getExps().begin (); i != e.getExps().end (); ++i)
+    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
     {
         this->apply_indent();
-        (*i)->accept (*this);
-        if (!(*i)->isVerbose())
+        (*it)->accept (*this);
+        if (!(*it)->isVerbose())
         {
             *ostr << ";";
         }
@@ -518,12 +521,11 @@ void PrintVisitor::visit (const SeqExp  &e)
 
 void PrintVisitor::visit (const ArrayListExp  &e)
 {
-    std::list<Exp *>::const_iterator   i;
     *ostr << SCI_LPAREN;
-    for (i = e.getExps().begin (); i != e.getExps().end ();)
+    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
     {
-        (*i)->accept (*this);
-        if (++i != e.getExps().end ())
+        (*it)->accept (*this);
+        if (++it != e.getExps().end ())
         {
             *ostr << SCI_COMMA << " ";
         }
@@ -533,12 +535,11 @@ void PrintVisitor::visit (const ArrayListExp  &e)
 
 void PrintVisitor::visit (const AssignListExp  &e)
 {
-    std::list<Exp *>::const_iterator   i;
     *ostr << SCI_LBRACK;
-    for (i = e.getExps().begin (); i != e.getExps().end ();)
+    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
     {
-        (*i)->accept (*this);
-        if (++i != e.getExps().end ())
+        (*it)->accept (*this);
+        if (++it != e.getExps().end ())
         {
             *ostr << SCI_COMMA << " ";
         }
@@ -588,20 +589,20 @@ void PrintVisitor::visit (const FunctionDec  &e)
     *ostr << SCI_FUNCTION << " ";
 
     // First ask if there are some return values.
-    if (e.getReturns().getVars().size() > 1)
+    if (e.getReturns().getAs<ArrayListVar>()->getVars().size() > 1)
     {
         *ostr << SCI_OPEN_RETURNS;
     }
 
-    visit(e.getReturns());
+    e.getReturns().accept(*this);
 
-    if (e.getReturns().getVars().size() > 1)
+    if (e.getReturns().getAs<ArrayListVar>()->getVars().size() > 1)
     {
         *ostr << SCI_CLOSE_RETURNS;
     }
 
     *ostr << " ";
-    if (e.getReturns().getVars().size() > 0)
+    if (e.getReturns().getAs<ArrayListVar>()->getVars().size() > 0)
     {
         *ostr << SCI_ASSIGN << " ";
     }
@@ -611,7 +612,7 @@ void PrintVisitor::visit (const FunctionDec  &e)
 
     // Then get function args
     *ostr << SCI_OPEN_ARGS;
-    visit(e.getArgs());
+    e.getArgs().accept(*this);
     *ostr << SCI_CLOSE_ARGS << std::endl;
 
     // Now print function body
@@ -642,7 +643,7 @@ void PrintVisitor::visit(const ListExp &e)
 }
 /** \} */
 
-void           PrintVisitor::apply_indent()
+void PrintVisitor::apply_indent()
 {
     int i;
     for (i = 0; i < indent; ++i)
@@ -651,12 +652,12 @@ void              PrintVisitor::apply_indent()
     }
 }
 
-void   PrintVisitor::enable_force_parenthesis()
+void PrintVisitor::enable_force_parenthesis()
 {
     force_parenthesis = true;
 }
 
-void   PrintVisitor::set_force_parenthesis(bool new_state)
+void PrintVisitor::set_force_parenthesis(bool new_state)
 {
     force_parenthesis = new_state;
 }
index 6b6e752..87b9257 100644 (file)
@@ -237,9 +237,9 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             return;
         }
 
-        AssignListExp *pList = dynamic_cast<AssignListExp*>(&e.getLeftExp());
-        if (pList)
+        if (e.getLeftExp().isAssignListExp())
         {
+            AssignListExp *pList = e.getLeftExp().getAs<AssignListExp>();
             //[x,y] = ?
             int iLhsCount = (int)pList->getExps().size();
 
@@ -256,9 +256,10 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 throw ast::ScilabError(os.str(), 999, e.getRightExp().getLocation());
             }
 
-            std::list<Exp *>::const_reverse_iterator it;
+            exps_t::const_reverse_iterator it;
             int i = (int)iLhsCount - 1;
-            for (it = pList->getExps().rbegin() ; it != pList->getExps().rend() ; it++, i--)
+            exps_t exps = pList->getExps();
+            for (it = exps.rbegin() ; it != exps.rend() ; it++, i--)
             {
                 //create a new AssignExp and run it
                 types::InternalType* pIT = exec.getResult(i);
index 87e86f6..94e62ac 100644 (file)
@@ -15,7 +15,7 @@
 template<class T>
 void RunVisitorT<T>::visitprivate(const CallExp &e)
 {
-    std::list<Exp *>::const_iterator itExp;
+    exps_t::const_iterator itExp;
 
     e.getName().accept(*this);
 
@@ -40,7 +40,8 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
         }
 
         //get function arguments
-        for (itExp = e.getArgs().begin (); itExp != e.getArgs().end (); ++itExp)
+        exps_t args = e.getArgs();
+        for (itExp = args.begin (); itExp != args.end (); ++itExp)
         {
             if ((*itExp)->isAssignExp())
             {
@@ -58,7 +59,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                     throw ast::ScilabError(os.str(), 999, e.getLocation());
                 }
 
-                SimpleVar* pVar = static_cast<SimpleVar*>(pL);
+                SimpleVar* pVar = pL->getAs<SimpleVar>();
                 Exp* pR = &pAssign->getRightExp();
                 pR->accept(*this);
                 InternalType* pITR = getResult();
index 2c84cd0..5497ca6 100644 (file)
@@ -20,22 +20,24 @@ void RunVisitorT<T>::visitprivate(const MatrixExp &e)
 {
     try
     {
-        std::list<MatrixLineExp *>::const_iterator row;
-        std::list<Exp *>::const_iterator col;
+        exps_t::const_iterator row;
+        exps_t::const_iterator col;
         InternalType *poResult = NULL;
         list<InternalType*> rowList;
 
-        if (e.getLines().size() == 0)
+        exps_t lines = e.getLines();
+        if (lines.size() == 0)
         {
             setResult(Double::Empty());
             return;
         }
 
         //do all [x,x]
-        for (row = e.getLines().begin() ; row != e.getLines().end() ; row++)
+        for (row = lines.begin() ; row != lines.end() ; row++)
         {
             InternalType* poRow = NULL;
-            for (col = (*row)->getColumns().begin() ; col != (*row)->getColumns().end() ; col++)
+            exps_t cols = (*row)->getAs<MatrixLineExp>()->getColumns();
+            for (col = cols.begin() ; col != cols.end() ; col++)
             {
                 setResult(NULL); // Reset value on loop re-start
                 (*col)->accept(*this);
index 4eac2d4..324bb16 100644 (file)
@@ -42,19 +42,21 @@ namespace ast
 template <class T>
 void RunVisitorT<T>::visitprivate(const CellExp &e)
 {
-    std::list<MatrixLineExp *>::const_iterator row;
-    std::list<Exp *>::const_iterator col;
+    exps_t::const_iterator row;
+    exps_t::const_iterator col;
     int iColMax = 0;
 
+    exps_t lines = e.getLines();
     //check dimmension
-    for (row = e.getLines().begin() ; row != e.getLines().end() ; ++row )
+    for (row = lines.begin() ; row != lines.end() ; ++row )
     {
+        exps_t cols = (*row)->getAs<MatrixLineExp>()->getColumns();
         if (iColMax == 0)
         {
-            iColMax = static_cast<int>((*row)->getColumns().size());
+            iColMax = static_cast<int>(cols.size());
         }
 
-        if (iColMax != static_cast<int>((*row)->getColumns().size()))
+        if (iColMax != static_cast<int>(cols.size()))
         {
             std::wostringstream os;
             os << _W("inconsistent row/column dimensions\n");
@@ -64,15 +66,16 @@ void RunVisitorT<T>::visitprivate(const CellExp &e)
     }
 
     //alloc result cell
-    types::Cell *pC = new types::Cell(static_cast<int>(e.getLines().size()), iColMax);
+    types::Cell *pC = new types::Cell(static_cast<int>(lines.size()), iColMax);
 
     int i = 0;
     int j = 0;
 
     //insert items in cell
-    for (i = 0, row = e.getLines().begin() ; row != e.getLines().end() ; ++row, ++i)
+    for (i = 0, row = lines.begin() ; row != lines.end() ; ++row, ++i)
     {
-        for (j = 0, col = (*row)->getColumns().begin() ; col != (*row)->getColumns().end() ; ++col, ++j)
+        exps_t cols = (*row)->getAs<MatrixLineExp>()->getColumns();
+        for (j = 0, col = cols.begin() ; col != cols.end() ; ++col, ++j)
         {
             (*col)->accept(*this);
             InternalType *pIT = getResult();
@@ -382,7 +385,7 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
         {
             //TODO : maybe it would be interesting here to reuse the same InternalType (to avoid delete/new)
             InternalType * pIL = pVar->extractValue(i);
-            symbol::Context::getInstance()->put(e.getVardec().getStack(), pIL);
+            symbol::Context::getInstance()->put(e.getVardec().getAs<VarDec>()->getStack(), pIL);
 
             e.getBody().accept(*this);
             if (e.getBody().isBreak())
@@ -411,7 +414,7 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
         for (int i = 0; i < size; ++i)
         {
             InternalType* pNew = pL->get(i);
-            symbol::Context::getInstance()->put(e.getVardec().getStack(), pNew);
+            symbol::Context::getInstance()->put(e.getVardec().getAs<VarDec>()->getStack(), pNew);
 
             e.getBody().accept(*this);
             if (e.getBody().isBreak())
@@ -447,7 +450,6 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
         for (int i = 0; i < pVar->getCols(); i++)
         {
             GenericType* pNew = pVar->getColumnValues(i);
-
             if (pNew == NULL)
             {
                 pIT->DecreaseRef();
@@ -455,7 +457,7 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
                 throw ScilabError(_W("for expression : Wrong type for loop iterator.\n"), 999, e.getVardec().getLocation());
             }
 
-            symbol::Context::getInstance()->put(e.getVardec().getStack(), pNew);
+            symbol::Context::getInstance()->put(e.getVardec().getAs<VarDec>()->getStack(), pNew);
 
             e.getBody().accept(*this);
             if (e.getBody().isBreak())
@@ -545,10 +547,11 @@ void RunVisitorT<T>::visitprivate(const SelectExp &e)
     if (pIT)
     {
         //find good case
-        cases_t::iterator it;
-        for (it = e.getCases()->begin(); it != e.getCases()->end() ; it++)
+        exps_t::iterator it;
+        exps_t* cases = e.getCases();
+        for (it = cases->begin(); it != cases->end() ; it++)
         {
-            CaseExp* pCase = *it;
+            CaseExp* pCase = (*it)->getAs<CaseExp>();
             pCase->getTest()->accept(*this);
             InternalType *pITCase = getResult();
             setResult(NULL);
@@ -655,9 +658,10 @@ template <class T>
 void RunVisitorT<T>::visitprivate(const SeqExp  &e)
 {
     //T execMe;
-    std::list<Exp *>::const_iterator        itExp;
+    exps_t::const_iterator itExp;
+    exps_t exps = e.getExps();
 
-    for (itExp = e.getExps().begin (); itExp != e.getExps().end (); ++itExp)
+    for (itExp = exps.begin (); itExp != exps.end (); ++itExp)
     {
         if (e.isBreakable())
         {
@@ -981,18 +985,20 @@ void RunVisitorT<T>::visitprivate(const FunctionDec & e)
     // funcprot(1) && warning(on) : warning
     //get input parameters list
     std::list<symbol::Variable*> *pVarList = new std::list<symbol::Variable*>();
-    const ArrayListVar *pListVar = &e.getArgs();
-    for (std::list<Var *>::const_iterator i = pListVar->getVars().begin(), end = pListVar->getVars().end(); i != end; ++i)
+    const ArrayListVar* pListVar = e.getArgs().getAs<ArrayListVar>();
+    exps_t vars = pListVar->getVars();
+    for (exps_t::const_iterator it = vars.begin(), end = vars.end(); it != end; ++it)
     {
-        pVarList->push_back(static_cast<SimpleVar*>(*i)->getStack());
+        pVarList->push_back((*it)->getAs<SimpleVar>()->getStack());
     }
 
     //get output parameters list
     std::list<symbol::Variable*> *pRetList = new std::list<symbol::Variable*>();
-    const ArrayListVar *pListRet = &e.getReturns();
-    for (std::list<Var *>::const_iterator i = pListRet->getVars().begin(), end = pListRet->getVars().end(); i != end; ++i)
+    const ArrayListVar *pListRet = e.getReturns().getAs<ArrayListVar>();
+    exps_t rets = pListRet->getVars();
+    for (exps_t::const_iterator it = rets.begin(), end = rets.end(); it != end; ++it)
     {
-        pRetList->push_back(static_cast<SimpleVar*>(*i)->getStack());
+        pRetList->push_back((*it)->getAs<SimpleVar>()->getStack());
     }
 
     types::Macro *pMacro = new types::Macro(e.getSymbol().getName(), *pVarList, *pRetList,
index ba43ec3..a5f6e27 100644 (file)
@@ -2109,14 +2109,13 @@ List* getPropertyTree(ast::Exp* e, List* pList)
     {
         pList = getPropertyTree(&pCall->getName(), pList);
         ast::ExecVisitor exec;
-        std::list<ast::Exp*> l = pCall->getArgs();
-        std::list<ast::Exp*>::const_iterator it;
-        for (it = l.begin() ; it != l.end() ; it++)
+        ast::exps_t l = pCall->getArgs();
+        ast::exps_t::const_iterator it;
+        for (ast::exps_t::const_iterator it = l.begin(), itEnd = l.end() ; it != itEnd ; ++it)
         {
-            ast::Exp* pArg = (*it);
             try
             {
-                pArg->accept(exec);
+                (*it)->accept(exec);
                 pList->append(exec.getResult());
                 exec.clearResult();
             }
index a770f86..6fe8005 100644 (file)
@@ -61,7 +61,7 @@
 
     LineBreakStr*               mute;
 
-    ast::vars_t*                t_list_var;
+    ast::exps_t*                t_list_var;
     ast::exps_t*                t_list_exp;
     ast::Exp*                   t_exp;
 
@@ -74,7 +74,7 @@
     ast::TryCatchExp*           t_try_exp;
     ast::SelectExp*             t_select_exp;
     ast::CaseExp*               t_case_exp;
-    ast::cases_t*               t_list_case;
+    ast::exps_t*                t_list_case;
 
     ast::CallExp*               t_call_exp;
 
@@ -92,8 +92,7 @@
 
     ast::MatrixExp*             t_matrix_exp;
     ast::MatrixLineExp*         t_matrixline_exp;
-    std::list<ast::MatrixLineExp *>*            \
-                                t_list_mline;
+    ast::exps_t*                t_list_mline;
 
     ast::CellExp*               t_cell_exp;
 
@@ -320,19 +319,19 @@ program:
 expressions                     { ParserSingleInstance::setTree($1); }
 | EOL expressions                              { ParserSingleInstance::setTree($2); }
 | expressionLineBreak           {
-                                  ast::exps_t *tmp = new ast::exps_t;
+                                  ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                      tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty body")));
+                                      tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty body"));
                                   #endif
-                                  ParserSingleInstance::setTree(new ast::SeqExp(@$, *tmp));
+                                  ParserSingleInstance::setTree(new ast::SeqExp(@$, tmp));
                                  delete $1;
                                 }
 | /* Epsilon */                 {
-                                  ast::exps_t *tmp = new ast::exps_t;
+                                  ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                      tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty body")));
+                                      tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty body"));
                                   #endif
-                                  ParserSingleInstance::setTree(new ast::SeqExp(@$, *tmp));
+                                  ParserSingleInstance::setTree(new ast::SeqExp(@$, tmp));
                                 }
 ;
 
@@ -356,17 +355,17 @@ recursiveExpression                             {
                                                   $$ = new ast::SeqExp(@$, *$1);
                                                 }
 | expression                                    {
-                                                  ast::exps_t *tmp = new ast::exps_t;
+                                                  ast::exps_t tmp;
                                                   $1->setVerbose(true);
-                                                  tmp->push_front($1);
-                                                  $$ = new ast::SeqExp(@$, *tmp);
+                                                  tmp[0] = $1;
+                                                  $$ = new ast::SeqExp(@$, tmp);
                                                 }
 | expression COMMENT                            {
-                                                  ast::exps_t *tmp = new ast::exps_t;
+                                                  ast::exps_t tmp;
                                                   $1->setVerbose(true);
-                                                  tmp->push_front(new ast::CommentExp(@2, $2));
-                                                  tmp->push_front($1);
-                                                  $$ = new ast::SeqExp(@$, *tmp);
+                                                  tmp[0] = $1;
+                                                  tmp[1] = new ast::CommentExp(@2, $2);
+                                                  $$ = new ast::SeqExp(@$, tmp);
                                                 }
 ;
 
@@ -394,18 +393,18 @@ recursiveExpression expression expressionLineBreak        {
                                                          delete $4;
                                                        }
 | expression COMMENT expressionLineBreak               {
-                                                         ast::exps_t *tmp = new ast::exps_t;
+                                                         ast::exps_t* tmp = new ast::exps_t();
                               @2.columns($3->iNbBreaker);
-                                                         tmp->push_front(new ast::CommentExp(@2, $2));
                                                          $1->setVerbose($3->bVerbose);
-                                                         tmp->push_front($1);
+                                                         tmp->push_back($1);
+                                                         tmp->push_back(new ast::CommentExp(@2, $2));
                                                          $$ = tmp;
                                                          delete $3;
                                                        }
 | expression expressionLineBreak                       {
-                                                         ast::exps_t *tmp = new ast::exps_t;
+                                                         ast::exps_t* tmp = new ast::exps_t();
                                                          $1->setVerbose($2->bVerbose);
-                                                         tmp->push_front($1);
+                                                         tmp->push_back($1);
                                                          $$ = tmp;
                               if ($2->iNbBreaker != 0)
                               {
@@ -466,9 +465,9 @@ implicitFunctionCall implicitCallable               {
                           $$ = $1;
                                                }
 | ID implicitCallable                          {
-                                                 ast::exps_t *tmp = new ast::exps_t;
-                                                 tmp->push_front($2);
-                                                 $$ = new ast::CallExp(@$, *new ast::SimpleVar(@1, *new symbol::Symbol(*$1)), *tmp);
+                                                 ast::exps_t tmp;
+                                                 tmp[0] = $2;
+                                                 $$ = new ast::CallExp(@$, *new ast::SimpleVar(@1, *new symbol::Symbol(*$1)), tmp);
                                                  delete $1;
                                                }
 ;
@@ -571,43 +570,43 @@ ID LPAREN functionArgs RPAREN                             { $$ = new ast::CallExp(@$, *new ast::SimpleVar
 functionArgs :
 variable                       {
                                  $$ = new ast::exps_t;
-                                 $$->push_front($1);
+                                 $$->push_back($1);
                                }
 | functionCall                 {
                                  $$ = new ast::exps_t;
-                                 $$->push_front($1);
+                                 $$->push_back($1);
                                }
 | COLON                                {
                                  $$ = new ast::exps_t;
-                                 $$->push_front(new ast::ColonVar(@1));
+                                 $$->push_back(new ast::ColonVar(@1));
                                }
 | variableDeclaration          {
                                  $$ = new ast::exps_t;
-                                 $$->push_front($1);
+                                 $$->push_back($1);
                                }
 | COMMA {
                   $$ = new ast::exps_t;
-                                 $$->push_front(new ast::NilExp(@1));
-                                 $$->push_front(new ast::NilExp(@1));
+                                 $$->push_back(new ast::NilExp(@1));
+                                 $$->push_back(new ast::NilExp(@1));
                   }
 | COMMA variable       {
                                  $$ = new ast::exps_t;
-                                 $$->push_front(new ast::NilExp(@1));
+                                 $$->push_back(new ast::NilExp(@1));
                   $$->push_back($2);
                                }
 | COMMA functionCall {
                                  $$ = new ast::exps_t;
-                                 $$->push_front(new ast::NilExp(@1));
+                                 $$->push_back(new ast::NilExp(@1));
                   $$->push_back($2);
                                }
 | COMMA COLON  {
                                  $$ = new ast::exps_t;
-                                 $$->push_front(new ast::NilExp(@1));
+                                 $$->push_back(new ast::NilExp(@1));
                   $$->push_back(new ast::ColonVar(@2));
                                }
 | COMMA variableDeclaration {
                                  $$ = new ast::exps_t;
-                                 $$->push_front(new ast::NilExp(@1));
+                                 $$->push_back(new ast::NilExp(@1));
                   $$->push_back($2);
                                }
 | functionArgs COMMA {
@@ -635,7 +634,7 @@ variable                    {
 //                               $$ = $1;
 //                             }
 //| COMMA functionArgs {
-//                  $2->push_front(new ast::NilExp(@1));
+//                  $2->insert($2->begin(), new ast::NilExp(@1));
 //                               $$ = $2;
 //                             }
 ;
@@ -646,12 +645,12 @@ variable                  {
 /* How to declare a function */
 functionDeclaration :
 FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar(@2, *new symbol::Symbol(*$2)));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$2));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$4),
                                                            *new ast::ArrayListVar(@5, *$5),
-                                                           *new ast::ArrayListVar(@2, *tmp),
+                                                           *new ast::ArrayListVar(@2, tmp),
                                                            *$7);
                                  delete $2;
                                  delete $4;
@@ -665,28 +664,30 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                  delete $6;
                                }
 | FUNCTION LBRACK RBRACK ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$5),
                                                            *new ast::ArrayListVar(@6, *$6),
-                                                           *new ast::ArrayListVar(@2, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@2, tmp),
                                                            *$8);
                                  delete $5;
                                }
 | FUNCTION ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$2),
                                                            *new ast::ArrayListVar(@3, *$3),
-                                                           *new ast::ArrayListVar(@$, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@$, tmp),
                                                            *$5);
                                  delete $2;
                                }
 | FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody END {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar(@2, *new symbol::Symbol(*$2)));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$2));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$4),
                                                            *new ast::ArrayListVar(@5, *$5),
-                                                           *new ast::ArrayListVar(@2, *tmp),
+                                                           *new ast::ArrayListVar(@2, tmp),
                                                            *$7);
                                  delete $2;
                                  delete $4;
@@ -700,28 +701,30 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                  delete $6;
                                }
 | FUNCTION LBRACK RBRACK ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody END {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$5),
                                                            *new ast::ArrayListVar(@6, *$6),
-                                                           *new ast::ArrayListVar(@2, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@2, tmp),
                                                            *$8);
                                  delete $5;
                                }
 | FUNCTION ID functionDeclarationArguments functionDeclarationBreak functionBody END {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$2),
                                                            *new ast::ArrayListVar(@3, *$3),
-                                                           *new ast::ArrayListVar(@$, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@$, tmp),
                                                            *$5);
                                  delete $2;
                                }
 | HIDDENFUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar(@2, *new symbol::Symbol(*$2)));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$2));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$4),
                                                            *new ast::ArrayListVar(@5, *$5),
-                                                           *new ast::ArrayListVar(@2, *tmp),
+                                                           *new ast::ArrayListVar(@2, tmp),
                                                            *$7);
                                  delete $2;
                                  delete $4;
@@ -735,28 +738,30 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                  delete $6;
                                }
 | HIDDENFUNCTION LBRACK RBRACK ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$5),
                                                            *new ast::ArrayListVar(@6, *$6),
-                                                           *new ast::ArrayListVar(@2, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@2, tmp),
                                                            *$8);
                                  delete $5;
                                }
 | HIDDENFUNCTION ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$2),
                                                            *new ast::ArrayListVar(@3, *$3),
-                                                           *new ast::ArrayListVar(@$, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@$, tmp),
                                                            *$5);
                                  delete $2;
                                }
 | HIDDENFUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody END {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar(@2, *new symbol::Symbol(*$2)));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$2));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$4),
                                                            *new ast::ArrayListVar(@5, *$5),
-                                                           *new ast::ArrayListVar(@2, *tmp),
+                                                           *new ast::ArrayListVar(@2, tmp),
                                                            *$7);
                                  delete $2;
                                  delete $4;
@@ -770,28 +775,30 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                  delete $6;
                                }
 | HIDDENFUNCTION LBRACK RBRACK ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody END {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$5),
                                                            *new ast::ArrayListVar(@6, *$6),
-                                                           *new ast::ArrayListVar(@2, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@2, tmp),
                                                            *$8);
                                  delete $5;
                                }
 | HIDDENFUNCTION ID functionDeclarationArguments functionDeclarationBreak functionBody END {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$2),
                                                            *new ast::ArrayListVar(@3, *$3),
-                                                           *new ast::ArrayListVar(@$, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@$, tmp),
                                                            *$5);
                                  delete $2;
                                }
 | HIDDEN FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar(@2, *new symbol::Symbol(*$3)));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$3));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$5),
                                                            *new ast::ArrayListVar(@6, *$6),
-                                                           *new ast::ArrayListVar(@3, *tmp),
+                                                           *new ast::ArrayListVar(@3, tmp),
                                                            *$8);
                                  delete $3;
                                  delete $5;
@@ -805,28 +812,30 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                  delete $7;
                                }
 | HIDDEN FUNCTION LBRACK RBRACK ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$6),
                                                            *new ast::ArrayListVar(@7, *$7),
-                                                           *new ast::ArrayListVar(@3, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@3, tmp),
                                                            *$9);
                                  delete $6;
                                }
 | HIDDEN FUNCTION ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$3),
                                                            *new ast::ArrayListVar(@4, *$4),
-                                                           *new ast::ArrayListVar(@$, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@$, tmp),
                                                            *$6);
                                  delete $3;
                                }
 | HIDDEN FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody END {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar(@3, *new symbol::Symbol(*$3)));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar(@3, *new symbol::Symbol(*$3));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$5),
                                                            *new ast::ArrayListVar(@6, *$6),
-                                                           *new ast::ArrayListVar(@2, *tmp),
+                                                           *new ast::ArrayListVar(@2, tmp),
                                                            *$8);
                                  delete $3;
                                  delete $5;
@@ -840,18 +849,20 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                  delete $7;
                                }
 | HIDDEN FUNCTION LBRACK RBRACK ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody END {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$6),
                                                            *new ast::ArrayListVar(@7, *$7),
-                                                           *new ast::ArrayListVar(@3, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@3, tmp),
                                                            *$9);
                                  delete $6;
                                }
 | HIDDEN FUNCTION ID functionDeclarationArguments functionDeclarationBreak functionBody END {
+                                 ast::exps_t tmp;
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$3),
                                                            *new ast::ArrayListVar(@4, *$4),
-                                                           *new ast::ArrayListVar(@$, *new ast::vars_t),
+                                                           *new ast::ArrayListVar(@$, tmp),
                                                            *$6);
                                  delete $3;
                                }
@@ -871,8 +882,8 @@ idList                              { $$ = $1; }
 /* Arguments passed to a function in it's declaration. */
 functionDeclarationArguments :
 LPAREN idList RPAREN           { $$ = $2; }
-| LPAREN RPAREN                        { $$ = new ast::vars_t; }
-| /* Epsilon */                        { $$ = new ast::vars_t; }
+| LPAREN RPAREN                        { $$ = new ast::exps_t();       }
+| /* Epsilon */                        { $$ = new ast::exps_t();       }
 ;
 
 /*
@@ -886,8 +897,8 @@ idList COMMA ID                     {
                                  $$ = $1;
                                }
 | ID                           {
-                                 $$ = new ast::vars_t;
-                                 $$->push_front(new ast::SimpleVar(@$, *new symbol::Symbol(*$1)));
+                                 $$ = new ast::exps_t;
+                                 $$->push_back(new ast::SimpleVar(@$, *new symbol::Symbol(*$1)));
                                  delete $1;
                                }
 ;
@@ -911,11 +922,11 @@ lineEnd                           { /* !! Do Nothing !! */ }
 functionBody :
 expressions                    { $$ = $1; }
 | /* Epsilon */                        {
-                                 ast::exps_t *tmp = new ast::exps_t;
+                                 ast::exps_t tmp;
                                  #ifdef BUILD_DEBUG_AST
-                                   tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty function body")));
+                                   tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty function body"));
                                  #endif
-                                 $$ = new ast::SeqExp(@$, *tmp);
+                                 $$ = new ast::SeqExp(@$, tmp);
                                }
 ;
 
@@ -1187,17 +1198,17 @@ LBRACE matrixOrCellLines RBRACE                                 { $$ = new ast::CellExp(@$, *$2); }
                                                                  $$ = new ast::CellExp(@$, *$3);
                                                                }
 | LBRACE matrixOrCellColumns RBRACE                                    {
-                                                                 std::list<ast::MatrixLineExp *> *tmp = new std::list<ast::MatrixLineExp *>;
-                                                                 tmp->push_front(new ast::MatrixLineExp(@2, *$2));
-                                                                 $$ = new ast::CellExp(@$, *tmp);
+                                                                 ast::exps_t tmp;
+                                                                 tmp[0] = new ast::MatrixLineExp(@2, *$2);
+                                                                 $$ = new ast::CellExp(@$, tmp);
                                                                }
 | LBRACE EOL matrixOrCellColumns RBRACE                                {
-                                                                 std::list<ast::MatrixLineExp *> *tmp = new std::list<ast::MatrixLineExp *>;
-                                                                 tmp->push_front(new ast::MatrixLineExp(@3, *$3));
-                                                                 $$ = new ast::CellExp(@$, *tmp);
+                                                                 ast::exps_t tmp;
+                                                                 tmp[0] = new ast::MatrixLineExp(@3, *$3);
+                                                                 $$ = new ast::CellExp(@$, tmp);
                                 }
-| LBRACE EOL RBRACE                                            { $$ = new ast::CellExp(@$, *new std::list<ast::MatrixLineExp *>); }
-| LBRACE RBRACE                                                        { $$ = new ast::CellExp(@$, *new std::list<ast::MatrixLineExp *>); }
+| LBRACE EOL RBRACE                                            { ast::exps_t tmp;$$ = new ast::CellExp(@$, tmp); }
+| LBRACE RBRACE                                                        { ast::exps_t tmp;$$ = new ast::CellExp(@$, tmp); }
 ;
 
 
@@ -1217,17 +1228,17 @@ LBRACK matrixOrCellLines RBRACK                                 { $$ = new ast::MatrixExp(@$, *$2); }
                                                                  $$ = new ast::MatrixExp(@$, *$3);
                                                                }
 | LBRACK matrixOrCellColumns RBRACK                                    {
-                                                                 std::list<ast::MatrixLineExp *> *tmp = new std::list<ast::MatrixLineExp *>;
-                                                                 tmp->push_front(new ast::MatrixLineExp(@2, *$2));
-                                                                 $$ = new ast::MatrixExp(@$, *tmp);
+                                                                 ast::exps_t tmp;
+                                                                 tmp[0] = new ast::MatrixLineExp(@2, *$2);
+                                                                 $$ = new ast::MatrixExp(@$, tmp);
                                                                }
 | LBRACK EOL matrixOrCellColumns RBRACK                                {
-                                                                 std::list<ast::MatrixLineExp *> *tmp = new std::list<ast::MatrixLineExp *>;
-                                                                 tmp->push_front(new ast::MatrixLineExp(@3, *$3));
-                                                                 $$ = new ast::MatrixExp(@$, *tmp);
+                                                                 ast::exps_t tmp;
+                                                                 tmp[0] = new ast::MatrixLineExp(@3, *$3);
+                                                                 $$ = new ast::MatrixExp(@$, tmp);
                                                                }
-| LBRACK EOL RBRACK                                            { $$ = new ast::MatrixExp(@$, *new std::list<ast::MatrixLineExp *>); }
-| LBRACK RBRACK                                                        { $$ = new ast::MatrixExp(@$, *new std::list<ast::MatrixLineExp *>); }
+| LBRACK EOL RBRACK                                            { ast::exps_t tmp;$$ = new ast::MatrixExp(@$, tmp); }
+| LBRACK RBRACK                                                        { ast::exps_t tmp;$$ = new ast::MatrixExp(@$, tmp); }
 ;
 
 /*
@@ -1240,8 +1251,8 @@ matrixOrCellLines matrixOrCellLine        {
                                          $$ = $1;
                                        }
 | matrixOrCellLine                     {
-                                         $$ = new std::list<ast::MatrixLineExp *>;
-                                         $$->push_front($1);
+                                         $$ = new ast::exps_t;
+                                         $$->push_back($1);
                                        }
 //| matrixOrCellLines lineEnd {}
 //| COMMENT EOL {}
@@ -1294,15 +1305,15 @@ matrixOrCellColumns matrixOrCellColumnsBreak variable       %prec HIGHLEVEL {
                                                                             }
 | variable                                                  %prec HIGHLEVEL {
                                                                                 $$ = new ast::exps_t;
-                                                                                $$->push_front($1);
+                                                                                $$->push_back($1);
                                                                             }
 | functionCall                                              %prec HIGHLEVEL {
                                                                                 $$ = new ast::exps_t;
-                                                                                $$->push_front($1);
+                                                                                $$->push_back($1);
                                                                             }
 | COMMENT                                                                   {
                                                                                 $$ = new ast::exps_t;
-                                                                                $$->push_front(new ast::CommentExp(@$, $1));
+                                                                                $$->push_back(new ast::CommentExp(@$, $1));
                                                                             }
 ;
 
@@ -1392,11 +1403,11 @@ IF condition then thenBody END                          { $$ = new ast::IfExp(@$
 thenBody :
 expressions                             { $$ = $1; }
 | /* Epsilon */                         {
-    ast::exps_t *tmp = new ast::exps_t;
+    ast::exps_t tmp;
     #ifdef BUILD_DEBUG_AST
-    tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty then body")));
+    tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty then body"));
     #endif
-    $$ = new ast::SeqExp(@$, *tmp);
+    $$ = new ast::SeqExp(@$, tmp);
                                         }
 ;
 
@@ -1408,9 +1419,9 @@ elseBody :
 expressions                             { $$ = $1; }
 | /* Epsilon */                         {
                                          #ifdef BUILD_DEBUG_AST
-                                           ast::exps_t *tmp = new ast::exps_t;
-                                           tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty else body")));
-                                           $$ = new ast::SeqExp(@$, *tmp);
+                                           ast::exps_t tmp;
+                                           tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty else body"));
+                                           $$ = new ast::SeqExp(@$, tmp);
                                          #else
                                            $$ = NULL;
                                          #endif
@@ -1461,27 +1472,27 @@ ELSE                                                    { /* !! Do Nothing !! */ }
 /* else if ... then ... */
 elseIfControl :
 ELSEIF condition then thenBody                                         {
-                                                                               ast::exps_t *tmp = new ast::exps_t;
-                                                                               tmp->push_front( new ast::IfExp(@$, *$2, *$4) );
-                                                                               $$ = new ast::SeqExp(@$, *tmp);
+                                                                               ast::exps_t tmp;
+                                                                               tmp[0] = new ast::IfExp(@$, *$2, *$4);
+                                                                               $$ = new ast::SeqExp(@$, tmp);
                                                                        }
 | ELSEIF condition then thenBody else elseBody                         {
-                                                                               ast::exps_t *tmp = new ast::exps_t;
+                                                                               ast::exps_t tmp;
                                                                                if( $6 == NULL)
                                         {
-                                            tmp->push_front( new ast::IfExp(@$, *$2, *$4) );
+                                            tmp[0] = new ast::IfExp(@$, *$2, *$4);
                                         }
                                         else
                                         {
-                                            tmp->push_front( new ast::IfExp(@$, *$2, *$4, *$6) );
+                                            tmp[0] = new ast::IfExp(@$, *$2, *$4, *$6);
                                         }
-                                                                               $$ = new ast::SeqExp(@$, *tmp);
+                                                                               $$ = new ast::SeqExp(@$, tmp);
 
                                                                        }
 | ELSEIF condition then thenBody elseIfControl                         {
-                                                                               ast::exps_t *tmp = new ast::exps_t;
-                                                                               tmp->push_front( new ast::IfExp(@$, *$2, *$4, *$5) );
-                                                                               $$ = new ast::SeqExp(@$, *tmp);
+                                                                               ast::exps_t tmp;
+                                                                               tmp[0] = new ast::IfExp(@$, *$2, *$4, *$5);
+                                                                               $$ = new ast::SeqExp(@$, tmp);
                                                                        }
 ;
 
@@ -1549,19 +1560,19 @@ EOL                                                             { /* !! Do Nothing !! */ }
 /* (Case ... Then ...)+ control block */
 casesControl :
 CASE variable caseControlBreak caseBody                                                        {
-                                                                                                                                 $$ = new ast::cases_t;
+                                                                                                                                 $$ = new ast::exps_t;
                                                                                                                                  $$->push_back(new ast::CaseExp(@$, *$2, *$4));
                                                                                                                                }
 | CASE functionCall caseControlBreak caseBody                                  {
-                                                                                                                                 $$ = new ast::cases_t;
+                                                                                                                                 $$ = new ast::exps_t;
                                                                                                                                  $$->push_back(new ast::CaseExp(@$, *$2, *$4));
                                                                                                                                }
 | comments CASE variable caseControlBreak caseBody                             {
-                                                                                                                                 $$ = new ast::cases_t;
+                                                                                                                                 $$ = new ast::exps_t;
                                                                                                                                  $$->push_back(new ast::CaseExp(@$, *$3, *$5));
                                                                                                                                }
 | comments CASE functionCall caseControlBreak caseBody          {
-                                                                                                                                 $$ = new ast::cases_t;
+                                                                                                                                 $$ = new ast::exps_t;
                                                                                                                                  $$->push_back(new ast::CaseExp(@$, *$3, *$5));
                                                                                                                                }
 | casesControl CASE variable caseControlBreak caseBody                 {
@@ -1577,11 +1588,11 @@ CASE variable caseControlBreak caseBody                                                 {
 caseBody :
 expressions                            { $$ = $1; }
 | /* Epsilon */                        {
-                                                 ast::exps_t *tmp = new ast::exps_t;
+                                                 ast::exps_t tmp;
                                                #ifdef BUILD_DEBUG_AST
-                                                 tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty case body")));
+                                                 tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty case body"));
                                                #endif
-                                                 $$ = new ast::SeqExp(@$, *tmp);
+                                                 $$ = new ast::SeqExp(@$, tmp);
                                                }
 ;
 
@@ -1641,11 +1652,11 @@ EOL                                             { /* !! Do Nothing !! */ }
 forBody :
 expressions                    { $$ = $1; }
 | /* Epsilon */                        {
-                                 ast::exps_t *tmp = new ast::exps_t;
+                                 ast::exps_t tmp;
                                  #ifdef BUILD_DEBUG_AST
-                                   tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty for body")));
+                                   tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty for body"));
                                  #endif
-                                 $$ = new ast::SeqExp(@$, *tmp);
+                                 $$ = new ast::SeqExp(@$, tmp);
                                }
 ;
 
@@ -1664,11 +1675,11 @@ WHILE condition whileConditionBreak whileBody END       { $$ = new ast::WhileExp(@$, *
 whileBody :
 expressions             { $$ = $1; }
 | /* Epsilon */                        {
-                          ast::exps_t *tmp = new ast::exps_t;
+                          ast::exps_t tmp;
                           #ifdef BUILD_DEBUG_AST
-                            tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty while body")));
+                            tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty while body"));
                           #endif
-                          $$ = new ast::SeqExp(@$, *tmp);
+                          $$ = new ast::SeqExp(@$, tmp);
                         }
 ;
 
@@ -1704,11 +1715,11 @@ COMMA                   { /* !! Do Nothing !! */ }
 tryControl :
 TRY catchBody CATCH catchBody END                 { $$ =new ast::TryCatchExp(@$, *$2, *$4); }
 | TRY catchBody END                               {
-                                                    ast::exps_t *tmp = new ast::exps_t;
+                                                    ast::exps_t tmp;
                                                     #ifdef BUILD_DEBUG_AST
-                                                      tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty catch body")));
+                                                      tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty catch body"));
                                                     #endif
-                                                    $$ =new ast::TryCatchExp(@$, *$2, *new ast::SeqExp(@$, *tmp));
+                                                    $$ =new ast::TryCatchExp(@$, *$2, *new ast::SeqExp(@$, tmp));
                                                   }
 ;
 
@@ -1722,18 +1733,18 @@ expressions                     { $$ = $1; }
 | SEMI expressions             { $$ = $2; }
 | COMMA expressions             { $$ = $2; }
 | EOL                           {
-                                  ast::exps_t *tmp = new ast::exps_t;
+                                  ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                    tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty catch body")));
+                                    tmp = new ast::CommentExp(@$, new std::wstring(L"Empty catch body"));
                                   #endif
-                                  $$ = new ast::SeqExp(@$, *tmp);
+                                  $$ = new ast::SeqExp(@$, tmp);
                                 }
 | /* Epsilon */                 {
-                                  ast::exps_t *tmp = new ast::exps_t;
+                                  ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                    tmp->push_front(new ast::CommentExp(@$, new std::wstring(L"Empty catch body")));
+                                    tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty catch body"));
                                   #endif
-                                  $$ = new ast::SeqExp(@$, *tmp);
+                                  $$ = new ast::SeqExp(@$, tmp);
                                 }
 ;
 
index 2f34fcf..0c15e78 100644 (file)
@@ -327,7 +327,7 @@ union YYSTYPE
 
     LineBreakStr*               mute;
 
-    ast::vars_t*                t_list_var;
+    ast::exps_t*                t_list_var;
     ast::exps_t*                t_list_exp;
     ast::Exp*                   t_exp;
 
@@ -340,7 +340,7 @@ union YYSTYPE
     ast::TryCatchExp*           t_try_exp;
     ast::SelectExp*             t_select_exp;
     ast::CaseExp*               t_case_exp;
-    ast::cases_t*               t_list_case;
+    ast::exps_t*                t_list_case;
 
     ast::CallExp*               t_call_exp;
 
@@ -358,8 +358,7 @@ union YYSTYPE
 
     ast::MatrixExp*             t_matrix_exp;
     ast::MatrixLineExp*         t_matrixline_exp;
-    std::list<ast::MatrixLineExp *>*            \
-                                t_list_mline;
+    ast::exps_t*                t_list_mline;
 
     ast::CellExp*               t_cell_exp;
 
@@ -709,48 +708,48 @@ static const yytype_uint8 yytranslate[] =
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   320,   320,   321,   322,   330,   344,   347,   352,   358,
-     364,   378,   388,   396,   405,   423,   424,   425,   426,   427,
-     428,   436,   437,   438,   439,   440,   441,   442,   443,   444,
-     445,   446,   447,   448,   449,   450,   463,   468,   484,   485,
-     490,   495,   500,   501,   502,   503,   504,   510,   511,   512,
-     513,   521,   522,   524,   532,   533,   534,   535,   546,   547,
-     548,   549,   572,   576,   580,   584,   588,   593,   598,   603,
-     608,   613,   617,   621,   625,   629,   648,   659,   667,   675,
-     683,   694,   702,   710,   718,   729,   737,   745,   753,   764,
-     772,   780,   788,   799,   807,   815,   823,   834,   842,   850,
-     865,   873,   874,   875,   883,   888,   900,   901,   902,   903,
-     904,   912,   913,   927,   928,   936,   941,   954,   955,   956,
-     958,   959,   960,   962,   963,   964,   966,   967,   968,   970,
-     971,   972,   974,   975,   976,   978,   979,   980,   982,   983,
-     984,   986,   987,   988,   990,   991,   992,  1000,  1006,  1012,
-    1013,  1014,  1015,  1016,  1017,  1018,  1019,  1020,  1021,  1022,
-    1023,  1024,  1025,  1026,  1027,  1036,  1037,  1039,  1040,  1042,
-    1043,  1044,  1045,  1046,  1047,  1048,  1049,  1051,  1052,  1053,
-    1054,  1055,  1056,  1057,  1058,  1060,  1061,  1062,  1063,  1064,
-    1065,  1066,  1067,  1075,  1076,  1084,  1085,  1086,  1094,  1095,
-    1096,  1097,  1098,  1103,  1104,  1105,  1110,  1114,  1118,  1119,
-    1120,  1121,  1122,  1123,  1124,  1125,  1126,  1127,  1128,  1129,
-    1130,  1131,  1132,  1133,  1141,  1145,  1149,  1155,  1161,  1167,
-    1179,  1180,  1181,  1185,  1189,  1194,  1199,  1200,  1209,  1210,
-    1211,  1215,  1219,  1224,  1229,  1230,  1238,  1242,  1255,  1256,
-    1257,  1258,  1266,  1267,  1275,  1279,  1283,  1287,  1291,  1295,
-    1299,  1303,  1314,  1315,  1323,  1324,  1325,  1326,  1328,  1329,
-    1331,  1332,  1341,  1342,  1343,  1348,  1349,  1350,  1355,  1356,
-    1357,  1358,  1365,  1374,  1375,  1385,  1393,  1394,  1408,  1409,
-    1425,  1426,  1427,  1428,  1429,  1437,  1438,  1439,  1440,  1441,
-    1442,  1450,  1451,  1452,  1453,  1454,  1455,  1463,  1468,  1481,
-    1496,  1497,  1498,  1499,  1507,  1508,  1516,  1517,  1518,  1519,
-    1520,  1521,  1522,  1530,  1531,  1539,  1540,  1541,  1542,  1543,
-    1551,  1555,  1559,  1563,  1567,  1571,  1578,  1579,  1593,  1594,
-    1595,  1596,  1597,  1598,  1599,  1600,  1601,  1602,  1603,  1604,
-    1612,  1613,  1621,  1622,  1631,  1632,  1633,  1634,  1635,  1636,
-    1637,  1638,  1642,  1643,  1657,  1665,  1666,  1680,  1681,  1682,
-    1683,  1684,  1685,  1686,  1687,  1688,  1689,  1690,  1691,  1692,
-    1693,  1694,  1695,  1696,  1697,  1705,  1706,  1720,  1721,  1722,
-    1723,  1724,  1731,  1745,  1746,  1747,  1754,  1755,  1763,  1764,
-    1772,  1773,  1774,  1775,  1776,  1777,  1778,  1779,  1780,  1781,
-    1782,  1783,  1784,  1785,  1786,  1787,  1788,  1789,  1790,  1791
+       0,   319,   319,   320,   321,   329,   343,   346,   351,   357,
+     363,   377,   387,   395,   404,   422,   423,   424,   425,   426,
+     427,   435,   436,   437,   438,   439,   440,   441,   442,   443,
+     444,   445,   446,   447,   448,   449,   462,   467,   483,   484,
+     489,   494,   499,   500,   501,   502,   503,   509,   510,   511,
+     512,   520,   521,   523,   531,   532,   533,   534,   545,   546,
+     547,   548,   571,   575,   579,   583,   587,   592,   597,   602,
+     607,   612,   616,   620,   624,   628,   647,   658,   666,   675,
+     684,   695,   703,   712,   721,   732,   740,   749,   758,   769,
+     777,   786,   795,   806,   814,   823,   832,   843,   851,   860,
+     876,   884,   885,   886,   894,   899,   911,   912,   913,   914,
+     915,   923,   924,   938,   939,   947,   952,   965,   966,   967,
+     969,   970,   971,   973,   974,   975,   977,   978,   979,   981,
+     982,   983,   985,   986,   987,   989,   990,   991,   993,   994,
+     995,   997,   998,   999,  1001,  1002,  1003,  1011,  1017,  1023,
+    1024,  1025,  1026,  1027,  1028,  1029,  1030,  1031,  1032,  1033,
+    1034,  1035,  1036,  1037,  1038,  1047,  1048,  1050,  1051,  1053,
+    1054,  1055,  1056,  1057,  1058,  1059,  1060,  1062,  1063,  1064,
+    1065,  1066,  1067,  1068,  1069,  1071,  1072,  1073,  1074,  1075,
+    1076,  1077,  1078,  1086,  1087,  1095,  1096,  1097,  1105,  1106,
+    1107,  1108,  1109,  1114,  1115,  1116,  1121,  1125,  1129,  1130,
+    1131,  1132,  1133,  1134,  1135,  1136,  1137,  1138,  1139,  1140,
+    1141,  1142,  1143,  1144,  1152,  1156,  1160,  1166,  1172,  1178,
+    1190,  1191,  1192,  1196,  1200,  1205,  1210,  1211,  1220,  1221,
+    1222,  1226,  1230,  1235,  1240,  1241,  1249,  1253,  1266,  1267,
+    1268,  1269,  1277,  1278,  1286,  1290,  1294,  1298,  1302,  1306,
+    1310,  1314,  1325,  1326,  1334,  1335,  1336,  1337,  1339,  1340,
+    1342,  1343,  1352,  1353,  1354,  1359,  1360,  1361,  1366,  1367,
+    1368,  1369,  1376,  1385,  1386,  1396,  1404,  1405,  1419,  1420,
+    1436,  1437,  1438,  1439,  1440,  1448,  1449,  1450,  1451,  1452,
+    1453,  1461,  1462,  1463,  1464,  1465,  1466,  1474,  1479,  1492,
+    1507,  1508,  1509,  1510,  1518,  1519,  1527,  1528,  1529,  1530,
+    1531,  1532,  1533,  1541,  1542,  1550,  1551,  1552,  1553,  1554,
+    1562,  1566,  1570,  1574,  1578,  1582,  1589,  1590,  1604,  1605,
+    1606,  1607,  1608,  1609,  1610,  1611,  1612,  1613,  1614,  1615,
+    1623,  1624,  1632,  1633,  1642,  1643,  1644,  1645,  1646,  1647,
+    1648,  1649,  1653,  1654,  1668,  1676,  1677,  1691,  1692,  1693,
+    1694,  1695,  1696,  1697,  1698,  1699,  1700,  1701,  1702,  1703,
+    1704,  1705,  1706,  1707,  1708,  1716,  1717,  1731,  1732,  1733,
+    1734,  1735,  1742,  1756,  1757,  1758,  1765,  1766,  1774,  1775,
+    1783,  1784,  1785,  1786,  1787,  1788,  1789,  1790,  1791,  1792,
+    1793,  1794,  1795,  1796,  1797,  1798,  1799,  1800,  1801,  1802
 };
 #endif
 
@@ -2703,11 +2702,11 @@ yyreduce:
   case 4:
 
     {
-                                  ast::exps_t *tmp = new ast::exps_t;
+                                  ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                      tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty body")));
+                                      tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty body"));
                                   #endif
-                                  ParserSingleInstance::setTree(new ast::SeqExp((yyloc), *tmp));
+                                  ParserSingleInstance::setTree(new ast::SeqExp((yyloc), tmp));
                                  delete (yyvsp[0].mute);
                                 }
 
@@ -2716,11 +2715,11 @@ yyreduce:
   case 5:
 
     {
-                                  ast::exps_t *tmp = new ast::exps_t;
+                                  ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                      tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty body")));
+                                      tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty body"));
                                   #endif
-                                  ParserSingleInstance::setTree(new ast::SeqExp((yyloc), *tmp));
+                                  ParserSingleInstance::setTree(new ast::SeqExp((yyloc), tmp));
                                 }
 
     break;
@@ -2757,10 +2756,10 @@ yyreduce:
   case 9:
 
     {
-                                                  ast::exps_t *tmp = new ast::exps_t;
+                                                  ast::exps_t tmp;
                                                   (yyvsp[0].t_exp)->setVerbose(true);
-                                                  tmp->push_front((yyvsp[0].t_exp));
-                                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                                  tmp[0] = (yyvsp[0].t_exp);
+                                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                                 }
 
     break;
@@ -2768,11 +2767,11 @@ yyreduce:
   case 10:
 
     {
-                                                  ast::exps_t *tmp = new ast::exps_t;
+                                                  ast::exps_t tmp;
                                                   (yyvsp[-1].t_exp)->setVerbose(true);
-                                                  tmp->push_front(new ast::CommentExp((yylsp[0]), (yyvsp[0].comment)));
-                                                  tmp->push_front((yyvsp[-1].t_exp));
-                                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                                  tmp[0] = (yyvsp[-1].t_exp);
+                                                  tmp[1] = new ast::CommentExp((yylsp[0]), (yyvsp[0].comment));
+                                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                                 }
 
     break;
@@ -2808,11 +2807,11 @@ yyreduce:
   case 13:
 
     {
-                                                         ast::exps_t *tmp = new ast::exps_t;
+                                                         ast::exps_t* tmp = new ast::exps_t();
                               (yylsp[-1]).columns((yyvsp[0].mute)->iNbBreaker);
-                                                         tmp->push_front(new ast::CommentExp((yylsp[-1]), (yyvsp[-1].comment)));
                                                          (yyvsp[-2].t_exp)->setVerbose((yyvsp[0].mute)->bVerbose);
-                                                         tmp->push_front((yyvsp[-2].t_exp));
+                                                         tmp->push_back((yyvsp[-2].t_exp));
+                                                         tmp->push_back(new ast::CommentExp((yylsp[-1]), (yyvsp[-1].comment)));
                                                          (yyval.t_list_exp) = tmp;
                                                          delete (yyvsp[0].mute);
                                                        }
@@ -2822,9 +2821,9 @@ yyreduce:
   case 14:
 
     {
-                                                         ast::exps_t *tmp = new ast::exps_t;
+                                                         ast::exps_t* tmp = new ast::exps_t();
                                                          (yyvsp[-1].t_exp)->setVerbose((yyvsp[0].mute)->bVerbose);
-                                                         tmp->push_front((yyvsp[-1].t_exp));
+                                                         tmp->push_back((yyvsp[-1].t_exp));
                                                          (yyval.t_list_exp) = tmp;
                               if ((yyvsp[0].mute)->iNbBreaker != 0)
                               {
@@ -2977,9 +2976,9 @@ yyreduce:
   case 37:
 
     {
-                                                 ast::exps_t *tmp = new ast::exps_t;
-                                                 tmp->push_front((yyvsp[0].t_string_exp));
-                                                 (yyval.t_call_exp) = new ast::CallExp((yyloc), *new ast::SimpleVar((yylsp[-1]), *new symbol::Symbol(*(yyvsp[-1].str))), *tmp);
+                                                 ast::exps_t tmp;
+                                                 tmp[0] = (yyvsp[0].t_string_exp);
+                                                 (yyval.t_call_exp) = new ast::CallExp((yyloc), *new ast::SimpleVar((yylsp[-1]), *new symbol::Symbol(*(yyvsp[-1].str))), tmp);
                                                  delete (yyvsp[-1].str);
                                                }
 
@@ -3150,7 +3149,7 @@ yyreduce:
 
     {
                                  (yyval.t_list_exp) = new ast::exps_t;
-                                 (yyval.t_list_exp)->push_front((yyvsp[0].t_exp));
+                                 (yyval.t_list_exp)->push_back((yyvsp[0].t_exp));
                                }
 
     break;
@@ -3159,7 +3158,7 @@ yyreduce:
 
     {
                                  (yyval.t_list_exp) = new ast::exps_t;
-                                 (yyval.t_list_exp)->push_front((yyvsp[0].t_call_exp));
+                                 (yyval.t_list_exp)->push_back((yyvsp[0].t_call_exp));
                                }
 
     break;
@@ -3168,7 +3167,7 @@ yyreduce:
 
     {
                                  (yyval.t_list_exp) = new ast::exps_t;
-                                 (yyval.t_list_exp)->push_front(new ast::ColonVar((yylsp[0])));
+                                 (yyval.t_list_exp)->push_back(new ast::ColonVar((yylsp[0])));
                                }
 
     break;
@@ -3177,7 +3176,7 @@ yyreduce:
 
     {
                                  (yyval.t_list_exp) = new ast::exps_t;
-                                 (yyval.t_list_exp)->push_front((yyvsp[0].t_assign_exp));
+                                 (yyval.t_list_exp)->push_back((yyvsp[0].t_assign_exp));
                                }
 
     break;
@@ -3186,8 +3185,8 @@ yyreduce:
 
     {
                   (yyval.t_list_exp) = new ast::exps_t;
-                                 (yyval.t_list_exp)->push_front(new ast::NilExp((yylsp[0])));
-                                 (yyval.t_list_exp)->push_front(new ast::NilExp((yylsp[0])));
+                                 (yyval.t_list_exp)->push_back(new ast::NilExp((yylsp[0])));
+                                 (yyval.t_list_exp)->push_back(new ast::NilExp((yylsp[0])));
                   }
 
     break;
@@ -3196,7 +3195,7 @@ yyreduce:
 
     {
                                  (yyval.t_list_exp) = new ast::exps_t;
-                                 (yyval.t_list_exp)->push_front(new ast::NilExp((yylsp[-1])));
+                                 (yyval.t_list_exp)->push_back(new ast::NilExp((yylsp[-1])));
                   (yyval.t_list_exp)->push_back((yyvsp[0].t_exp));
                                }
 
@@ -3206,7 +3205,7 @@ yyreduce:
 
     {
                                  (yyval.t_list_exp) = new ast::exps_t;
-                                 (yyval.t_list_exp)->push_front(new ast::NilExp((yylsp[-1])));
+                                 (yyval.t_list_exp)->push_back(new ast::NilExp((yylsp[-1])));
                   (yyval.t_list_exp)->push_back((yyvsp[0].t_call_exp));
                                }
 
@@ -3216,7 +3215,7 @@ yyreduce:
 
     {
                                  (yyval.t_list_exp) = new ast::exps_t;
-                                 (yyval.t_list_exp)->push_front(new ast::NilExp((yylsp[-1])));
+                                 (yyval.t_list_exp)->push_back(new ast::NilExp((yylsp[-1])));
                   (yyval.t_list_exp)->push_back(new ast::ColonVar((yylsp[0])));
                                }
 
@@ -3226,7 +3225,7 @@ yyreduce:
 
     {
                                  (yyval.t_list_exp) = new ast::exps_t;
-                                 (yyval.t_list_exp)->push_front(new ast::NilExp((yylsp[-1])));
+                                 (yyval.t_list_exp)->push_back(new ast::NilExp((yylsp[-1])));
                   (yyval.t_list_exp)->push_back((yyvsp[0].t_assign_exp));
                                }
 
@@ -3280,12 +3279,12 @@ yyreduce:
   case 76:
 
     {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str))));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-6]), *tmp),
+                                                           *new ast::ArrayListVar((yylsp[-6]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-6].str);
                                  delete (yyvsp[-4].str);
@@ -3309,10 +3308,11 @@ yyreduce:
   case 78:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-7]), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yylsp[-7]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3322,10 +3322,11 @@ yyreduce:
   case 79:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yyloc), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yyloc), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3335,12 +3336,12 @@ yyreduce:
   case 80:
 
     {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str))));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-6]), *tmp),
+                                                           *new ast::ArrayListVar((yylsp[-6]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-6].str);
                                  delete (yyvsp[-4].str);
@@ -3364,10 +3365,11 @@ yyreduce:
   case 82:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-7]), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yylsp[-7]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3377,10 +3379,11 @@ yyreduce:
   case 83:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yyloc), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yyloc), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3390,12 +3393,12 @@ yyreduce:
   case 84:
 
     {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str))));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-6]), *tmp),
+                                                           *new ast::ArrayListVar((yylsp[-6]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-6].str);
                                  delete (yyvsp[-4].str);
@@ -3419,10 +3422,11 @@ yyreduce:
   case 86:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-7]), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yylsp[-7]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3432,10 +3436,11 @@ yyreduce:
   case 87:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yyloc), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yyloc), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3445,12 +3450,12 @@ yyreduce:
   case 88:
 
     {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str))));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-6]), *tmp),
+                                                           *new ast::ArrayListVar((yylsp[-6]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-6].str);
                                  delete (yyvsp[-4].str);
@@ -3474,10 +3479,11 @@ yyreduce:
   case 90:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-7]), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yylsp[-7]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3487,10 +3493,11 @@ yyreduce:
   case 91:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yyloc), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yyloc), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3500,12 +3507,12 @@ yyreduce:
   case 92:
 
     {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar((yylsp[-7]), *new symbol::Symbol(*(yyvsp[-6].str))));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar((yylsp[-7]), *new symbol::Symbol(*(yyvsp[-6].str)));
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-6]), *tmp),
+                                                           *new ast::ArrayListVar((yylsp[-6]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-6].str);
                                  delete (yyvsp[-4].str);
@@ -3529,10 +3536,11 @@ yyreduce:
   case 94:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-7]), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yylsp[-7]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3542,10 +3550,11 @@ yyreduce:
   case 95:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yyloc), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yyloc), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3555,12 +3564,12 @@ yyreduce:
   case 96:
 
     {
-                                 ast::vars_t *tmp = new ast::vars_t;
-                                 tmp->push_front(new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str))));
+                                 ast::exps_t tmp;
+                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-7]), *tmp),
+                                                           *new ast::ArrayListVar((yylsp[-7]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-6].str);
                                  delete (yyvsp[-4].str);
@@ -3584,10 +3593,11 @@ yyreduce:
   case 98:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yylsp[-7]), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yylsp[-7]), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3597,10 +3607,11 @@ yyreduce:
   case 99:
 
     {
+                                 ast::exps_t tmp;
                                  (yyval.t_function_dec) = new ast::FunctionDec((yyloc),
                                                            *new symbol::Symbol(*(yyvsp[-4].str)),
                                                            *new ast::ArrayListVar((yylsp[-3]), *(yyvsp[-3].t_list_var)),
-                                                           *new ast::ArrayListVar((yyloc), *new ast::vars_t),
+                                                           *new ast::ArrayListVar((yyloc), tmp),
                                                            *(yyvsp[-1].t_seq_exp));
                                  delete (yyvsp[-4].str);
                                }
@@ -3621,13 +3632,13 @@ yyreduce:
 
   case 102:
 
-    { (yyval.t_list_var) = new ast::vars_t;    }
+    { (yyval.t_list_var) = new ast::exps_t();  }
 
     break;
 
   case 103:
 
-    { (yyval.t_list_var) = new ast::vars_t;    }
+    { (yyval.t_list_var) = new ast::exps_t();  }
 
     break;
 
@@ -3644,8 +3655,8 @@ yyreduce:
   case 105:
 
     {
-                                 (yyval.t_list_var) = new ast::vars_t;
-                                 (yyval.t_list_var)->push_front(new ast::SimpleVar((yyloc), *new symbol::Symbol(*(yyvsp[0].str))));
+                                 (yyval.t_list_var) = new ast::exps_t;
+                                 (yyval.t_list_var)->push_back(new ast::SimpleVar((yyloc), *new symbol::Symbol(*(yyvsp[0].str))));
                                  delete (yyvsp[0].str);
                                }
 
@@ -3690,11 +3701,11 @@ yyreduce:
   case 112:
 
     {
-                                 ast::exps_t *tmp = new ast::exps_t;
+                                 ast::exps_t tmp;
                                  #ifdef BUILD_DEBUG_AST
-                                   tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty function body")));
+                                   tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty function body"));
                                  #endif
-                                 (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                 (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                }
 
     break;
@@ -4492,9 +4503,9 @@ yyreduce:
   case 234:
 
     {
-                                                                 std::list<ast::MatrixLineExp *> *tmp = new std::list<ast::MatrixLineExp *>;
-                                                                 tmp->push_front(new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp)));
-                                                                 (yyval.t_cell_exp) = new ast::CellExp((yyloc), *tmp);
+                                                                 ast::exps_t tmp;
+                                                                 tmp[0] = new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp));
+                                                                 (yyval.t_cell_exp) = new ast::CellExp((yyloc), tmp);
                                                                }
 
     break;
@@ -4502,22 +4513,22 @@ yyreduce:
   case 235:
 
     {
-                                                                 std::list<ast::MatrixLineExp *> *tmp = new std::list<ast::MatrixLineExp *>;
-                                                                 tmp->push_front(new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp)));
-                                                                 (yyval.t_cell_exp) = new ast::CellExp((yyloc), *tmp);
+                                                                 ast::exps_t tmp;
+                                                                 tmp[0] = new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp));
+                                                                 (yyval.t_cell_exp) = new ast::CellExp((yyloc), tmp);
                                 }
 
     break;
 
   case 236:
 
-    { (yyval.t_cell_exp) = new ast::CellExp((yyloc), *new std::list<ast::MatrixLineExp *>); }
+    { ast::exps_t tmp;(yyval.t_cell_exp) = new ast::CellExp((yyloc), tmp); }
 
     break;
 
   case 237:
 
-    { (yyval.t_cell_exp) = new ast::CellExp((yyloc), *new std::list<ast::MatrixLineExp *>); }
+    { ast::exps_t tmp;(yyval.t_cell_exp) = new ast::CellExp((yyloc), tmp); }
 
     break;
 
@@ -4554,9 +4565,9 @@ yyreduce:
   case 242:
 
     {
-                                                                 std::list<ast::MatrixLineExp *> *tmp = new std::list<ast::MatrixLineExp *>;
-                                                                 tmp->push_front(new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp)));
-                                                                 (yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), *tmp);
+                                                                 ast::exps_t tmp;
+                                                                 tmp[0] = new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp));
+                                                                 (yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), tmp);
                                                                }
 
     break;
@@ -4564,22 +4575,22 @@ yyreduce:
   case 243:
 
     {
-                                                                 std::list<ast::MatrixLineExp *> *tmp = new std::list<ast::MatrixLineExp *>;
-                                                                 tmp->push_front(new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp)));
-                                                                 (yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), *tmp);
+                                                                 ast::exps_t tmp;
+                                                                 tmp[0] = new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp));
+                                                                 (yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), tmp);
                                                                }
 
     break;
 
   case 244:
 
-    { (yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), *new std::list<ast::MatrixLineExp *>); }
+    { ast::exps_t tmp;(yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), tmp); }
 
     break;
 
   case 245:
 
-    { (yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), *new std::list<ast::MatrixLineExp *>); }
+    { ast::exps_t tmp;(yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), tmp); }
 
     break;
 
@@ -4595,8 +4606,8 @@ yyreduce:
   case 247:
 
     {
-                                         (yyval.t_list_mline) = new std::list<ast::MatrixLineExp *>;
-                                         (yyval.t_list_mline)->push_front((yyvsp[0].t_matrixline_exp));
+                                         (yyval.t_list_mline) = new ast::exps_t;
+                                         (yyval.t_list_mline)->push_back((yyvsp[0].t_matrixline_exp));
                                        }
 
     break;
@@ -4686,7 +4697,7 @@ yyreduce:
 
     {
                                                                                 (yyval.t_list_exp) = new ast::exps_t;
-                                                                                (yyval.t_list_exp)->push_front((yyvsp[0].t_exp));
+                                                                                (yyval.t_list_exp)->push_back((yyvsp[0].t_exp));
                                                                             }
 
     break;
@@ -4695,7 +4706,7 @@ yyreduce:
 
     {
                                                                                 (yyval.t_list_exp) = new ast::exps_t;
-                                                                                (yyval.t_list_exp)->push_front((yyvsp[0].t_call_exp));
+                                                                                (yyval.t_list_exp)->push_back((yyvsp[0].t_call_exp));
                                                                             }
 
     break;
@@ -4704,7 +4715,7 @@ yyreduce:
 
     {
                                                                                 (yyval.t_list_exp) = new ast::exps_t;
-                                                                                (yyval.t_list_exp)->push_front(new ast::CommentExp((yyloc), (yyvsp[0].comment)));
+                                                                                (yyval.t_list_exp)->push_back(new ast::CommentExp((yyloc), (yyvsp[0].comment)));
                                                                             }
 
     break;
@@ -4879,11 +4890,11 @@ yyreduce:
   case 287:
 
     {
-    ast::exps_t *tmp = new ast::exps_t;
+    ast::exps_t tmp;
     #ifdef BUILD_DEBUG_AST
-    tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty then body")));
+    tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty then body"));
     #endif
-    (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+    (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                         }
 
     break;
@@ -4898,9 +4909,9 @@ yyreduce:
 
     {
                                          #ifdef BUILD_DEBUG_AST
-                                           ast::exps_t *tmp = new ast::exps_t;
-                                           tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty else body")));
-                                           (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                           ast::exps_t tmp;
+                                           tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty else body"));
+                                           (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                          #else
                                            (yyval.t_seq_exp) = NULL;
                                          #endif
@@ -5013,9 +5024,9 @@ yyreduce:
   case 307:
 
     {
-                                                                               ast::exps_t *tmp = new ast::exps_t;
-                                                                               tmp->push_front( new ast::IfExp((yyloc), *(yyvsp[-2].t_exp), *(yyvsp[0].t_seq_exp)) );
-                                                                               (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                                                               ast::exps_t tmp;
+                                                                               tmp[0] = new ast::IfExp((yyloc), *(yyvsp[-2].t_exp), *(yyvsp[0].t_seq_exp));
+                                                                               (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                                                        }
 
     break;
@@ -5023,16 +5034,16 @@ yyreduce:
   case 308:
 
     {
-                                                                               ast::exps_t *tmp = new ast::exps_t;
+                                                                               ast::exps_t tmp;
                                                                                if( (yyvsp[0].t_seq_exp) == NULL)
                                         {
-                                            tmp->push_front( new ast::IfExp((yyloc), *(yyvsp[-4].t_exp), *(yyvsp[-2].t_seq_exp)) );
+                                            tmp[0] = new ast::IfExp((yyloc), *(yyvsp[-4].t_exp), *(yyvsp[-2].t_seq_exp));
                                         }
                                         else
                                         {
-                                            tmp->push_front( new ast::IfExp((yyloc), *(yyvsp[-4].t_exp), *(yyvsp[-2].t_seq_exp), *(yyvsp[0].t_seq_exp)) );
+                                            tmp[0] = new ast::IfExp((yyloc), *(yyvsp[-4].t_exp), *(yyvsp[-2].t_seq_exp), *(yyvsp[0].t_seq_exp));
                                         }
-                                                                               (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                                                               (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
 
                                                                        }
 
@@ -5041,9 +5052,9 @@ yyreduce:
   case 309:
 
     {
-                                                                               ast::exps_t *tmp = new ast::exps_t;
-                                                                               tmp->push_front( new ast::IfExp((yyloc), *(yyvsp[-3].t_exp), *(yyvsp[-1].t_seq_exp), *(yyvsp[0].t_seq_exp)) );
-                                                                               (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                                                               ast::exps_t tmp;
+                                                                               tmp[0] = new ast::IfExp((yyloc), *(yyvsp[-3].t_exp), *(yyvsp[-1].t_seq_exp), *(yyvsp[0].t_seq_exp));
+                                                                               (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                                                        }
 
     break;
@@ -5171,7 +5182,7 @@ yyreduce:
   case 330:
 
     {
-                                                                                                                                 (yyval.t_list_case) = new ast::cases_t;
+                                                                                                                                 (yyval.t_list_case) = new ast::exps_t;
                                                                                                                                  (yyval.t_list_case)->push_back(new ast::CaseExp((yyloc), *(yyvsp[-2].t_exp), *(yyvsp[0].t_seq_exp)));
                                                                                                                                }
 
@@ -5180,7 +5191,7 @@ yyreduce:
   case 331:
 
     {
-                                                                                                                                 (yyval.t_list_case) = new ast::cases_t;
+                                                                                                                                 (yyval.t_list_case) = new ast::exps_t;
                                                                                                                                  (yyval.t_list_case)->push_back(new ast::CaseExp((yyloc), *(yyvsp[-2].t_call_exp), *(yyvsp[0].t_seq_exp)));
                                                                                                                                }
 
@@ -5189,7 +5200,7 @@ yyreduce:
   case 332:
 
     {
-                                                                                                                                 (yyval.t_list_case) = new ast::cases_t;
+                                                                                                                                 (yyval.t_list_case) = new ast::exps_t;
                                                                                                                                  (yyval.t_list_case)->push_back(new ast::CaseExp((yyloc), *(yyvsp[-2].t_exp), *(yyvsp[0].t_seq_exp)));
                                                                                                                                }
 
@@ -5198,7 +5209,7 @@ yyreduce:
   case 333:
 
     {
-                                                                                                                                 (yyval.t_list_case) = new ast::cases_t;
+                                                                                                                                 (yyval.t_list_case) = new ast::exps_t;
                                                                                                                                  (yyval.t_list_case)->push_back(new ast::CaseExp((yyloc), *(yyvsp[-2].t_call_exp), *(yyvsp[0].t_seq_exp)));
                                                                                                                                }
 
@@ -5231,11 +5242,11 @@ yyreduce:
   case 337:
 
     {
-                                                 ast::exps_t *tmp = new ast::exps_t;
+                                                 ast::exps_t tmp;
                                                #ifdef BUILD_DEBUG_AST
-                                                 tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty case body")));
+                                                 tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty case body"));
                                                #endif
-                                                 (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                                 (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                                }
 
     break;
@@ -5393,11 +5404,11 @@ yyreduce:
   case 363:
 
     {
-                                 ast::exps_t *tmp = new ast::exps_t;
+                                 ast::exps_t tmp;
                                  #ifdef BUILD_DEBUG_AST
-                                   tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty for body")));
+                                   tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty for body"));
                                  #endif
-                                 (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                 (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                }
 
     break;
@@ -5417,11 +5428,11 @@ yyreduce:
   case 366:
 
     {
-                          ast::exps_t *tmp = new ast::exps_t;
+                          ast::exps_t tmp;
                           #ifdef BUILD_DEBUG_AST
-                            tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty while body")));
+                            tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty while body"));
                           #endif
-                          (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                          (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                         }
 
     break;
@@ -5543,11 +5554,11 @@ yyreduce:
   case 386:
 
     {
-                                                    ast::exps_t *tmp = new ast::exps_t;
+                                                    ast::exps_t tmp;
                                                     #ifdef BUILD_DEBUG_AST
-                                                      tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty catch body")));
+                                                      tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty catch body"));
                                                     #endif
-                                                    (yyval.t_try_exp) =new ast::TryCatchExp((yyloc), *(yyvsp[-1].t_seq_exp), *new ast::SeqExp((yyloc), *tmp));
+                                                    (yyval.t_try_exp) =new ast::TryCatchExp((yyloc), *(yyvsp[-1].t_seq_exp), *new ast::SeqExp((yyloc), tmp));
                                                   }
 
     break;
@@ -5579,11 +5590,11 @@ yyreduce:
   case 391:
 
     {
-                                  ast::exps_t *tmp = new ast::exps_t;
+                                  ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                    tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty catch body")));
+                                    tmp = new ast::CommentExp((yyloc), new std::wstring(L"Empty catch body"));
                                   #endif
-                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                 }
 
     break;
@@ -5591,11 +5602,11 @@ yyreduce:
   case 392:
 
     {
-                                  ast::exps_t *tmp = new ast::exps_t;
+                                  ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                    tmp->push_front(new ast::CommentExp((yyloc), new std::wstring(L"Empty catch body")));
+                                    tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty catch body"));
                                   #endif
-                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), *tmp);
+                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                 }
 
     break;
index b5d9680..cd878ef 100644 (file)
@@ -92,12 +92,17 @@ bool MacroFile::parse(void)
         //find FunctionDec
         ast::FunctionDec* pFD = NULL;
 
-        std::list<ast::Exp *>::iterator j;
-        std::list<ast::Exp *>LExp = ((ast::SeqExp*)tree)->getExps();
+        ast::exps_t::iterator j;
+        ast::exps_t LExp = tree->getAs<ast::SeqExp>()->getExps();
 
         for (j = LExp.begin() ; j != LExp.end() ; j++)
         {
-            pFD = dynamic_cast<ast::FunctionDec*>(*j);
+            if ((*j)->isFunctionDec() == false)
+            {
+                continue;
+            }
+
+            pFD = (*j)->getAs<ast::FunctionDec>();
             if (pFD) // &&     pFD->getName() == m_stName
             {
                 symbol::Context* pContext = symbol::Context::getInstance();
@@ -107,22 +112,23 @@ bool MacroFile::parse(void)
                     MacroFile* pMacro = pContext->getFunction(pFD->getSymbol())->getAs<MacroFile>();
                     if (pMacro->m_pMacro == NULL)
                     {
-                        std::list<ast::Var *>::const_iterator i;
 
                         //get input parameters list
                         std::list<symbol::Variable*> *pVarList = new std::list<symbol::Variable*>();
-                        ast::ArrayListVar *pListVar = (ast::ArrayListVar *)&pFD->getArgs();
-                        for (i = pListVar->getVars().begin() ; i != pListVar->getVars().end() ; i++)
+                        ast::ArrayListVar *pListVar = pFD->getArgs().getAs<ast::ArrayListVar>();
+                        ast::exps_t vars = pListVar->getVars();
+                        for (ast::exps_t::const_iterator it = vars.begin(), itEnd = vars.end() ; it != itEnd ; ++it)
                         {
-                            pVarList->push_back(((ast::SimpleVar*)(*i))->getStack());
+                            pVarList->push_back((*it)->getAs<ast::SimpleVar>()->getStack());
                         }
 
                         //get output parameters list
                         std::list<symbol::Variable*> *pRetList = new std::list<symbol::Variable*>();
-                        ast::ArrayListVar *pListRet = (ast::ArrayListVar *)&pFD->getReturns();
-                        for (i = pListRet->getVars().begin() ; i != pListRet->getVars().end() ; i++)
+                        ast::ArrayListVar *pListRet = pFD->getReturns().getAs<ast::ArrayListVar>();
+                        ast::exps_t recs = pListRet->getVars();
+                        for (ast::exps_t::const_iterator it = recs.begin(), itEnd = recs.end(); it != itEnd ; ++it)
                         {
-                            pRetList->push_back(((ast::SimpleVar*)(*i))->getStack());
+                            pRetList->push_back((*it)->getAs<ast::SimpleVar>()->getStack());
                         }
 
                         pMacro->m_pMacro = new Macro(m_wstName, *pVarList, *pRetList, (ast::SeqExp&)pFD->getBody(), m_wstModule);
diff --git