first ast optimization, constant opexp, constant matrixexp 70/15270/10
Antoine ELIAS [Wed, 24 Sep 2014 09:51:37 +0000 (11:51 +0200)]
Change-Id: Ie5effb84b9628d9b5778016b581e52620041e60f

71 files changed:
scilab/modules/ast/ast.vcxproj
scilab/modules/ast/ast.vcxproj.filters
scilab/modules/ast/includes/analysis/AnalysisVisitor.hxx
scilab/modules/ast/includes/analysis/Result.hxx
scilab/modules/ast/includes/ast/debugvisitor.hxx
scilab/modules/ast/includes/ast/dummyvisitor.hxx
scilab/modules/ast/includes/ast/execvisitor.hxx
scilab/modules/ast/includes/ast/printvisitor.hxx
scilab/modules/ast/includes/ast/runvisitor.hxx
scilab/modules/ast/includes/ast/serializervisitor.hxx
scilab/modules/ast/includes/ast/shortcutvisitor.hxx
scilab/modules/ast/includes/ast/stepvisitor.hxx
scilab/modules/ast/includes/ast/timedvisitor.hxx
scilab/modules/ast/includes/ast/visitor.hxx
scilab/modules/ast/includes/exps/allexp.hxx
scilab/modules/ast/includes/exps/assignexp.hxx
scilab/modules/ast/includes/exps/ast.hxx
scilab/modules/ast/includes/exps/boolexp.hxx
scilab/modules/ast/includes/exps/callexp.hxx
scilab/modules/ast/includes/exps/caseexp.hxx
scilab/modules/ast/includes/exps/constexp.hxx
scilab/modules/ast/includes/exps/daxpyexp.hxx [new file with mode: 0644]
scilab/modules/ast/includes/exps/decls.hxx
scilab/modules/ast/includes/exps/doubleexp.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/optimizedexp.hxx [new file with mode: 0644]
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/stringexp.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/system_env/configvariable.hxx
scilab/modules/ast/includes/types/bool.hxx
scilab/modules/ast/includes/types/double.hxx
scilab/modules/ast/includes/types/internal.hxx
scilab/modules/ast/includes/types/string.hxx
scilab/modules/ast/src/cpp/ast/debugvisitor.cpp
scilab/modules/ast/src/cpp/ast/macrovarvisitor.cpp
scilab/modules/ast/src/cpp/ast/printvisitor.cpp
scilab/modules/ast/src/cpp/ast/run_OpExp.cpp
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/parse/bison/parsescilab.yy
scilab/modules/ast/src/cpp/parse/parsescilab.cpp
scilab/modules/ast/src/cpp/system_env/configvariable.cpp
scilab/modules/ast/src/cpp/types/bool.cpp
scilab/modules/ast/src/cpp/types/double.cpp
scilab/modules/ast/src/cpp/types/string.cpp
scilab/modules/core/Makefile.am
scilab/modules/core/Makefile.in
scilab/modules/core/includes/core_gw.hxx
scilab/modules/core/sci_gateway/cpp/core_gw.cpp
scilab/modules/core/sci_gateway/cpp/core_gw.vcxproj
scilab/modules/core/sci_gateway/cpp/core_gw.vcxproj.filters
scilab/modules/core/sci_gateway/cpp/sci_analyzeroptions.cpp [new file with mode: 0644]
scilab/modules/core/src/cpp/InitScilab.cpp
scilab/modules/core/src/cpp/tasks.cpp
scilab/modules/elementary_functions/includes/elem_common.h
scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp
scilab/modules/functions/sci_gateway/cpp/sci_macrovar.cpp

index d26bb2c..3fb5e56 100644 (file)
@@ -286,6 +286,7 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClInclude Include="includes\exps\constexp.hxx" />
     <ClInclude Include="includes\exps\continueexp.hxx" />
     <ClInclude Include="includes\exps\controlexp.hxx" />
+    <ClInclude Include="includes\exps\daxpyexp.hxx" />
     <ClInclude Include="includes\exps\dec.hxx" />
     <ClInclude Include="includes\exps\decls.hxx" />
     <ClInclude Include="includes\exps\dollarvar.hxx" />
@@ -304,6 +305,7 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClInclude Include="includes\exps\nilexp.hxx" />
     <ClInclude Include="includes\exps\notexp.hxx" />
     <ClInclude Include="includes\exps\opexp.hxx" />
+    <ClInclude Include="includes\exps\optimizedexp.hxx" />
     <ClInclude Include="includes\exps\returnexp.hxx" />
     <ClInclude Include="includes\exps\selectexp.hxx" />
     <ClInclude Include="includes\exps\seqexp.hxx" />
@@ -522,4 +524,4 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index 52baf67..e53d949 100644 (file)
     <ClInclude Include="includes\operations\types_dotdivide.hxx">
       <Filter>Header Files\operations</Filter>
     </ClInclude>
+    <ClInclude Include="includes\exps\optimizedexp.hxx">
+      <Filter>Header Files\exps</Filter>
+    </ClInclude>
+    <ClInclude Include="includes\exps\daxpyexp.hxx">
+      <Filter>Header Files\exps</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="src\cpp\ast\debugvisitor.cpp">
index f91f5bf..30b582f 100644 (file)
@@ -26,6 +26,7 @@
 #include "ForList.hxx"
 #include "Result.hxx"
 #include "SymInfo.hxx"
+#include "execvisitor.hxx"
 
 namespace analysis
 {
@@ -307,19 +308,19 @@ private:
 
     void visit(ast::DoubleExp & e)
     {
-        e.getDecorator().res = Result(TIType(TIType::DOUBLE, 1, 1), false);
+        e.getDecorator().res = Result(TIType(TIType::DOUBLE, 1, 1), false, true);
         setResult(e.getDecorator().res);
     }
 
     void visit(ast::BoolExp & e)
     {
-        e.getDecorator().res = Result(TIType(TIType::BOOLEAN, 1, 1), false);
+        e.getDecorator().res = Result(TIType(TIType::BOOLEAN, 1, 1), false, true);
         setResult(e.getDecorator().res);
     }
 
     void visit(ast::StringExp & e)
     {
-        e.getDecorator().res = Result(TIType(TIType::STRING, 1, 1), false);
+        e.getDecorator().res = Result(TIType(TIType::STRING, 1, 1), false, true);
         setResult(e.getDecorator().res);
     }
 
@@ -358,7 +359,6 @@ private:
         const TIType & RType = RR.getType();
         TIType resT;
         bool allocTmp = false;
-        bool constant = false;
 
         // We can released the temp vars
         if (LR.isTemp())
@@ -370,9 +370,25 @@ private:
             add_tmp(RType, -1);
         }
 
+        //if left and right are constant, result is constant too
+        if (e.getLeft().getDecorator().res.isConstant() && e.getRight().getDecorator().res.isConstant())
+        {
+            if (execAndReplace(e))
+            {
+                return;
+            }
+        }
+
         switch (e.getOper())
         {
             case ast::OpExp::plus :
+            {
+                if (replaceDAXPY(e))
+                {
+                    return;
+                }
+                //continue in generic case
+            }
             case ast::OpExp::minus :
             case ast::OpExp::dottimes :
             {
@@ -395,12 +411,7 @@ private:
             allocTmp = true;
         }
 
-        if (e.getLeft().isConstExp() && e.getRight().isConstExp())
-        {
-            constant = true;
-        }
-
-        e.getDecorator().res = Result(resT, allocTmp, true);
+        e.getDecorator().res = Result(resT, allocTmp, false);
         setResult(e.getDecorator().res);
     }
 
@@ -516,19 +527,37 @@ private:
     void visit(ast::MatrixExp & e)
     {
         const ast::exps_t lines = e.getLines();
+        bool constant = true;
         for (ast::exps_t::const_iterator i = lines.begin(), itEnd = lines.end(); i != itEnd; ++i)
         {
             (*i)->accept(*this);
+            if ((*i)->getDecorator().res.isConstant() == false)
+            {
+                constant = false;
+            }
+        }
+
+        if (constant)
+        {
+            execAndReplace(e);
         }
     }
 
     void visit(ast::MatrixLineExp & e)
     {
         const ast::exps_t columns = e.getColumns();
+        bool constant = true;
         for (ast::exps_t::const_iterator i = columns.begin(), itEnd = columns.end(); i != itEnd; ++i)
         {
             (*i)->accept(*this);
+            if ((*i)->getDecorator().res.isConstant() == false)
+            {
+                constant = false;
+            }
         }
+
+        e.getDecorator().res = Result(e.getDecorator().res.getType(), e.getDecorator().res.isTemp(), constant);
+
     }
 
     void visit(ast::CellExp & e)
@@ -614,6 +643,87 @@ private:
 
         const_cast<ast::ListExp &>(e).setValues(start, step, end);
     }
+
+    /* optimized */
+    void visit(ast::OptimizedExp & e)
+    {
+        //gné ??? Oo
+    }
+
+    void visit(ast::DAXPYExp & e)
+    {
+        //gné ??? Oo
+    }
+
+    bool replaceDAXPY(ast::OpExp& e)
+    {
+        bool ret = false;
+
+        if (e.getOper() == ast::OpExp::plus)
+        {
+            ast::Exp& le = e.getLeft();
+            ast::Exp& re = e.getRight();
+            ast::Exp* a = NULL;
+            ast::Exp* x = NULL;
+            ast::Exp* y = NULL;
+
+            // a * x(i,j) + y(i,j) or y(i,j) + a * x(i,j)
+
+            if (le.isOpExp() && le.getAs<ast::OpExp>()->getOper() == ast::OpExp::dottimes)
+            {
+                ast::OpExp* dt = le.getAs<ast::OpExp>();
+                y = &le;
+                a = &dt->getLeft();
+                x = &dt->getRight();
+            }
+            else if (re.isOpExp() && re.getAs<ast::OpExp>()->getOper() == ast::OpExp::dottimes)
+            {
+                ast::OpExp* rt = re.getAs<ast::OpExp>();
+                y = &re;
+                a = &rt->getLeft();
+                x = &rt->getRight();
+            }
+
+            if (a && x && y)
+            {
+                //checks dimensions of x and y
+                ast::Exp* exp = new ast::DAXPYExp(e.getLocation(), *a, *x, *y);
+                exp->setVerbose(e.isVerbose());
+                exp->getDecorator().res = e.getDecorator().res;
+                e.replace(exp);
+                ret = true;
+            }
+        }
+        return ret;
+    }
+
+    bool execAndReplace(ast::Exp& e)
+    {
+        //exec operation and substitute exp by result
+        ast::ExecVisitor exec;
+
+        try
+        {
+            e.accept(exec);
+            InternalType* result = exec.getResult();
+            ast::Exp* exp = result->getExp(e.getLocation());
+            if (exp)
+            {
+                exp->setVerbose(e.isVerbose());
+                e.replace(exp);
+                exp->getDecorator().res = Result(e.getDecorator().res.getType(), e.getDecorator().res.isTemp(), true);
+                setResult(exp->getDecorator().res);
+                return true;
+            }
+        }
+        catch (const ast::ScilabException& /*se*/)
+        {
+            //nothing to do, stop optimization phase and continue.
+            std::cout << "optimization failed !" << std::endl;
+        }
+
+        return false;
+    }
 };
 
 } // namespace analysis
index 88c27e3..3fd0f0e 100644 (file)
@@ -27,15 +27,20 @@ class Result
 
 public:
 
-    Result() : type(), temp(false) { }
-    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) { }
+    Result() : type(), temp(false), constant(false) { }
+    Result(const TIType & _type, const bool _temp, const bool _constant) : type(_type), temp(_temp), constant(_constant) { }
+    Result(TIType && _type, const bool _temp, const bool _constant) : type(_type), temp(_temp), constant(_constant) { }
 
     inline bool isTemp() const
     {
         return temp;
     }
 
+    inline bool isConstant() const
+    {
+        return constant;
+    }
+
     inline const TIType & getType() const
     {
         return type;
index 6df05af..9907731 100644 (file)
@@ -98,6 +98,10 @@ public :
      ** \{ */
 public:
     virtual void visit(const ListExp &e);
+
+    /* optimized */
+    virtual void visit(const OptimizedExp &e);
+    virtual void visit(const DAXPYExp &e);
     /** \} */
 };
 }
index ec91bb4..44f19f1 100644 (file)
@@ -283,6 +283,17 @@ protected:
         e.getEnd().accept(*this);
     }
     /** \} */
+
+    /* optimized */
+    virtual void visit(const OptimizedExp &e)
+    {
+        e.getOriginal()->accept(*this);
+    }
+
+    virtual void visit (const DAXPYExp &e)
+    {
+        e.getOriginal()->accept(*this);
+    }
 };
 }
 
index 7575554..03b682c 100644 (file)
@@ -193,6 +193,16 @@ class EXTERN_AST ExecVisitor : public RunVisitorT<ExecVisitor>
     {
         visitprivate(e);
     }
+
+    void visit(const OptimizedExp &e)
+    {
+        visitprivate(e);
+    }
+
+    void visit(const DAXPYExp &e)
+    {
+        visitprivate(e);
+    }
 };
 }
 #endif // !AST_EXECVISITOR_HXX
index a863a36..233c91f 100644 (file)
@@ -110,6 +110,10 @@ public :
     ** \{ */
 public:
     virtual void visit(const ListExp &e);
+
+    /* optimized */
+    virtual void visit(const OptimizedExp &e);
+    virtual void visit(const DAXPYExp &e);
     /** \} */
 
 
index aee807d..892260f 100644 (file)
@@ -364,40 +364,42 @@ public :
     void visitprivate(const MatrixExp &e);
     void visitprivate(const CallExp &e);
     void visitprivate(const CellCallExp &e);
+    void visitprivate(const OptimizedExp &e);
+    void visitprivate(const DAXPYExp &e);
 
     void visitprivate(const StringExp &e)
     {
-        if (e.getBigString() == NULL)
+        if (e.getConstant() == NULL)
         {
             types::String *psz = new types::String(e.getValue().c_str());
-            (const_cast<StringExp *>(&e))->setBigString(psz);
+            (const_cast<StringExp *>(&e))->setConstant(psz);
 
         }
-        setResult(e.getBigString());
+        setResult(e.getConstant());
     }
 
 
     void visitprivate(const DoubleExp  &e)
     {
-        if (e.getBigDouble() == NULL)
+        if (e.getConstant() == NULL)
         {
             Double *pdbl = new Double(e.getValue());
-            (const_cast<DoubleExp *>(&e))->setBigDouble(pdbl);
+            (const_cast<DoubleExp *>(&e))->setConstant(pdbl);
 
         }
-        setResult(e.getBigDouble());
+        setResult(e.getConstant());
     }
 
 
     void visitprivate(const BoolExp  &e)
     {
-        if (e.getBigBool() == NULL)
+        if (e.getConstant() == NULL)
         {
             Bool *pB = new Bool(e.getValue());
-            (const_cast<BoolExp *>(&e))->setBigBool(pB);
+            (const_cast<BoolExp *>(&e))->setConstant(pB);
 
         }
-        setResult(e.getBigBool());
+        setResult(e.getConstant());
     }
 
 
index 98efffe..d527410 100644 (file)
@@ -185,7 +185,7 @@ private :
         add_uint32((unsigned int)exps.size());
         for (exps_t::const_iterator it = exps.begin(), itEnd = exps.end(); it != itEnd ; ++it)
         {
-            (*it)->accept(*this);
+            (*it)->getOriginal()->accept(*this);
         }
     }
 
@@ -195,7 +195,7 @@ private :
         add_uint32((unsigned int)vars.size());
         for (exps_t::const_iterator it = vars.begin (), itEnd = vars.end(); it != itEnd; ++it)
         {
-            (*it)->accept(*this);
+            (*it)->getOriginal()->accept(*this);
         }
     }
 
@@ -206,12 +206,12 @@ private :
 
     void add_exp(const Exp* e)
     {
-        e->accept(*this);
+        e->getOriginal()->accept(*this);
     }
 
     void add_exp(const Exp& e)
     {
-        e.accept(*this);
+        e.getOriginal()->accept(*this);
     }
 
     void add_OpExp_Oper(const OpExp::Oper oper)
@@ -531,15 +531,15 @@ private :
     {
         add_ast(32, e);
         add_OpExp_Oper(e.getOper());
-        e.getLeft().accept(*this);
-        e.getRight().accept(*this);
+        e.getLeft().getOriginal()->accept(*this);
+        e.getRight().getOriginal()->accept(*this);
     }
     void visit(const LogicalOpExp& e)  /* done */
     {
         add_ast(33, e);
         add_OpExp_Oper(e.getOper());
-        e.getLeft().accept(*this);
-        e.getRight().accept(*this);
+        e.getLeft().getOriginal()->accept(*this);
+        e.getRight().getOriginal()->accept(*this);
     }
     void visit(const MatrixExp& e) /* done */
     {
@@ -563,13 +563,24 @@ private :
         add_exps(e.getArgs());
     }
 
+    /* optimized */
+    void visit(const OptimizedExp& e)
+    {
+        e.getOriginal()->accept(*this);
+    }
+
+    void visit(const DAXPYExp& e)
+    {
+        e.getOriginal()->accept(*this);
+    }
+
 public :
     SerializeVisitor(Exp* _ast) : ast(_ast), buf(NULL), buflen(0), bufsize(0), saveNodeNumber(true) {}
 
     unsigned char* serialize(bool _saveNodeNumber = true)
     {
         saveNodeNumber = _saveNodeNumber;
-        ast->accept(*this);
+        ast->getOriginal()->accept(*this);
         return get_buf();
     }
 };
index 0e44005..d1c655a 100644 (file)
@@ -65,6 +65,7 @@ public:
     virtual void visit (const ListExp &/*e*/) {}
 
     virtual void visit (const LogicalOpExp &e);
+
 };
 }
 #endif // !AST_SHORTCUTVISITOR_HXX
index 3b39bcb..6f421a0 100644 (file)
@@ -203,6 +203,17 @@ class EXTERN_AST StepVisitor : public RunVisitorT<StepVisitor>
     {
         visitprivate(e);
     }
+
+    /* optimized */
+    void visit(const OptimizedExp &e)
+    {
+        visitprivate(e);
+    }
+
+    void visit(const DAXPYExp &e)
+    {
+        visitprivate(e);
+    }
 };
 }
 
index 9e4aad4..8df9d5d 100644 (file)
@@ -206,6 +206,17 @@ public :
     {
         visitprivate(e);
     }
+
+    /* optimized */
+    void visit(const OptimizedExp &e)
+    {
+        visitprivate(e);
+    }
+
+    void visit(const DAXPYExp &e)
+    {
+        visitprivate(e);
+    }
 };
 }
 #endif // !AST_TIMEDVISITOR_HXX
index 6e33e4a..0a0011d 100644 (file)
@@ -164,6 +164,12 @@ public:
 public:
     virtual void visit (typename select_const<K, ListExp>::t & e) = 0;
     /** \} */
+
+public:
+    virtual void visit (typename select_const<K, OptimizedExp>::t & e) = 0;
+
+    /*optimized*/
+    virtual void visit (typename select_const<K, DAXPYExp>::t & e) = 0;
 };
 
 /** \brief Define shortand type for a const visitor */
index 691b61b..15c3a75 100644 (file)
@@ -73,5 +73,7 @@
 
 // Type Dedicated Expressions
 #include "listexp.hxx"
+#include "optimizedexp.hxx"
+#include "daxpyexp.hxx"
 
 #endif /* !AST_ALLEXP_HXX */
index 78858b3..64951e1 100644 (file)
@@ -42,10 +42,11 @@ public:
     ** Delete var and exp (see constructor). */
     virtual ~AssignExp ()
     {
-        if (lr_owner)
+        if (lr_owner == false)
         {
-            delete _exps[0];
-            delete _exps[1];
+            //set to NULL to avoid delete in ~Exp()
+            _exps[0] = NULL;
+            _exps[1] = NULL;
         }
     }
     /** \} */
index 8e44250..c8a3d8a 100644 (file)
@@ -112,25 +112,9 @@ public:
         decorator = _decorator;
     }
 
-    Ast* getParent() const
-    {
-        return parent;
-    }
-
-    Ast* getParent()
-    {
-        return parent;
-    }
-
-    void setParent(Ast* _ast)
-    {
-        parent = _ast;
-    }
-
 private:
-    /** \brief Construct an Ast by copy. */
     analysis::Decorator decorator;
-    Ast* parent;
+    /** \brief Construct an Ast by copy. */
     Ast (const Ast&);
     /** \brief Assign an Ast to this. */
     Ast& operator= (const Ast&);
index 8d5dfd0..902e232 100644 (file)
@@ -15,7 +15,6 @@
 #define AST_BOOLEXP_HXX
 
 #include "constexp.hxx"
-#include "bool.hxx"
 
 using namespace types;
 
@@ -28,19 +27,21 @@ class BoolExp : public ConstExp
 {
 public:
     BoolExp (const Location& location, bool value)
-        : ConstExp (location), _value (value), _bigBool (NULL)
+        : ConstExp (location), _value (value)
     {
     }
+
+    BoolExp (const Location& location, types::InternalType* value)
+        : ConstExp (location),
+          _value (false)
+    {
+        setConstant(value);
+    }
     /** \brief Destroy an Boolean Expression node.
     **
     ** Delete size et init (exp) (see constructor). */
     virtual ~BoolExp ()
     {
-        if (_bigBool)
-        {
-            _bigBool->DecreaseRef();
-            _bigBool->killMe();
-        }
     }
     /** \} */
 
@@ -76,26 +77,6 @@ public:
         return _value;
     }
 
-    /** \brief Get the big bool */
-    types::Bool* getBigBool() const
-    {
-        return _bigBool;
-    }
-
-    /** \brief Set the big bool */
-    void setBigBool(types::Bool *pB)
-    {
-        if (_bigBool)
-        {
-            _bigBool->DecreaseRef();
-            _bigBool->killMe();
-        }
-
-        _bigBool = pB;
-        _bigBool->IncreaseRef();
-    }
-    /** \} */
-
     virtual ExpType getType()
     {
         return BOOLEXP;
@@ -106,8 +87,7 @@ public:
     }
 
 protected:
-    bool            _value;
-    types::Bool*    _bigBool;
+    bool _value;
 
 };
 
index 19189a8..b09063c 100644 (file)
@@ -95,14 +95,20 @@ public:
     const exps_t& getArgs() const
     {
         exps_t* args = new exps_t;
-        std::copy(++(_exps.begin()), _exps.end(), args->begin());
+        for (exps_t::const_iterator it = ++(_exps.begin()), itEnd = _exps.end(); it != itEnd ; ++it)
+        {
+            args->push_back(*it);
+        }
         return *args;
     }
 
     exps_t& getArgs()
     {
         exps_t* args = new exps_t;
-        std::copy(++(_exps.begin()), _exps.end(), args->begin());
+        for (exps_t::const_iterator it = ++(_exps.begin()), itEnd = _exps.end(); it != itEnd ; ++it)
+        {
+            args->push_back(*it);
+        }
         return *args;
     }
 
index 1853df2..21fe7a7 100644 (file)
@@ -34,8 +34,6 @@ public :
 
     ~CaseExp()
     {
-        delete _exps[0];
-        delete _exps[1];
     }
 
     virtual CaseExp* clone()
index 3b0828d..423a6dc 100644 (file)
@@ -14,6 +14,7 @@
 #define AST_CONSTEXP_HXX
 
 #include "exp.hxx"
+#include "internal.hxx"
 
 namespace ast
 {
@@ -24,18 +25,48 @@ class ConstExp : public Exp
 {
 public:
     ConstExp (const Location& location)
-        : Exp (location)
+        : Exp (location), constant(NULL)
     {
     }
 
     virtual ~ConstExp ()
     {
+        if (constant)
+        {
+            constant->DecreaseRef();
+            constant->killMe();
+        }
     }
 
     inline bool isConstExp() const
     {
         return true;
     }
+
+    types::InternalType* getConstant() const
+    {
+        return constant;
+    }
+
+    types::InternalType* getConstant()
+    {
+        return constant;
+    }
+
+    void setConstant(types::InternalType* _const)
+    {
+        if (constant)
+        {
+            constant->DecreaseRef();
+            constant->killMe();
+        }
+
+        constant = _const;
+        constant->IncreaseRef();
+    }
+
+protected :
+    types::InternalType* constant;
 };
 } // namespace ast
 #endif
diff --git a/scilab/modules/ast/includes/exps/daxpyexp.hxx b/scilab/modules/ast/includes/exps/daxpyexp.hxx
new file mode 100644 (file)
index 0000000..10ec186
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef AST_DAXPYEXP_HXX
+#define AST_DAXPYEXP_HXX
+
+#include "optimizedexp.hxx"
+#include "internal.hxx"
+
+namespace ast
+{
+class DAXPYExp : public OptimizedExp
+{
+public:
+    DAXPYExp (const Location& location, Exp& a, Exp& x, Exp& y)
+        : OptimizedExp (location)
+    {
+        _exps.push_back(&a);
+        _exps.push_back(&x);
+        _exps.push_back(&y);
+
+        a.setParent(this);
+        x.setParent(this);
+        y.setParent(this);
+    }
+
+    virtual ~DAXPYExp ()
+    {
+        //all children are ref so let original parent to destroy then
+        _exps.clear();
+    }
+
+    virtual DAXPYExp* clone()
+    {
+        DAXPYExp* cloned = new DAXPYExp(getLocation(), *getA().clone(), *getX().clone(), *getY().clone());
+        return cloned;
+    }
+
+    virtual void accept (Visitor& v)
+    {
+        v.visit (*this);
+    }
+
+    virtual void accept (ConstVisitor& v) const
+    {
+        v.visit (*this);
+    }
+
+    const Exp& getA() const
+    {
+        return *_exps[0];
+    }
+
+    Exp& getA()
+    {
+        return *_exps[0];
+    }
+
+    const Exp& getX() const
+    {
+        return *_exps[1];
+    }
+
+    Exp& getX()
+    {
+        return *_exps[1];
+    }
+
+    const Exp& getY() const
+    {
+        return *_exps[2];
+    }
+
+    Exp& getY()
+    {
+        return *_exps[2];
+    }
+
+};
+} // namespace ast
+#endif /* !AST_DAXPYEXP_HXX */
index e5af6da..a4154c7 100644 (file)
@@ -81,6 +81,9 @@ class FunctionDec;
 // Type dedicated Exp
 class ListExp;
 
+class OptimizedExp;
+class DAXPYExp;
+
 } // namespace ast
 
 #endif // !AST_DECLS_HXX
index ce850b9..2f334b3 100644 (file)
@@ -17,8 +17,6 @@
 
 #include "visitor.hxx"
 
-#include "double.hxx"
-
 namespace ast
 {
 /** \brief Abstract an Double Expression node.
@@ -29,20 +27,21 @@ class DoubleExp : public ConstExp
 public:
     DoubleExp (const Location& location, double value)
         : ConstExp (location),
-          _value (value),
-          _bigDouble (NULL)
+          _value (value)
+    {
+    }
+
+    DoubleExp (const Location& location, types::InternalType* value)
+        : ConstExp (location),
+          _value (0)
     {
+        setConstant(value);
     }
     /** \brief Destroy an Double Expression node.
     **
     ** Delete size et init (exp) (see constructor). */
     virtual ~DoubleExp ()
     {
-        if (_bigDouble)
-        {
-            _bigDouble->DecreaseRef();
-            _bigDouble->killMe();
-        }
     }
     /** \} */
 
@@ -78,23 +77,6 @@ public:
     }
     /** \} */
 
-    types::Double* getBigDouble() const
-    {
-        return _bigDouble;
-    }
-
-    void setBigDouble(types::Double *pdbl)
-    {
-        if (_bigDouble)
-        {
-            _bigDouble->DecreaseRef();
-            _bigDouble->killMe();
-        }
-
-        _bigDouble = pdbl;
-        _bigDouble->IncreaseRef();
-    }
-
     virtual ExpType getType()
     {
         return DOUBLEEXP;
@@ -105,8 +87,7 @@ public:
     }
 
 protected:
-    double     _value;
-    types::Double*    _bigDouble;
+    double _value;
 };
 
 } // namespace ast
index d539f98..7c49d28 100644 (file)
@@ -46,15 +46,26 @@ public:
           _bReturn(false),
           _bReturnable(false),
           _bContinue(false),
-          _bContinuable(false)
+          _bContinuable(false),
+          parent(NULL),
+          original(NULL)
     {
+        original = this;
     }
     /** \brief Destroys an Expression node. */
     virtual ~Exp ()
     {
         for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd; ++it)
         {
-            delete *it;
+            if (*it != NULL)
+            {
+                delete *it;
+            }
+        }
+
+        if (original && original != this)
+        {
+            delete original;
         }
     }
     /** \} */
@@ -406,6 +417,65 @@ public:
         return false;
     }
 
+    inline virtual bool isOptimizedExp() const
+    {
+        return false;
+    }
+
+    Exp* getParent() const
+    {
+        return parent;
+    }
+
+    Exp* getParent()
+    {
+        return parent;
+    }
+
+    void setParent(Exp* _ast)
+    {
+        parent = _ast;
+    }
+
+    Exp* getOriginal() const
+    {
+        return original;
+    }
+
+    Exp* getOriginal()
+    {
+        return original;
+    }
+
+    void setOriginal(Exp* _ast)
+    {
+        original = _ast;
+    }
+
+    void replace(Exp* _new)
+    {
+        if (parent && _new)
+        {
+            parent->replace(this, _new);
+        }
+    }
+
+    void replace(Exp* _old, Exp* _new)
+    {
+        if (_old && _new)
+        {
+            for (exps_t::iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
+            {
+                if (*it == _old)
+                {
+                    _new->setOriginal(*it);
+                    *it = _new;
+                    _new->setParent(this);
+                }
+            }
+        }
+    }
+
 private:
     bool _verbose;
     bool _bBreak;
@@ -416,7 +486,8 @@ private:
     bool _bContinuable;
 protected:
     exps_t _exps;
-    Exp* _original;
+    Exp* parent;
+    Exp* original;
 };
 } // namespace ast
 
index 6b12fed..e534a58 100644 (file)
@@ -48,8 +48,8 @@ public:
     {
         head.setParent(this);
         tail.setParent(this);
-        _exps[0] = &head;
-        _exps[1] = &tail;
+        _exps.push_back(&head);
+        _exps.push_back(&tail);
     }
 
     /** \brief Destroy a Field Expression node.
@@ -57,8 +57,6 @@ public:
     ** Delete name and init (see constructor). */
     virtual ~FieldExp()
     {
-        delete _exps[0];
-        delete _exps[1];
     }
     /** \}*/
 
index ba873ff..dbb0e84 100644 (file)
@@ -47,8 +47,8 @@ public:
     {
         vardec.setParent(this);
         body.setParent(this);
-        _exps[0] = &vardec;
-        _exps[1] = &body;
+        _exps.push_back(&vardec);
+        _exps.push_back(&body);
     }
 
     /** \brief Destroy a For Expression node.
@@ -56,8 +56,6 @@ public:
     ** Delete vardec, hi and body (see constructor). */
     virtual ~ForExp ()
     {
-        delete _exps[0];
-        delete _exps[1];
     }
     /** \} */
 
index 62430a3..b3d8321 100644 (file)
@@ -58,18 +58,16 @@ public:
         args.setParent(this);
         returns.setParent(this);
         body.setParent(this);
-        _exps[0] = &args;
-        _exps[1] = &returns;
-        _exps[2] = &body;
+        _exps.push_back(&args);
+        _exps.push_back(&returns);
+        _exps.push_back(&body);
     }
 
     virtual ~FunctionDec ()
     {
         //body will be deleted by types::Macro
-        //delete _exps[2];
-        delete _exps[0];
-        delete _exps[1];
-
+        //so replace by NULL to avoir delete in ~Exp()
+        _exps[2] = NULL;
     }
 
     virtual FunctionDec* clone()
index 5d4ea01..03aba98 100644 (file)
@@ -41,9 +41,9 @@ public:
         test.setParent(this);
         t.setParent(this);
         e.setParent(this);
-        _exps[0] = &test;
-        _exps[1] = &t;
-        _exps[2] = &e;
+        _exps.push_back(&test);
+        _exps.push_back(&t);
+        _exps.push_back(&e);
     }
 
     IfExp(const Location& location,
@@ -54,17 +54,14 @@ public:
         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.push_back(&test);
+        _exps.push_back(&t);
+        _exps.push_back(new ast::CommentExp(location, new std::wstring(L"No else !!")));
         _exps[2]->setParent(this);
     }
 
     virtual ~IfExp()
     {
-        delete _exps[0];
-        delete _exps[1];
-        delete _exps[2];
     }
 
     virtual IfExp* clone()
index 487e65d..cb13be5 100644 (file)
@@ -46,9 +46,9 @@ public:
         start.setParent(this);
         step.setParent(this);
         end.setParent(this);
-        _exps[0] = &start;
-        _exps[1] = &step;
-        _exps[2] = &end;
+        _exps.push_back(&start);
+        _exps.push_back(&step);
+        _exps.push_back(&end);
 
         values[0] = std::numeric_limits<double>::quiet_NaN();
         values[1] = std::numeric_limits<double>::quiet_NaN();
@@ -65,9 +65,6 @@ public:
     ** Delete left and right, see constructor. */
     virtual ~ListExp ()
     {
-        delete _exps[0];
-        delete _exps[1];
-        delete _exps[2];
     }
     /** \} */
 
index c52dc14..208bb08 100644 (file)
@@ -48,10 +48,6 @@ public:
 
     virtual ~MatrixExp ()
     {
-        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
-        {
-            delete *it;
-        }
     }
 
     virtual MatrixExp* clone()
index 1a6ef4b..4e6053e 100644 (file)
@@ -48,10 +48,6 @@ public:
 
     virtual ~MatrixLineExp ()
     {
-        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
-        {
-            delete *it;
-        }
     }
 
     virtual MatrixLineExp* clone()
index 7a9132b..4bedbea 100644 (file)
@@ -37,7 +37,7 @@ public:
         : MathExp (location)
     {
         exp.setParent(this);
-        _exps[0] = &exp;
+        _exps.push_back(&exp);
     }
 
     /** \brief Destroy a Not Operation Expression node.
@@ -45,7 +45,6 @@ public:
     ** Delete expression, see constructor. */
     virtual ~NotExp ()
     {
-        delete _exps[0];
     }
     /** \} */
 
index d8f162b..7967491 100644 (file)
@@ -92,8 +92,8 @@ public:
     {
         left.setParent(this);
         right.setParent(this);
-        _exps[0] = &left;
-        _exps[1] = &right;
+        _exps.push_back(&left);
+        _exps.push_back(&right);
     }
 
     /** \brief Destroy a Operation Expression node.
@@ -101,8 +101,6 @@ public:
     ** Delete left and right, see constructor. */
     virtual ~OpExp ()
     {
-        delete _exps[0];
-        delete _exps[1];
     }
     /** \} */
 
diff --git a/scilab/modules/ast/includes/exps/optimizedexp.hxx b/scilab/modules/ast/includes/exps/optimizedexp.hxx
new file mode 100644 (file)
index 0000000..bae017c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef AST_OPTIMIZEDEXP_HXX
+#define AST_OPTIMIZEDEXP_HXX
+
+#include "exp.hxx"
+
+namespace ast
+{
+class OptimizedExp : public Exp
+{
+public:
+    OptimizedExp (const Location& location)
+        : Exp (location)
+    {
+    }
+
+    virtual ~OptimizedExp ()
+    {
+    }
+
+    virtual ExpType getType()
+    {
+        return OPTIMIZEDEXP;
+    }
+
+    inline bool isOptimizedExp() const
+    {
+        return true;
+    }
+};
+} // namespace ast
+#endif /* !AST_OPTIMIZEDEXP_HXX */
index ee55569..f094ea3 100644 (file)
@@ -43,11 +43,11 @@ public:
         {
             _is_global = false;
             exp->setParent(this);
-            _exps[0] = exp;
+            _exps.push_back(exp);
         }
         else
         {
-            _exps[0] = new ast::CommentExp(location, new std::wstring(L"No return !!"));
+            _exps.push_back(new ast::CommentExp(location, new std::wstring(L"No return !!")));
             _exps[0]->setParent(this);
         }
 
@@ -55,7 +55,6 @@ public:
 
     virtual ~ReturnExp ()
     {
-        delete _exps[0];
     }
 
     virtual ReturnExp* clone()
index a3180b3..2147b2b 100644 (file)
@@ -44,8 +44,15 @@ public :
             _exps.push_back(*it);
         }
 
-        defaultCase.setParent(this);
-        _exps.push_back(&defaultCase);
+        if (&defaultCase != NULL)
+        {
+            defaultCase.setParent(this);
+            _exps.push_back(&defaultCase);
+        }
+        else
+        {
+            _hasDefault = false;
+        }
     }
 
     SelectExp(const Location& location,
@@ -66,10 +73,6 @@ public :
 
     ~SelectExp()
     {
-        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
-        {
-            delete *it;
-        }
     }
 
     virtual SelectExp* clone()
index b71c621..3d7c3a3 100644 (file)
@@ -49,10 +49,6 @@ public:
 
     virtual ~SeqExp ()
     {
-        for (exps_t::const_iterator it = _exps.begin(), itEnd = _exps.end(); it != itEnd ; ++it)
-        {
-            delete *it;
-        }
     }
 
     virtual SeqExp* clone()
index 3f97ea4..bbce8a5 100644 (file)
@@ -14,7 +14,6 @@
 #define AST_STRINGEXP_HXX
 
 #include "constexp.hxx"
-#include "string.hxx"
 
 namespace ast
 {
@@ -24,23 +23,24 @@ namespace ast
 class StringExp : public ConstExp
 {
 public:
-    StringExp (const Location& location,
-               std::wstring value)
+    StringExp (const Location& location, std::wstring value)
         : ConstExp (location),
-          _value (value),
-          _bigString (NULL)
+          _value (value)
     {
     }
+
+    StringExp (const Location& location, types::InternalType* value)
+        : ConstExp (location),
+          _value (L"")
+    {
+        setConstant(value);
+    }
+
     /** \brief Destroy an string Exp node.
     **
     ** Delete value (see constructor). */
     virtual ~StringExp ()
     {
-        if (_bigString)
-        {
-            _bigString->DecreaseRef();
-            _bigString->killMe();
-        }
     }
     /** \} */
 
@@ -65,25 +65,6 @@ public:
     }
     /** \} */
 
-    types::String* getBigString() const
-    {
-        return _bigString;
-    }
-
-
-    void setBigString(types::String *_pS)
-    {
-        if (_bigString)
-        {
-            _bigString->DecreaseRef();
-            _bigString->killMe();
-        }
-        _bigString = _pS;
-        _bigString->IncreaseRef();
-    }
-
-    /** \name Accessors.
-    ** \{ */
 public:
     /** \brief Return the name of the type name (read only). */
     const std::wstring getValue() const
@@ -103,7 +84,6 @@ public:
 
 protected:
     const std::wstring _value;
-    types::String* _bigString;
 };
 
 } // namespace ast
index 45f007e..393cd35 100644 (file)
@@ -46,7 +46,7 @@ public:
           _conjugate (kind)
     {
         exp.setParent(this);
-        _exps[0] = &exp;
+        _exps.push_back(&exp);
     }
 
     /** \brief Destroy a Transpose Operation Expression node.
@@ -54,7 +54,6 @@ public:
     ** Delete expression, see constructor. */
     virtual ~TransposeExp ()
     {
-        delete _exps[0];
     }
     /** \} */
 
index a114fe8..c97a239 100644 (file)
@@ -43,14 +43,12 @@ public:
     {
         tryme.setParent(this);
         catchme.setParent(this);
-        _exps[0] = &tryme;
-        _exps[1] = &catchme;
+        _exps.push_back(&tryme);
+        _exps.push_back(&catchme);
     }
 
     virtual ~TryCatchExp ()
     {
-        delete _exps[0];
-        delete _exps[1];
     }
 
     virtual TryCatchExp* clone()
index 355cbb7..28ef750 100644 (file)
@@ -54,7 +54,7 @@ public:
           _stack(NULL)
     {
         init.setParent(this);
-        _exps[0] = &init;
+        _exps.push_back(&init);
     }
 
     /** \brief Destroy a Variable Declaration node.
@@ -63,7 +63,6 @@ public:
     virtual ~VarDec()
     {
         delete &_name;
-        delete _exps[0];
     }
     /** \} */
 
index fcc300e..0000924 100644 (file)
@@ -45,8 +45,8 @@ public:
     {
         test.setParent(this);
         body.setParent(this);
-        _exps[0] = &test;
-        _exps[1] = &body;
+        _exps.push_back(&test);
+        _exps.push_back(&body);
     }
 
     /** \brief Destroy a While Expression node.
@@ -54,8 +54,6 @@ public:
     ** Delete test and body (see constructor). */
     virtual ~WhileExp ()
     {
-        delete _exps[0];
-        delete _exps[1];
     }
     /** \}*/
 
index e9aaa06..2db858a 100644 (file)
@@ -386,6 +386,15 @@ public :
     static void addReferenceModule(std::wstring _module);
     static void removeReferenceModule(std::wstring _module);
     static std::list<std::wstring> getReferenceModules();
+
+    //analyzer options
+
+private :
+    static int m_analyzerOptions;
+public :
+    static void setAnalyzerOptions(int _val);
+    static int getAnalyzerOptions(void);
+
 };
 
 #endif /* !__CONFIGVARIABLE_HXX__ */
index b62a52a..e5ad77e 100644 (file)
@@ -79,6 +79,8 @@ protected :
         return isScalar() ? IdScalarBool : IdBool;
     }
 
+    virtual ast::Exp*       getExp(const Location& loc);
+
 private :
     virtual bool            subMatrixToString(std::wostringstream& ostr, int* _piDims, int _iDims);
 
index 1b887cd..223ede3 100644 (file)
@@ -25,6 +25,7 @@
 #include "arrayof.hxx"
 #include "bool.hxx"
 #include "types_transposition.hxx"
+#include "doubleexp.hxx"
 
 namespace types
 {
@@ -267,6 +268,8 @@ public :
         return false;
     }
 
+    virtual ast::Exp*           getExp(const Location& loc);
+
 private :
     virtual bool                subMatrixToString(std::wostringstream& ostr, int* _piDims, int _iDims);
 
index 21b9dc6..7e8c931 100644 (file)
@@ -25,6 +25,7 @@ extern "C"
 #include "dynlib_ast.h"
 }
 
+#include "exp.hxx" // for invoke
 #include "visitor.hxx" // for invoke
 #include "callexp.hxx"
 #include "localization.hxx"
@@ -212,6 +213,10 @@ public :
         return getTypeStr();
     }
     virtual InternalType*           clone(void) = 0;
+    virtual ast::Exp*               getExp(const Location &loc)
+    {
+        return NULL;
+    }
 
 #ifdef _SCILAB_DEBUGREF_
     inline void _killme(const char * f, int l)
index 4b7f5c5..4e8005e 100644 (file)
@@ -99,6 +99,8 @@ public :
         return type_traits::transpose(*this, out);
     }
 
+    virtual ast::Exp*       getExp(const Location& loc);
+
 private :
     void                    deleteString(int _iRows, int _iCols);
     void                    deleteString(int _iPos);
index 0ffd5cc..f1321ac 100644 (file)
@@ -414,4 +414,15 @@ void DebugVisitor::visit(const ListExp &e)
     e.getEnd().accept(*this);
     DEBUG_END_NODE();
 }
+
+void DebugVisitor::visit(const OptimizedExp &e)
+{
+    e.getOriginal()->accept(*this);
+}
+
+void DebugVisitor::visit(const DAXPYExp &e)
+{
+    e.getOriginal()->accept(*this);
+}
+
 }
index 4a0a548..e821153 100644 (file)
@@ -31,22 +31,22 @@ void MacrovarVisitor::visit(const CallExp &e)
     exps_t args = e.getArgs();
     for (exps_t::const_iterator it = args.begin (), itEnd = args.end(); it != itEnd; ++it)
     {
-        (*it)->accept (*this);
+        (*it)->getOriginal()->accept (*this);
         add();
     }
 }
 
 void MacrovarVisitor::visit(const AssignExp &e)
 {
-    e.getLeftExp().accept (*this);
+    e.getLeftExp().getOriginal()->accept (*this);
     add();
-    e.getRightExp().accept (*this);
+    e.getRightExp().getOriginal()->accept (*this);
     add();
 }
 
 void MacrovarVisitor::visit (const VarDec  &e)
 {
-    e.getInit().accept(*this);
+    e.getInit().getOriginal()->accept(*this);
     add(m_local);
 }
 
index b339dac..91a7492 100644 (file)
@@ -27,14 +27,14 @@ void PrintVisitor::visit (const MatrixExp &e)
     for (i = lines.begin() ; i != lines.end() ; )
     {
         j = i;
-        if (++j == e.getLines().end())
+        if (++j == lines.end())
         {
             this->is_last_matrix_line = true;
         }
-        (*i)->accept (*this);
+        (*i)->getOriginal()->accept(*this);
         ++i;
 
-        if (e.getLines().size() > 1)
+        if (lines.size() > 1)
         {
             *ostr << std::endl;
             this->apply_indent();
@@ -52,12 +52,12 @@ void PrintVisitor::visit (const MatrixLineExp &e)
     ast::exps_t cols = e.getColumns();
     for (i = cols.begin() ; i != cols.end() ; )
     {
-        (*i)->accept (*this);
+        (*i)->getOriginal()->accept(*this);
         if (dynamic_cast<ast::CommentExp*>(*i) != NULL)
         {
             last_column_is_comment = true;
         }
-        if (++i != e.getColumns().end())
+        if (++i != cols.end())
         {
             if (dynamic_cast<ast::CommentExp*>(*i) == NULL)
             {
@@ -84,8 +84,8 @@ void PrintVisitor::visit (const CellExp &e)
     ast::exps_t lines = e.getLines();
     for (i = lines.begin() ; i != lines.end() ; )
     {
-        (*i)->accept (*this);
-        if (++i != e.getLines().end())
+        (*i)->getOriginal()->accept(*this);
+        if (++i != lines.end())
         {
             *ostr << SCI_LINE_SEPARATOR << std::endl;
             this->apply_indent();
@@ -166,10 +166,10 @@ void PrintVisitor::visit (const DollarVar &/*e*/)
 void PrintVisitor::visit (const ArrayListVar &e)
 {
     exps_t vars = e.getVars();
-    for (exps_t::const_iterator it = vars.begin (), itEnd = vars.end(); it != itEnd; ++it)
+    for (exps_t::const_iterator it = vars.begin (), itEnd = vars.end(); it != itEnd; /**/)
     {
-        (*it)->accept (*this);
-        if (++it != e.getVars().end())
+        (*it)->getOriginal()->accept(*this);
+        if (++it != itEnd)
         {
             *ostr << ", ";
         }
@@ -182,9 +182,9 @@ void PrintVisitor::visit (const ArrayListVar &e)
 
 void PrintVisitor::visit (const FieldExp &e)
 {
-    e.getHead()->accept(*this);
+    e.getHead()->getOriginal()->accept(*this);
     *ostr << SCI_FVAR_SEPARATOR;
-    e.getTail()->accept(*this);
+    e.getTail()->getOriginal()->accept(*this);
 }
 
 void PrintVisitor::visit(const OpExp &e)
@@ -200,7 +200,7 @@ void PrintVisitor::visit(const OpExp &e)
     {
         // Getting Left Operand
         this->enable_force_parenthesis();
-        e.getLeft().accept(*this);
+        e.getLeft().getOriginal()->accept(*this);
         this->set_force_parenthesis(old_force_parenthesis);
         *ostr << " ";
     }
@@ -287,7 +287,7 @@ void PrintVisitor::visit(const OpExp &e)
 
     // Now getting right operand
     this->enable_force_parenthesis();
-    e.getRight().accept(*this);
+    e.getRight().getOriginal()->accept(*this);
     this->set_force_parenthesis(old_force_parenthesis);
 
     if (force_parenthesis)
@@ -307,7 +307,7 @@ void PrintVisitor::visit(const LogicalOpExp &e)
 
     // Getting Left Operand
     this->enable_force_parenthesis();
-    e.getLeft().accept(*this);
+    e.getLeft().getOriginal()->accept(*this);
     this->set_force_parenthesis(old_force_parenthesis);
 
     *ostr << " ";
@@ -334,7 +334,7 @@ void PrintVisitor::visit(const LogicalOpExp &e)
 
     // Now getting right operand
     this->enable_force_parenthesis();
-    e.getRight().accept(*this);
+    e.getRight().getOriginal()->accept(*this);
     this->set_force_parenthesis(old_force_parenthesis);
 
     if (force_parenthesis)
@@ -345,20 +345,20 @@ void PrintVisitor::visit(const LogicalOpExp &e)
 
 void PrintVisitor::visit (const AssignExp  &e)
 {
-    e.getLeftExp().accept (*this);
+    e.getLeftExp().getOriginal()->accept(*this);
     *ostr << " " << SCI_ASSIGN << " ";
-    e.getRightExp().accept (*this);
+    e.getRightExp().getOriginal()->accept(*this);
 }
 
 void PrintVisitor::visit(const CellCallExp &e)
 {
-    e.getName().accept (*this);
+    e.getName().getOriginal()->accept(*this);
     *ostr << SCI_OPEN_CELL;
     exps_t args = e.getArgs();
-    for (exps_t::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)->accept (*this);
-        if (++it != e.getArgs().end ())
+        (*it)->getOriginal()->accept(*this);
+        if (++it != itEnd)
         {
             *ostr << SCI_COMMA << " ";
         }
@@ -368,15 +368,15 @@ void PrintVisitor::visit(const CellCallExp &e)
 
 void PrintVisitor::visit(const CallExp &e)
 {
-    e.getName().accept (*this);
+    e.getName().getOriginal()->accept(*this);
     *ostr << SCI_OPEN_CALL;
     std::list<Exp *>::const_iterator   i;
 
     exps_t args = e.getArgs();
-    for (exps_t::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)->accept (*this);
-        if (++it != e.getArgs().end())
+        (*it)->getOriginal()->accept(*this);
+        if (++it != itEnd)
         {
             *ostr << SCI_COMMA << " ";
         }
@@ -388,18 +388,18 @@ void PrintVisitor::visit (const IfExp  &e)
 {
     *ostr << SCI_IF;
     *ostr << " " << SCI_OPEN_TEST;
-    e.getTest().accept(*this);
+    e.getTest().getOriginal()->accept(*this);
     *ostr << SCI_CLOSE_TEST << " ";
     *ostr << SCI_THEN << std::endl;
     ++indent;
-    e.getThen().accept(*this);
+    e.getThen().getOriginal()->accept(*this);
     --indent;
     if (e.hasElse())
     {
         this->apply_indent();
         *ostr << SCI_ELSE << std::endl;
         ++indent;
-        e.getElse().accept(*this);
+        e.getElse().getOriginal()->accept(*this);
         --indent;
     }
     this->apply_indent();
@@ -410,12 +410,12 @@ void PrintVisitor::visit (const TryCatchExp  &e)
 {
     *ostr << SCI_TRY << std::endl;
     ++indent;
-    e.getTry().accept(*this);
+    e.getTry().getOriginal()->accept(*this);
     --indent;
     this->apply_indent();
     *ostr << SCI_CATCH << std::endl;
     ++indent;
-    e.getCatch().accept(*this);
+    e.getCatch().getOriginal()->accept(*this);
     --indent;
     this->apply_indent();
     *ostr << SCI_ENDTRY;
@@ -425,10 +425,10 @@ void PrintVisitor::visit (const WhileExp  &e)
 {
     *ostr << SCI_WHILE;
     *ostr << " " << SCI_OPEN_TEST;
-    e.getTest().accept (*this);
+    e.getTest().getOriginal()->accept(*this);
     *ostr << SCI_CLOSE_TEST << " " << SCI_DO << std::endl;
     ++indent;
-    e.getBody().accept (*this);
+    e.getBody().getOriginal()->accept(*this);
     --indent;
     this->apply_indent();
     *ostr << SCI_ENDWHILE;
@@ -438,11 +438,11 @@ void PrintVisitor::visit (const ForExp  &e)
 {
     *ostr << SCI_FOR;
     *ostr << " " << SCI_OPEN_TEST;
-    e.getVardec().accept(*this);
+    e.getVardec().getOriginal()->accept(*this);
     *ostr << SCI_CLOSE_TEST << " ";
     *ostr << SCI_DO << std::endl;
     ++indent;
-    e.getBody().accept (*this);
+    e.getBody().getOriginal()->accept(*this);
     --indent;
     this->apply_indent();
     *ostr << SCI_ENDFOR;
@@ -464,7 +464,7 @@ void PrintVisitor::visit (const ReturnExp &e)
     if (!e.isGlobal())
     {
         *ostr << " " ;
-        e.getExp().accept(*this);
+        e.getExp().getOriginal()->accept(*this);
     }
 }
 
@@ -472,20 +472,20 @@ void PrintVisitor::visit (const SelectExp &e)
 {
     *ostr << SCI_SELECT;
     *ostr << " " << SCI_OPEN_TEST;
-    e.getSelect()->accept(*this);
+    e.getSelect()->getOriginal()->accept(*this);
     *ostr << SCI_CLOSE_TEST << std::endl;
     ++indent;
     exps_t* cases = e.getCases();
     for (exps_t::iterator it = cases->begin(), itEnd = cases->end(); it !=  itEnd ; ++it)
     {
-        (*it)->accept (*this);
+        (*it)->getOriginal()->accept(*this);
     }
     if (e.hasDefault())
     {
         this->apply_indent();
         *ostr << SCI_DEFAULT_CASE << std::endl;
         ++indent;
-        e.getDefaultCase()->accept(*this);
+        e.getDefaultCase()->getOriginal()->accept(*this);
         --indent;
     }
     --indent;
@@ -498,10 +498,10 @@ void PrintVisitor::visit (const CaseExp &e)
     this->apply_indent();
     *ostr << SCI_CASE;
     *ostr << " " << SCI_OPEN_TEST;
-    e.getTest()->accept(*this);
+    e.getTest()->getOriginal()->accept(*this);
     *ostr << SCI_CLOSE_TEST << std::endl;
     indent++;
-    e.getBody()->accept(*this);
+    e.getBody()->getOriginal()->accept(*this);
     indent--;
 }
 
@@ -510,7 +510,7 @@ void PrintVisitor::visit (const SeqExp  &e)
     for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
     {
         this->apply_indent();
-        (*it)->accept (*this);
+        (*it)->getOriginal()->accept(*this);
         if (!(*it)->isVerbose())
         {
             *ostr << ";";
@@ -522,10 +522,10 @@ void PrintVisitor::visit (const SeqExp  &e)
 void PrintVisitor::visit (const ArrayListExp  &e)
 {
     *ostr << SCI_LPAREN;
-    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
+    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; /**/)
     {
-        (*it)->accept (*this);
-        if (++it != e.getExps().end ())
+        (*it)->getOriginal()->accept(*this);
+        if (++it != itEnd)
         {
             *ostr << SCI_COMMA << " ";
         }
@@ -536,10 +536,11 @@ void PrintVisitor::visit (const ArrayListExp  &e)
 void PrintVisitor::visit (const AssignListExp  &e)
 {
     *ostr << SCI_LBRACK;
-    for (exps_t::const_iterator it = e.getExps().begin (), itEnd = e.getExps().end(); it != itEnd; ++it)
+    ast::exps_t exps = e.getExps();
+    for (exps_t::const_iterator it = exps.begin (), itEnd = exps.end(); it != itEnd; /**/)
     {
-        (*it)->accept (*this);
-        if (++it != e.getExps().end ())
+        (*it)->getOriginal()->accept(*this);
+        if (++it != itEnd)
         {
             *ostr << SCI_COMMA << " ";
         }
@@ -554,14 +555,14 @@ void PrintVisitor::visit (const NotExp &e)
 {
     *ostr << SCI_NOT;
     *ostr << SCI_LPAREN;
-    e.getExp().accept (*this);
+    e.getExp().getOriginal()->accept(*this);
     *ostr << SCI_RPAREN;
 }
 
 void PrintVisitor::visit (const TransposeExp &e)
 {
     *ostr << SCI_LPAREN;
-    e.getExp().accept (*this);
+    e.getExp().getOriginal()->accept(*this);
     *ostr << SCI_RPAREN;
     if (e.getConjugate() == TransposeExp::_Conjugate_)
     {
@@ -581,7 +582,7 @@ void PrintVisitor::visit (const VarDec  &e)
 {
     *ostr << e.getSymbol().getName();
     *ostr << SCI_ASSIGN;
-    e.getInit().accept (*this);
+    e.getInit().getOriginal()->accept(*this);
 }
 
 void PrintVisitor::visit (const FunctionDec  &e)
@@ -594,7 +595,7 @@ void PrintVisitor::visit (const FunctionDec  &e)
         *ostr << SCI_OPEN_RETURNS;
     }
 
-    e.getReturns().accept(*this);
+    e.getReturns().getOriginal()->accept(*this);
 
     if (e.getReturns().getAs<ArrayListVar>()->getVars().size() > 1)
     {
@@ -612,12 +613,12 @@ void PrintVisitor::visit (const FunctionDec  &e)
 
     // Then get function args
     *ostr << SCI_OPEN_ARGS;
-    e.getArgs().accept(*this);
+    e.getArgs().getOriginal()->accept(*this);
     *ostr << SCI_CLOSE_ARGS << std::endl;
 
     // Now print function body
     ++indent;
-    e.getBody().accept(*this);
+    e.getBody().getOriginal()->accept(*this);
     --indent;
     this->apply_indent();
 
@@ -631,18 +632,29 @@ void PrintVisitor::visit (const FunctionDec  &e)
 void PrintVisitor::visit(const ListExp &e)
 {
     *ostr << SCI_LPAREN;
-    e.getStart().accept(*this);
+    e.getStart().getOriginal()->accept(*this);
     if (e.hasExplicitStep())
     {
         *ostr << SCI_IMPLICIT_LIST;
-        e.getStep().accept(*this);
+        e.getStep().getOriginal()->accept(*this);
     }
     *ostr << SCI_IMPLICIT_LIST;
-    e.getEnd().accept(*this);
+    e.getEnd().getOriginal()->accept(*this);
     *ostr << SCI_RPAREN;
 }
 /** \} */
 
+
+void PrintVisitor::visit(const OptimizedExp &e)
+{
+    e.getOriginal()->accept(*this);
+}
+
+void PrintVisitor::visit(const DAXPYExp &e)
+{
+    e.getOriginal()->accept(*this);
+}
+
 void PrintVisitor::apply_indent()
 {
     int i;
index cf0e5e6..64c472b 100644 (file)
@@ -208,6 +208,10 @@ void RunVisitorT<T>::visitprivate(const OpExp &e)
         throw error;
     }
 
+    if (e.getDecorator().res.isConstant())
+    {
+
+    }
 }
 
 template<class T>
index 324bb16..4ca16f0 100644 (file)
@@ -35,8 +35,11 @@ extern "C"
 {
 #include "sciprint.h"
 #include "os_swprintf.h"
+#include "elem_common.h"
 }
 
+
+
 namespace ast
 {
 template <class T>
@@ -1160,6 +1163,183 @@ void RunVisitorT<T>::visitprivate(const ListExp &e)
     cleanIn(in, out);
 }
 
+template <class T>
+void RunVisitorT<T>::visitprivate(const OptimizedExp &e)
+{
+}
+
+template <class T>
+void RunVisitorT<T>::visitprivate(const DAXPYExp &e)
+{
+    InternalType* pIT = NULL;
+    Double* ad = NULL;
+    int ar = 0;
+    int ac = 0;
+
+    Double* xd = NULL;
+    int xr = 0;
+    int xc = 0;
+
+    Double* yd = NULL;
+    int yr = 0;
+    int yc = 0;
+
+    //check types and dimensions
+
+    //y must be double
+    const Exp &ye = e.getY();
+    ye.accept(*this);
+    pIT = getResult();
+    if (pIT->isDouble())
+    {
+        yd = pIT->getAs<Double>();
+        if (yd->getDims() == 2 && yd->isComplex() == false)
+        {
+            yr = yd->getRows();
+            yc = yd->getCols();
+        }
+        else
+        {
+            yd->killMe();
+            e.getOriginal()->accept(*this);
+            return;
+        }
+    }
+    else
+    {
+        pIT->killMe();
+        e.getOriginal()->accept(*this);
+        return;
+    }
+
+    //x
+    const Exp &xe = e.getX();
+    xe.accept(*this);
+    pIT = getResult();
+
+    if (pIT->isDouble())
+    {
+        xd = pIT->getAs<Double>();
+        if (xd->isScalar() && xd->isComplex() == false)
+        {
+            // x become a
+            ad = xd;
+            ar = 1;
+            ac = 1;
+        }
+        else if (xd->getDims() == 2 && xd->isComplex() == false)
+        {
+            xr = xd->getRows();
+            xc = xd->getCols();
+        }
+        else
+        {
+            yd->killMe();
+            xd->killMe();
+            e.getOriginal()->accept(*this);
+            return;
+        }
+    }
+    else
+    {
+        pIT->killMe();
+        yd->killMe();
+        e.getOriginal()->accept(*this);
+        return;
+    }
+
+    const Exp &ae = e.getA();
+    ae.accept(*this);
+    pIT = getResult();
+
+    if (pIT->isDouble())
+    {
+        if (ad)
+        {
+            xd = pIT->getAs<Double>();
+            //X is scalar it become A
+            //now use A as X
+            if (xd->getDims() == 2 && xd->isComplex() == false)
+            {
+                xr = xd->getRows();
+                xc = xd->getCols();
+            }
+            else
+            {
+                yd->killMe();
+                xd->killMe();
+                ad->killMe();
+                e.getOriginal()->accept(*this);
+                return;
+            }
+        }
+        else
+        {
+            //a is a and it must be scalar
+            ad = pIT->getAs<Double>();
+            if (ad->isScalar() && ad->isComplex() == false)
+            {
+                ar = 1;
+                ac = 1;
+            }
+            else
+            {
+                yd->killMe();
+                xd->killMe();
+                ad->killMe();
+                e.getOriginal()->accept(*this);
+                return;
+            }
+        }
+    }
+    else
+    {
+        pIT->killMe();
+        yd->killMe();
+        xd->killMe();
+        e.getOriginal()->accept(*this);
+        return;
+    }
+
+    if (ad && xd && yd)
+    {
+        if ( ac == 1 &&
+                ar == 1 &&
+                xr == yr &&
+                xc == yc)
+        {
+            //go !
+            int one = 1;
+            int size = xc * xr;
+            Double* od = (Double*)yd->clone();
+            C2F(daxpy)(&size, ad->get(), xd->get(), &one, od->get(), &one);
+            setResult(od);
+            yd->killMe();
+            xd->killMe();
+            ad->killMe();
+            return;
+        }
+    }
+
+    if (yd)
+    {
+        yd->killMe();
+    }
+
+    if (xd)
+    {
+        xd->killMe();
+    }
+
+    if (ad)
+    {
+        ad->killMe();
+    }
+
+    e.getOriginal()->accept(*this);
+    return;
+}
+
 #include "run_CallExp.cpp"
 #include "run_MatrixExp.cpp"
 #include "run_OpExp.cpp"
index 6fe8005..fe6b9db 100644 (file)
@@ -321,7 +321,7 @@ expressions                     { ParserSingleInstance::setTree($1); }
 | expressionLineBreak           {
                                   ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                      tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty body"));
+                                      tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty body");
                                   #endif
                                   ParserSingleInstance::setTree(new ast::SeqExp(@$, tmp));
                                  delete $1;
@@ -329,7 +329,7 @@ expressions                     { ParserSingleInstance::setTree($1); }
 | /* Epsilon */                 {
                                   ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                      tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty body"));
+                                      tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty body")));
                                   #endif
                                   ParserSingleInstance::setTree(new ast::SeqExp(@$, tmp));
                                 }
@@ -357,14 +357,14 @@ recursiveExpression                             {
 | expression                                    {
                                                   ast::exps_t tmp;
                                                   $1->setVerbose(true);
-                                                  tmp[0] = $1;
+                                                  tmp.push_back($1);
                                                   $$ = new ast::SeqExp(@$, tmp);
                                                 }
 | expression COMMENT                            {
                                                   ast::exps_t tmp;
                                                   $1->setVerbose(true);
-                                                  tmp[0] = $1;
-                                                  tmp[1] = new ast::CommentExp(@2, $2);
+                                                  tmp.push_back($1);
+                                                  tmp.push_back(new ast::CommentExp(@2, $2));
                                                   $$ = new ast::SeqExp(@$, tmp);
                                                 }
 ;
@@ -466,7 +466,7 @@ implicitFunctionCall implicitCallable               {
                                                }
 | ID implicitCallable                          {
                                                  ast::exps_t tmp;
-                                                 tmp[0] = $2;
+                                                 tmp.push_back($2);
                                                  $$ = new ast::CallExp(@$, *new ast::SimpleVar(@1, *new symbol::Symbol(*$1)), tmp);
                                                  delete $1;
                                                }
@@ -646,7 +646,7 @@ variable                    {
 functionDeclaration :
 FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$2));
+                                 tmp.push_back(new ast::SimpleVar(@2, *new symbol::Symbol(*$2)));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$4),
                                                            *new ast::ArrayListVar(@5, *$5),
@@ -683,7 +683,7 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                }
 | FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody END {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$2));
+                                 tmp.push_back(new ast::SimpleVar(@2, *new symbol::Symbol(*$2)));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$4),
                                                            *new ast::ArrayListVar(@5, *$5),
@@ -720,7 +720,7 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                }
 | HIDDENFUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$2));
+                                 tmp.push_back(new ast::SimpleVar(@2, *new symbol::Symbol(*$2)));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$4),
                                                            *new ast::ArrayListVar(@5, *$5),
@@ -757,7 +757,7 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                }
 | HIDDENFUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody END {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$2));
+                                 tmp.push_back(new ast::SimpleVar(@2, *new symbol::Symbol(*$2)));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$4),
                                                            *new ast::ArrayListVar(@5, *$5),
@@ -794,7 +794,7 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                }
 | HIDDEN FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody ENDFUNCTION {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar(@2, *new symbol::Symbol(*$3));
+                                 tmp.push_back(new ast::SimpleVar(@2, *new symbol::Symbol(*$3)));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$5),
                                                            *new ast::ArrayListVar(@6, *$6),
@@ -831,7 +831,7 @@ FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak func
                                }
 | HIDDEN FUNCTION ID ASSIGN ID functionDeclarationArguments functionDeclarationBreak functionBody END {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar(@3, *new symbol::Symbol(*$3));
+                                 tmp.push_back(new ast::SimpleVar(@3, *new symbol::Symbol(*$3)));
                                  $$ = new ast::FunctionDec(@$,
                                                            *new symbol::Symbol(*$5),
                                                            *new ast::ArrayListVar(@6, *$6),
@@ -924,7 +924,7 @@ expressions                 { $$ = $1; }
 | /* Epsilon */                        {
                                  ast::exps_t tmp;
                                  #ifdef BUILD_DEBUG_AST
-                                   tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty function body"));
+                                   tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty function body")));
                                  #endif
                                  $$ = new ast::SeqExp(@$, tmp);
                                }
@@ -1199,12 +1199,12 @@ LBRACE matrixOrCellLines RBRACE                                 { $$ = new ast::CellExp(@$, *$2); }
                                                                }
 | LBRACE matrixOrCellColumns RBRACE                                    {
                                                                  ast::exps_t tmp;
-                                                                 tmp[0] = new ast::MatrixLineExp(@2, *$2);
+                                                                 tmp.push_back(new ast::MatrixLineExp(@2, *$2));
                                                                  $$ = new ast::CellExp(@$, tmp);
                                                                }
 | LBRACE EOL matrixOrCellColumns RBRACE                                {
                                                                  ast::exps_t tmp;
-                                                                 tmp[0] = new ast::MatrixLineExp(@3, *$3);
+                                                                 tmp.push_back(new ast::MatrixLineExp(@3, *$3));
                                                                  $$ = new ast::CellExp(@$, tmp);
                                 }
 | LBRACE EOL RBRACE                                            { ast::exps_t tmp;$$ = new ast::CellExp(@$, tmp); }
@@ -1229,12 +1229,12 @@ LBRACK matrixOrCellLines RBRACK                                 { $$ = new ast::MatrixExp(@$, *$2); }
                                                                }
 | LBRACK matrixOrCellColumns RBRACK                                    {
                                                                  ast::exps_t tmp;
-                                                                 tmp[0] = new ast::MatrixLineExp(@2, *$2);
+                                                                 tmp.push_back(new ast::MatrixLineExp(@2, *$2));
                                                                  $$ = new ast::MatrixExp(@$, tmp);
                                                                }
 | LBRACK EOL matrixOrCellColumns RBRACK                                {
                                                                  ast::exps_t tmp;
-                                                                 tmp[0] = new ast::MatrixLineExp(@3, *$3);
+                                                                 tmp.push_back(new ast::MatrixLineExp(@3, *$3));
                                                                  $$ = new ast::MatrixExp(@$, tmp);
                                                                }
 | LBRACK EOL RBRACK                                            { ast::exps_t tmp;$$ = new ast::MatrixExp(@$, tmp); }
@@ -1405,7 +1405,7 @@ expressions                             { $$ = $1; }
 | /* Epsilon */                         {
     ast::exps_t tmp;
     #ifdef BUILD_DEBUG_AST
-    tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty then body"));
+    tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty then body")));
     #endif
     $$ = new ast::SeqExp(@$, tmp);
                                         }
@@ -1420,7 +1420,7 @@ expressions                             { $$ = $1; }
 | /* Epsilon */                         {
                                          #ifdef BUILD_DEBUG_AST
                                            ast::exps_t tmp;
-                                           tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty else body"));
+                                           tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty else body")));
                                            $$ = new ast::SeqExp(@$, tmp);
                                          #else
                                            $$ = NULL;
@@ -1473,25 +1473,25 @@ ELSE                                                    { /* !! Do Nothing !! */ }
 elseIfControl :
 ELSEIF condition then thenBody                                         {
                                                                                ast::exps_t tmp;
-                                                                               tmp[0] = new ast::IfExp(@$, *$2, *$4);
+                                                                               tmp.push_back(new ast::IfExp(@$, *$2, *$4));
                                                                                $$ = new ast::SeqExp(@$, tmp);
                                                                        }
 | ELSEIF condition then thenBody else elseBody                         {
                                                                                ast::exps_t tmp;
                                                                                if( $6 == NULL)
                                         {
-                                            tmp[0] = new ast::IfExp(@$, *$2, *$4);
+                                            tmp.push_back(new ast::IfExp(@$, *$2, *$4));
                                         }
                                         else
                                         {
-                                            tmp[0] = new ast::IfExp(@$, *$2, *$4, *$6);
+                                            tmp.push_back(new ast::IfExp(@$, *$2, *$4, *$6));
                                         }
                                                                                $$ = new ast::SeqExp(@$, tmp);
 
                                                                        }
 | ELSEIF condition then thenBody elseIfControl                         {
                                                                                ast::exps_t tmp;
-                                                                               tmp[0] = new ast::IfExp(@$, *$2, *$4, *$5);
+                                                                               tmp.push_back(new ast::IfExp(@$, *$2, *$4, *$5));
                                                                                $$ = new ast::SeqExp(@$, tmp);
                                                                        }
 ;
@@ -1590,7 +1590,7 @@ expressions                               { $$ = $1; }
 | /* Epsilon */                        {
                                                  ast::exps_t tmp;
                                                #ifdef BUILD_DEBUG_AST
-                                                 tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty case body"));
+                                                 tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty case body")));
                                                #endif
                                                  $$ = new ast::SeqExp(@$, tmp);
                                                }
@@ -1654,7 +1654,7 @@ expressions                       { $$ = $1; }
 | /* Epsilon */                        {
                                  ast::exps_t tmp;
                                  #ifdef BUILD_DEBUG_AST
-                                   tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty for body"));
+                                   tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty for body")));
                                  #endif
                                  $$ = new ast::SeqExp(@$, tmp);
                                }
@@ -1677,7 +1677,7 @@ expressions             { $$ = $1; }
 | /* Epsilon */                        {
                           ast::exps_t tmp;
                           #ifdef BUILD_DEBUG_AST
-                            tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty while body"));
+                            tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty while body")));
                           #endif
                           $$ = new ast::SeqExp(@$, tmp);
                         }
@@ -1717,7 +1717,7 @@ TRY catchBody CATCH catchBody END                 { $$ =new ast::TryCatchExp(@$,
 | TRY catchBody END                               {
                                                     ast::exps_t tmp;
                                                     #ifdef BUILD_DEBUG_AST
-                                                      tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty catch body"));
+                                                      tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty catch body")));
                                                     #endif
                                                     $$ =new ast::TryCatchExp(@$, *$2, *new ast::SeqExp(@$, tmp));
                                                   }
@@ -1742,7 +1742,7 @@ expressions                     { $$ = $1; }
 | /* Epsilon */                 {
                                   ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                    tmp[0] = new ast::CommentExp(@$, new std::wstring(L"Empty catch body"));
+                                    tmp.push_back(new ast::CommentExp(@$, new std::wstring(L"Empty catch body")));
                                   #endif
                                   $$ = new ast::SeqExp(@$, tmp);
                                 }
index 0c15e78..210101f 100644 (file)
@@ -2704,7 +2704,7 @@ yyreduce:
     {
                                   ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                      tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty body"));
+                                      tmp.push_back(new ast::CommentExp((yyloc), new std::wstring(L"Empty body");
                                   #endif
                                   ParserSingleInstance::setTree(new ast::SeqExp((yyloc), tmp));
                                  delete (yyvsp[0].mute);
@@ -2717,7 +2717,7 @@ yyreduce:
     {
                                   ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                      tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty body"));
+                                      tmp.push_back(new ast::CommentExp((yyloc), new std::wstring(L"Empty body")));
                                   #endif
                                   ParserSingleInstance::setTree(new ast::SeqExp((yyloc), tmp));
                                 }
@@ -2758,7 +2758,7 @@ yyreduce:
     {
                                                   ast::exps_t tmp;
                                                   (yyvsp[0].t_exp)->setVerbose(true);
-                                                  tmp[0] = (yyvsp[0].t_exp);
+                                                  tmp.push_back((yyvsp[0].t_exp));
                                                   (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                                 }
 
@@ -2769,8 +2769,8 @@ yyreduce:
     {
                                                   ast::exps_t tmp;
                                                   (yyvsp[-1].t_exp)->setVerbose(true);
-                                                  tmp[0] = (yyvsp[-1].t_exp);
-                                                  tmp[1] = new ast::CommentExp((yylsp[0]), (yyvsp[0].comment));
+                                                  tmp.push_back((yyvsp[-1].t_exp));
+                                                  tmp.push_back(new ast::CommentExp((yylsp[0]), (yyvsp[0].comment)));
                                                   (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                                 }
 
@@ -2977,7 +2977,7 @@ yyreduce:
 
     {
                                                  ast::exps_t tmp;
-                                                 tmp[0] = (yyvsp[0].t_string_exp);
+                                                 tmp.push_back((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);
                                                }
@@ -3280,7 +3280,7 @@ yyreduce:
 
     {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
+                                 tmp.push_back(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)),
@@ -3337,7 +3337,7 @@ yyreduce:
 
     {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
+                                 tmp.push_back(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)),
@@ -3394,7 +3394,7 @@ yyreduce:
 
     {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
+                                 tmp.push_back(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)),
@@ -3451,7 +3451,7 @@ yyreduce:
 
     {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
+                                 tmp.push_back(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)),
@@ -3508,7 +3508,7 @@ yyreduce:
 
     {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar((yylsp[-7]), *new symbol::Symbol(*(yyvsp[-6].str)));
+                                 tmp.push_back(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)),
@@ -3565,7 +3565,7 @@ yyreduce:
 
     {
                                  ast::exps_t tmp;
-                                 tmp[0] = new ast::SimpleVar((yylsp[-6]), *new symbol::Symbol(*(yyvsp[-6].str)));
+                                 tmp.push_back(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)),
@@ -3703,7 +3703,7 @@ yyreduce:
     {
                                  ast::exps_t tmp;
                                  #ifdef BUILD_DEBUG_AST
-                                   tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty function body"));
+                                   tmp.push_back(new ast::CommentExp((yyloc), new std::wstring(L"Empty function body")));
                                  #endif
                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                }
@@ -4504,7 +4504,7 @@ yyreduce:
 
     {
                                                                  ast::exps_t tmp;
-                                                                 tmp[0] = new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp));
+                                                                 tmp.push_back(new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp)));
                                                                  (yyval.t_cell_exp) = new ast::CellExp((yyloc), tmp);
                                                                }
 
@@ -4514,7 +4514,7 @@ yyreduce:
 
     {
                                                                  ast::exps_t tmp;
-                                                                 tmp[0] = new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp));
+                                                                 tmp.push_back(new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp)));
                                                                  (yyval.t_cell_exp) = new ast::CellExp((yyloc), tmp);
                                 }
 
@@ -4566,7 +4566,7 @@ yyreduce:
 
     {
                                                                  ast::exps_t tmp;
-                                                                 tmp[0] = new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp));
+                                                                 tmp.push_back(new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp)));
                                                                  (yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), tmp);
                                                                }
 
@@ -4576,7 +4576,7 @@ yyreduce:
 
     {
                                                                  ast::exps_t tmp;
-                                                                 tmp[0] = new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp));
+                                                                 tmp.push_back(new ast::MatrixLineExp((yylsp[-1]), *(yyvsp[-1].t_list_exp)));
                                                                  (yyval.t_matrix_exp) = new ast::MatrixExp((yyloc), tmp);
                                                                }
 
@@ -4892,7 +4892,7 @@ yyreduce:
     {
     ast::exps_t tmp;
     #ifdef BUILD_DEBUG_AST
-    tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty then body"));
+    tmp.push_back(new ast::CommentExp((yyloc), new std::wstring(L"Empty then body")));
     #endif
     (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                         }
@@ -4910,7 +4910,7 @@ yyreduce:
     {
                                          #ifdef BUILD_DEBUG_AST
                                            ast::exps_t tmp;
-                                           tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty else body"));
+                                           tmp.push_back(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;
@@ -5025,7 +5025,7 @@ yyreduce:
 
     {
                                                                                ast::exps_t tmp;
-                                                                               tmp[0] = new ast::IfExp((yyloc), *(yyvsp[-2].t_exp), *(yyvsp[0].t_seq_exp));
+                                                                               tmp.push_back(new ast::IfExp((yyloc), *(yyvsp[-2].t_exp), *(yyvsp[0].t_seq_exp)));
                                                                                (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                                                        }
 
@@ -5037,11 +5037,11 @@ yyreduce:
                                                                                ast::exps_t tmp;
                                                                                if( (yyvsp[0].t_seq_exp) == NULL)
                                         {
-                                            tmp[0] = new ast::IfExp((yyloc), *(yyvsp[-4].t_exp), *(yyvsp[-2].t_seq_exp));
+                                            tmp.push_back(new ast::IfExp((yyloc), *(yyvsp[-4].t_exp), *(yyvsp[-2].t_seq_exp)));
                                         }
                                         else
                                         {
-                                            tmp[0] = new ast::IfExp((yyloc), *(yyvsp[-4].t_exp), *(yyvsp[-2].t_seq_exp), *(yyvsp[0].t_seq_exp));
+                                            tmp.push_back(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);
 
@@ -5053,7 +5053,7 @@ yyreduce:
 
     {
                                                                                ast::exps_t tmp;
-                                                                               tmp[0] = new ast::IfExp((yyloc), *(yyvsp[-3].t_exp), *(yyvsp[-1].t_seq_exp), *(yyvsp[0].t_seq_exp));
+                                                                               tmp.push_back(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);
                                                                        }
 
@@ -5244,7 +5244,7 @@ yyreduce:
     {
                                                  ast::exps_t tmp;
                                                #ifdef BUILD_DEBUG_AST
-                                                 tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty case body"));
+                                                 tmp.push_back(new ast::CommentExp((yyloc), new std::wstring(L"Empty case body")));
                                                #endif
                                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                                }
@@ -5406,7 +5406,7 @@ yyreduce:
     {
                                  ast::exps_t tmp;
                                  #ifdef BUILD_DEBUG_AST
-                                   tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty for body"));
+                                   tmp.push_back(new ast::CommentExp((yyloc), new std::wstring(L"Empty for body")));
                                  #endif
                                  (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                }
@@ -5430,7 +5430,7 @@ yyreduce:
     {
                           ast::exps_t tmp;
                           #ifdef BUILD_DEBUG_AST
-                            tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty while body"));
+                            tmp.push_back(new ast::CommentExp((yyloc), new std::wstring(L"Empty while body")));
                           #endif
                           (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                         }
@@ -5556,7 +5556,7 @@ yyreduce:
     {
                                                     ast::exps_t tmp;
                                                     #ifdef BUILD_DEBUG_AST
-                                                      tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty catch body"));
+                                                      tmp.push_back(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));
                                                   }
@@ -5604,7 +5604,7 @@ yyreduce:
     {
                                   ast::exps_t tmp;
                                   #ifdef BUILD_DEBUG_AST
-                                    tmp[0] = new ast::CommentExp((yyloc), new std::wstring(L"Empty catch body"));
+                                    tmp.push_back(new ast::CommentExp((yyloc), new std::wstring(L"Empty catch body")));
                                   #endif
                                   (yyval.t_seq_exp) = new ast::SeqExp((yyloc), tmp);
                                 }
index 9ac2308..76dfabd 100644 (file)
@@ -1127,3 +1127,28 @@ std::list<std::wstring> ConfigVariable::getReferenceModules()
     std::list<std::wstring> l(m_ReferenceModules);
     return l;
 }
+
+/*
+** \}
+*/
+
+/*
+** analyzer options
+** \{
+*/
+
+int ConfigVariable::m_analyzerOptions = 0;
+void ConfigVariable::setAnalyzerOptions(int _val)
+{
+    m_analyzerOptions = _val;
+}
+
+int ConfigVariable::getAnalyzerOptions(void)
+{
+    return m_analyzerOptions;
+}
+
+
+/*
+** \}
+*/
index 1a0ddae..926b61d 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <sstream>
 #include "bool.hxx"
+#include "boolexp.hxx"
 #include "tostring_common.hxx"
 #include "configvariable.hxx"
 
@@ -333,38 +334,9 @@ int* Bool::allocData(int _iSize)
     return new int[_iSize];
 }
 
-//std::wstring Bool::toStringInLine(int _iPrecision, int iLineLen)
-//{
-//    std::wostringstream ostr;
-
-//    if(isScalar() || (isVector() && getRows() == 1))
-//    {
-//        for(int i = 0 ; i < getSize() ; i++)
-//        {
-//            ostr << L"  ";
-//            ostr << (get(i) == 0 ? L"F" : L"T");
-
-//            if(ostr.str().length() > iLineLen)
-//            {
-//                break;
-//            }
-//        }
-
-//        return ostr.str();
-//    }
-
-//    //all other cases
-//    ostr << L"[";
-//    for(int i = 0 ; i < m_iDims ; i++)
-//    {
-//        if(i > 0)
-//        {
-//            ostr << L"x";
-//        }
-//        ostr << m_piDims[i];
-//    }
-
-//    ostr << L" " << getTypeStr() << L"]";
-//    return ostr.str();
-//}
+ast::Exp* Bool::getExp(const Location& loc)
+{
+    return new ast::BoolExp(loc, this);
 }
+
+}
\ No newline at end of file
index 0156458..ca8480f 100644 (file)
@@ -13,6 +13,7 @@
 #include <sstream>
 #include <math.h>
 #include "double.hxx"
+#include "doubleexp.hxx"
 #include "tostring_common.hxx"
 #include "scilabexception.hxx"
 #include "configvariable.hxx"
@@ -1193,4 +1194,10 @@ void Double::convertToZComplex()
     m_pRealData = (double*)pdblZ;
     setViewAsZComplex(true);
 }
+
+ast::Exp* Double::getExp(const Location& loc)
+{
+    return new ast::DoubleExp(loc, this);
+}
+
 }
index 7d1fc94..7e97e91 100644 (file)
@@ -13,6 +13,7 @@
 #include <sstream>
 #include "core_math.h"
 #include "string.hxx"
+#include "stringexp.hxx"
 #include "tostring_common.hxx"
 #include "configvariable.hxx"
 
@@ -481,5 +482,11 @@ wchar_t** String::allocData(int _iSize)
     memset(pStr, 0x00, _iSize * sizeof(wchar_t*));
     return pStr;
 }
+
+ast::Exp* String::getExp(const Location& loc)
+{
+    return new ast::StringExp(loc, this);
+}
+
 }
 
index 0258e72..c02f6cc 100644 (file)
@@ -171,7 +171,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_where.cpp \
        sci_gateway/cpp/sci_getmemory.cpp \
        sci_gateway/cpp/sci_errclear.cpp \
-       sci_gateway/cpp/sci_intppty.cpp
+       sci_gateway/cpp/sci_intppty.cpp \
+       sci_gateway/cpp/sci_analyzeroptions.cpp
 
 libscicore_la_CPPFLAGS = \
     -I$(srcdir)/includes/ \
index 465a12e..1a847f9 100644 (file)
@@ -317,7 +317,8 @@ am__objects_5 = sci_gateway/cpp/libscicore_la-core_gw.lo \
        sci_gateway/cpp/libscicore_la-sci_where.lo \
        sci_gateway/cpp/libscicore_la-sci_getmemory.lo \
        sci_gateway/cpp/libscicore_la-sci_errclear.lo \
-       sci_gateway/cpp/libscicore_la-sci_intppty.lo
+       sci_gateway/cpp/libscicore_la-sci_intppty.lo \
+       sci_gateway/cpp/libscicore_la-sci_analyzeroptions.lo
 am_libscicore_la_OBJECTS = $(am__objects_4) $(am__objects_5)
 libscicore_la_OBJECTS = $(am_libscicore_la_OBJECTS)
 libscicore_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
@@ -870,7 +871,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_where.cpp \
        sci_gateway/cpp/sci_getmemory.cpp \
        sci_gateway/cpp/sci_errclear.cpp \
-       sci_gateway/cpp/sci_intppty.cpp
+       sci_gateway/cpp/sci_intppty.cpp \
+       sci_gateway/cpp/sci_analyzeroptions.cpp
 
 libscicore_la_CPPFLAGS = -I$(srcdir)/includes/ -I$(srcdir)/src/c/ \
        -I$(srcdir)/src/cpp/ -I$(top_srcdir)/modules/ast/includes/ast/ \
@@ -1523,6 +1525,9 @@ sci_gateway/cpp/libscicore_la-sci_errclear.lo:  \
 sci_gateway/cpp/libscicore_la-sci_intppty.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscicore_la-sci_analyzeroptions.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscicore.la: $(libscicore_la_OBJECTS) $(libscicore_la_DEPENDENCIES) $(EXTRA_libscicore_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(libscicore_la_LINK) $(am_libscicore_la_rpath) $(libscicore_la_OBJECTS) $(libscicore_la_LIBADD) $(LIBS)
@@ -1553,6 +1558,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscicore_la-sci_type.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-core_gw.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_abort.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_analyzeroptions.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_argn.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_banner.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_clear.Plo@am__quote@
@@ -2450,6 +2456,13 @@ sci_gateway/cpp/libscicore_la-sci_intppty.lo: sci_gateway/cpp/sci_intppty.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_intppty.lo `test -f 'sci_gateway/cpp/sci_intppty.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_intppty.cpp
 
+sci_gateway/cpp/libscicore_la-sci_analyzeroptions.lo: sci_gateway/cpp/sci_analyzeroptions.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscicore_la-sci_analyzeroptions.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_analyzeroptions.Tpo -c -o sci_gateway/cpp/libscicore_la-sci_analyzeroptions.lo `test -f 'sci_gateway/cpp/sci_analyzeroptions.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_analyzeroptions.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_analyzeroptions.Tpo sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_analyzeroptions.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_analyzeroptions.cpp' object='sci_gateway/cpp/libscicore_la-sci_analyzeroptions.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_analyzeroptions.lo `test -f 'sci_gateway/cpp/sci_analyzeroptions.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_analyzeroptions.cpp
+
 .f.o:
        $(AM_V_F77)$(F77COMPILE) -c -o $@ $<
 
index e249ea3..6891b92 100644 (file)
@@ -66,5 +66,6 @@ CPP_GATEWAY_PROTOTYPE(sci_intppty);
 CPP_GATEWAY_PROTOTYPE(sci_newfun);
 CPP_GATEWAY_PROTOTYPE(sci_clearfun);
 CPP_GATEWAY_PROTOTYPE(sci_funptr);
+CPP_GATEWAY_PROTOTYPE(sci_analyzeroptions);
 
 #endif /* __CORE_GW_HXX__ */
index 283ba35..d5e22bb 100644 (file)
@@ -61,5 +61,6 @@ int CoreModule::Load()
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"newfun", &sci_newfun, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"clearfun", &sci_clearfun, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"funptr", &sci_funptr, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(Function::createFunction(L"analyzerOptions", &sci_analyzeroptions, MODULE_NAME));
     return 1;
 }
index 845f977..a2603fa 100644 (file)
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="sci_analyzeroptions.cpp" />
     <ClCompile Include="sci_clearfun.cpp" />
     <ClCompile Include="sci_errclear.cpp" />
     <ClCompile Include="sci_format.cpp" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index c7eeac7..b5c2620 100644 (file)
     <ClCompile Include="sci_funptr.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="sci_analyzeroptions.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\banner.hxx">
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_analyzeroptions.cpp b/scilab/modules/core/sci_gateway/cpp/sci_analyzeroptions.cpp
new file mode 100644 (file)
index 0000000..6772e9b
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2010 - DIGITEO - Antoine ELIAS
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+
+#include "core_gw.hxx"
+#include "configvariable.hxx"
+#include "double.hxx"
+#include "function.hxx"
+
+extern "C"
+{
+#include "Scierror.h"
+#include "localization.h"
+}
+
+/*--------------------------------------------------------------------------*/
+
+using namespace types;
+
+Function::ReturnValue sci_analyzeroptions(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    InternalType *pIT = NULL;
+
+    /* Check the number of input argument */
+    if (in.size() > 1)
+    {
+        Scierror(999, _("%s: Wrong number of input arguments: %d or %d expected.\n"), "mode" , 0, 1);
+        return Function::Error;
+    }
+
+    /* Check the number of output argument */
+    if (_iRetCount != 1)
+    {
+        Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), "mode", 1);
+        return Function::Error;
+    }
+
+    if (in.size() == 0)
+    {
+        out.push_back(new Double((int)ConfigVariable::getAnalyzerOptions()));
+    }
+    else
+    {
+        if (in[0]->isDouble() == false)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: Scalar expected.\n"), "mode", 1);
+            return Function::Error;
+        }
+
+        types::Double* pDblIn = in[0]->getAs<types::Double>();
+
+        if (pDblIn->isScalar() == false)
+        {
+            Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), "mode", 1);
+            return types::Function::Error;
+        }
+
+        int iAnalizerOptions = (int)pDblIn->get(0);
+        if (pDblIn->get(0) != (double)iAnalizerOptions)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: An integer value expected.\n"), "mode", 1);
+            return types::Function::Error;
+        }
+
+        ConfigVariable::setAnalyzerOptions(iAnalizerOptions);
+    }
+
+    return Function::OK;
+}
+/*--------------------------------------------------------------------------*/
index ffbb808..c7b9d27 100644 (file)
@@ -735,8 +735,8 @@ static void Add_All_Variables(void)
 
 static void Add_Nan(void)
 {
-    double dbl1 = 1.0;
-    double dbl0 = dbl1 - dbl1;
+    double dbl1 = -1.0;
+    double dbl0 = fabs(dbl1 - dbl1);
 
     Add_Double_Constant(L"%nan", dbl0 / dbl0, 0, false);
 }
index d56581b..21ec687 100644 (file)
@@ -179,8 +179,12 @@ void execAstTask(ast::Exp* tree, bool serialize, bool timed, bool ASTtimed, bool
     if (!execVerbose && !ASTtimed)
     {
         //call analyzer visitor before exec visitor
-        analysis::AnalysisVisitor analysis;
-        newTree->accept(analysis);
+        if (ConfigVariable::getAnalyzerOptions() == 1)
+        {
+            analysis::AnalysisVisitor analysis;
+            newTree->accept(analysis);
+        }
+
         exec = new ast::ExecVisitor();
     }
 
index 0a578dd..cd9a6d1 100644 (file)
@@ -92,5 +92,5 @@ extern void C2F(dad) (double *a, int *na, int *i1, int *i2, int *j1, int *j2, do
 extern int C2F(entier) (int *_iSize, double *_pdbl, int *_pi);
 extern int C2F(simple) (int *_iSize, double *_pdbl, float *_pf);
 extern double C2F(nearfloat) (double*, double*);
-
+extern int C2F(daxpy)(int* N, double* DA, double* DX, int* INCX, double* DY, int* INCY);
 #endif /* __COMMON_H__ */
index 6f9843c..727a128 100644 (file)
@@ -16,6 +16,7 @@
 #include "execvisitor.hxx"
 #include "mutevisitor.hxx"
 #include "printvisitor.hxx"
+#include "AnalysisVisitor.hxx"
 #include "visitor_common.hxx"
 #include "scilabWrite.hxx"
 #include "scilabexception.hxx"
@@ -192,6 +193,12 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
         ConfigVariable::setSilentError(1);
     }
 
+    if (ConfigVariable::getAnalyzerOptions() == 1)
+    {
+        analysis::AnalysisVisitor analysis;
+        pExp->accept(analysis);
+    }
+
     ast::exps_t LExp = pExp->getAs<SeqExp>()->getExps();
 
     for (ast::exps_t::iterator j = LExp.begin(), itEnd = LExp.end(); j != itEnd ; ++j)
index 3fb7c29..bdc5d6b 100644 (file)
@@ -16,6 +16,7 @@
 #include "context.hxx"
 #include "functions_gw.hxx"
 #include "macrovarvisitor.hxx"
+#include "string.hxx"
 #include "list.hxx"
 #include "macro.hxx"
 #include "macrofile.hxx"