New scope management 49/14549/7
Antoine ELIAS [Tue, 20 May 2014 10:08:02 +0000 (12:08 +0200)]
Change-Id: Ic5002a4d28f36ba3b4fbca7e198370b7220d17e9

119 files changed:
scilab/etc/scilab.quit
scilab/etc/scilab.start
scilab/modules/api_scilab/api_scilab.vcxproj
scilab/modules/api_scilab/api_scilab.vcxproj.filters
scilab/modules/api_scilab/core_Import.def
scilab/modules/api_scilab/elementary_functions_Import.def [deleted file]
scilab/modules/api_scilab/src/cpp/api_boolean.cpp
scilab/modules/api_scilab/src/cpp/api_double.cpp
scilab/modules/api_scilab/src/cpp/api_int.cpp
scilab/modules/api_scilab/src/cpp/api_pointer.cpp
scilab/modules/api_scilab/src/cpp/api_poly.cpp
scilab/modules/api_scilab/src/cpp/api_string.cpp
scilab/modules/ast/includes/expHistory.hxx
scilab/modules/ast/includes/exps/assignexp.hxx
scilab/modules/ast/includes/exps/forexp.hxx
scilab/modules/ast/includes/exps/functiondec.hxx
scilab/modules/ast/includes/exps/simplevar.hxx
scilab/modules/ast/includes/exps/vardec.hxx
scilab/modules/ast/includes/runvisitor.hxx
scilab/modules/ast/includes/visitor_common.hxx
scilab/modules/ast/src/cpp/expHistory.cpp
scilab/modules/ast/src/cpp/run_AssignExp.cpp
scilab/modules/ast/src/cpp/run_CallExp.cpp
scilab/modules/ast/src/cpp/run_MatrixExp.cpp
scilab/modules/ast/src/cpp/run_OpExp.cpp
scilab/modules/ast/src/cpp/runvisitor.cpp
scilab/modules/ast/src/cpp/visitor_common.cpp
scilab/modules/core/includes/sci_tools.h [moved from scilab/modules/elementary_functions/includes/sci_tools.h with 75% similarity]
scilab/modules/core/includes/stack2.h
scilab/modules/core/sci_gateway/cpp/sci_argn.cpp
scilab/modules/core/sci_gateway/cpp/sci_clear.cpp
scilab/modules/core/sci_gateway/cpp/sci_global.cpp
scilab/modules/core/sci_gateway/cpp/sci_isglobal.cpp
scilab/modules/core/sci_gateway/cpp/sci_who.cpp
scilab/modules/core/src/c/core.vcxproj
scilab/modules/core/src/c/core.vcxproj.filters
scilab/modules/core/src/c/sci_tools.c
scilab/modules/core/src/cpp/InitScilab.cpp
scilab/modules/core/src/cpp/getfunctionsname.cpp
scilab/modules/core/src/cpp/getmacrosname.cpp
scilab/modules/core/src/cpp/getvariablesname.cpp
scilab/modules/core/src/cpp/runner.cpp
scilab/modules/core/src/cpp/storeCommand.cpp
scilab/modules/elementary_functions/src/c/elementary_functions.vcxproj
scilab/modules/elementary_functions/src/c/elementary_functions.vcxproj.filters
scilab/modules/elementary_functions/src/cpp/getmode.cpp
scilab/modules/fileio/includes/filemanager.hxx
scilab/modules/fileio/sci_gateway/cpp/sci_deletefile.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_fileext.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_fileparts.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_filesep.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_get_absolute_file_path.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_getrelativefilename.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mclearerr.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_meof.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_merror.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mfprintf.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mget.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mgetl.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mgetstr.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mput.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mputl.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mputstr.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mseek.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mtell.cpp
scilab/modules/fileio/src/cpp/expandPathVariable.cpp
scilab/modules/fileio/src/cpp/filemanager.cpp
scilab/modules/fileio/src/cpp/mget.cpp
scilab/modules/fileio/src/cpp/mgetl.cpp
scilab/modules/fileio/src/cpp/mgetstr.cpp
scilab/modules/fileio/src/cpp/mput.cpp
scilab/modules/fileio/src/cpp/mputl.cpp
scilab/modules/fileio/src/cpp/mseek.cpp
scilab/modules/fileio/src/cpp/mtell.cpp
scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp
scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp
scilab/modules/functions/sci_gateway/cpp/sci_functionlist.cpp
scilab/modules/functions/sci_gateway/cpp/sci_macrovar.cpp
scilab/modules/functions/sci_gateway/cpp/sci_whereis.cpp
scilab/modules/functions_manager/src/cpp/funcmanager.cpp
scilab/modules/graphics/sci_gateway/cpp/sci_get.cpp
scilab/modules/graphics/src/nographics/nographics_gw.cpp
scilab/modules/io/sci_gateway/cpp/sci_file.cpp
scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp
scilab/modules/io/src/cpp/loadlib.cpp
scilab/modules/mexlib/src/cpp/mexlib.cpp
scilab/modules/optimization/sci_gateway/cpp/sci_optim.cpp
scilab/modules/preferences/src/c/getScilabPreference.c
scilab/modules/string/sci_gateway/cpp/sci_regexp.cpp
scilab/modules/string/sci_gateway/cpp/sci_string.cpp
scilab/modules/string/sci_gateway/cpp/sci_stripblanks.cpp
scilab/modules/string/src/cpp/stripblanks.cpp
scilab/modules/string/src/cpp/stripblanks.hxx
scilab/modules/symbol/Makefile.am
scilab/modules/symbol/Makefile.in
scilab/modules/symbol/includes/context.hxx
scilab/modules/symbol/includes/libraries.hxx
scilab/modules/symbol/includes/variables.hxx
scilab/modules/symbol/src/cpp/context.cpp
scilab/modules/symbol/src/cpp/libraries.cpp [deleted file]
scilab/modules/symbol/src/cpp/variables.cpp [deleted file]
scilab/modules/symbol/symbol.vcxproj
scilab/modules/symbol/symbol.vcxproj.filters
scilab/modules/system_env/src/cpp/home.cpp
scilab/modules/system_env/src/cpp/sci_home.cpp
scilab/modules/system_env/src/cpp/sci_path.cpp
scilab/modules/system_env/src/cpp/sci_tmpdir.cpp
scilab/modules/time/sci_gateway/cpp/sci_tictoc.cpp
scilab/modules/types/includes/alltypes.hxx
scilab/modules/types/includes/library.hxx
scilab/modules/types/includes/macro.hxx
scilab/modules/types/includes/macrofile.hxx
scilab/modules/types/includes/typesdecl.hxx [new file with mode: 0644]
scilab/modules/types/sci_gateway/cpp/sci_inspectorGetFunctionList.cpp
scilab/modules/types/src/cpp/library.cpp
scilab/modules/types/src/cpp/macro.cpp
scilab/modules/types/src/cpp/macrofile.cpp
scilab/modules/types/types.vcxproj
scilab/modules/types/types.vcxproj.filters

index a74f151..6508654 100644 (file)
@@ -18,7 +18,7 @@ function scilabQuit()
   // ATOMS ===============================================================
   if with_module("atoms") then
     if sciargs() <> "-noatomsautoload" & isdef("atomsQuit") then
-      //atomsQuit();
+      atomsQuit();
     end
   end
 
index d922392..e0051e0 100644 (file)
@@ -41,7 +41,7 @@ end
 //if ((getscilabmode() == "NWNI" | getscilabmode() == "NW") & ~fromjava() & ~fromc() & sciargs()<>"-nb")
 if ((getscilabmode() == "NWNI" | getscilabmode() == "NW") & sciargs()<>"-nb")
    [v, opts] = getversion()
-   printf(strsubst(v, "scilab-", "Scilab ") + " (" + opts($-1) + ", " + opts($) + ")");
+   printf(strsubst(v, "scilab-", "Scilab ") + " (" + opts($-1) + ", " + opts($) + ")\n");
    clear v opts;
 end
 
index 6ce064f..5a93f72 100644 (file)
@@ -96,7 +96,6 @@
       <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)Localization_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)scilocalization.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions_f.lib" 1&gt;NUL 2&gt;NUL
-lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)linpack_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)linpack_f.lib" 1&gt;NUL 2&gt;NUL
 
 cd $(IntDir) &gt;nul
@@ -108,7 +107,7 @@ cd .. &gt;nul
 </Command>
     </PreLinkEvent>
     <Link>
-      <AdditionalDependencies>elementary_functions_f.lib;elementary_functions.lib;linpack_f.lib;core.lib;scilocalization.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>elementary_functions_f.lib;linpack_f.lib;core.lib;scilocalization.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ModuleDefinitionFile>api_scilab_export.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -149,7 +148,6 @@ cd .. &gt;nul
       <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)Localization_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)scilocalization.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions_f.lib" 1&gt;NUL 2&gt;NUL
-lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)linpack_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)linpack_f.lib" 1&gt;NUL 2&gt;NUL
 
 cd $(IntDir) &gt;nul
@@ -161,7 +159,7 @@ cd .. &gt;nul
 </Command>
     </PreLinkEvent>
     <Link>
-      <AdditionalDependencies>elementary_functions_f.lib;elementary_functions.lib;linpack_f.lib;core.lib;scilocalization.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>elementary_functions_f.lib;linpack_f.lib;core.lib;scilocalization.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ModuleDefinitionFile>api_scilab_export.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -206,7 +204,6 @@ cd .. &gt;nul
       <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)Localization_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)scilocalization.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions_f.lib" 1&gt;NUL 2&gt;NUL
-lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)linpack_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)linpack_f.lib" 1&gt;NUL 2&gt;NUL
 
 cd $(IntDir) &gt;nul
@@ -218,7 +215,7 @@ cd .. &gt;nul
 </Command>
     </PreLinkEvent>
     <Link>
-      <AdditionalDependencies>elementary_functions_f.lib;elementary_functions.lib;linpack_f.lib;core.lib;scilocalization.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>elementary_functions_f.lib;linpack_f.lib;core.lib;scilocalization.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ModuleDefinitionFile>api_scilab_export.def</ModuleDefinitionFile>
       <GenerateDebugInformation>false</GenerateDebugInformation>
@@ -269,7 +266,6 @@ cd .. &gt;nul
       <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)Localization_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)scilocalization.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions_f.lib" 1&gt;NUL 2&gt;NUL
-lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)linpack_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)linpack_f.lib" 1&gt;NUL 2&gt;NUL
 
 cd $(IntDir) &gt;nul
@@ -281,7 +277,7 @@ cd .. &gt;nul
 </Command>
     </PreLinkEvent>
     <Link>
-      <AdditionalDependencies>elementary_functions_f.lib;elementary_functions.lib;linpack_f.lib;core.lib;scilocalization.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>elementary_functions_f.lib;linpack_f.lib;core.lib;scilocalization.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ModuleDefinitionFile>api_scilab_export.def</ModuleDefinitionFile>
       <GenerateDebugInformation>false</GenerateDebugInformation>
@@ -379,7 +375,6 @@ cd .. &gt;nul
   <ItemGroup>
     <None Include="core_import.def" />
     <None Include="elementary_functions_f_Import.def" />
-    <None Include="elementary_functions_Import.def" />
     <None Include="linpack_f_Import.def" />
     <None Include="locales\api_scilab.pot" />
     <None Include="Localization_Import.def" />
index 9296795..7125997 100644 (file)
     <None Include="linpack_f_Import.def">
       <Filter>Libraries Dependencies\Imports</Filter>
     </None>
-    <None Include="elementary_functions_Import.def">
-      <Filter>Libraries Dependencies\Imports</Filter>
-    </None>
   </ItemGroup>
 </Project>
\ No newline at end of file
index 36055b2..a2aea91 100644 (file)
@@ -7,6 +7,5 @@ getExecMode
 freeArrayOfString
 isopt_
 numopt_
-SciToF77
 MyHeapAlloc
 MyHeapFree
diff --git a/scilab/modules/api_scilab/elementary_functions_Import.def b/scilab/modules/api_scilab/elementary_functions_Import.def
deleted file mode 100644 (file)
index 870e2c2..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-LIBRARY    elementary_functions.dll
-
-
-EXPORTS
-SciToF77
index 610665b..bad2010 100644 (file)
@@ -30,7 +30,6 @@ extern "C"
 }
 
 using namespace std;
-using namespace types;
 
 /********************************/
 /*   boolean matrix functions   */
@@ -62,7 +61,7 @@ SciErr getMatrixOfBoolean(void* _pvCtx, int* _piAddress, int* _piRows, int* _piC
 
     if (_piBool)
     {
-        *_piBool = ((InternalType*)_piAddress)->getAs<types::Bool>()->get();
+        *_piBool = ((types::InternalType*)_piAddress)->getAs<types::Bool>()->get();
     }
     return sciErr;
 }
@@ -77,11 +76,11 @@ SciErr allocMatrixOfBoolean(void* _pvCtx, int _iVar, int _iRows, int _iCols, int
         return sciErr;
     }
 
-    GatewayStruct* pStr = (GatewayStruct*)_pvCtx;
-    typed_list in = *pStr->m_pIn;
-    InternalType** out = pStr->m_pOut;
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
 
-    Bool *pBool = new Bool(_iRows, _iCols);
+    types::Bool *pBool = new types::Bool(_iRows, _iCols);
     if (pBool == NULL)
     {
         addErrorMessage(&sciErr, API_ERROR_NO_MORE_MEMORY, _("%s: No more memory to allocated variable"), "allocMatrixOfBoolean");
index 7cfda61..d66467d 100644 (file)
@@ -422,7 +422,7 @@ SciErr createNamedComplexZMatrixOfDouble(void* _pvCtx, const char* _pstName, int
     C2F(dcopy)(&iSize, const_cast<double*>(&_pdblData->r), &iTwo, pdblReal, &iOne);
     C2F(dcopy)(&iSize, const_cast<double*>(&_pdblData->i), &iOne, pdblImg, &iOne);
 
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), *pDbl);
+    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pDbl);
     FREE(pwstName);
     return sciErr;
 }
@@ -451,7 +451,7 @@ SciErr createCommonNamedMatrixOfDouble(void* _pvCtx, const char* _pstName, int _
         C2F(dcopy)(&iSize, const_cast<double*>(_pdblImg), &iOne, pdblImg, &iOne);
     }
 
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), *pDbl);
+    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pDbl);
     FREE(pwstName);
     return sciErr;
 }
index cfe755e..bda5cbf 100644 (file)
@@ -805,7 +805,7 @@ SciErr createCommonNamedMatrixOfInteger(void* _pvCtx, const char* _pstName, int
         return sciErr;
     }
 
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), *pIT);
+    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pIT);
     FREE(pwstName);
     return sciErr;
 }
index 0f42050..b977edd 100644 (file)
@@ -16,6 +16,7 @@
 #include "gatewaystruct.hxx"
 #include "pointer.hxx"
 #include "context.hxx"
+#include "scilabexception.hxx"
 
 extern "C"
 {
@@ -96,7 +97,7 @@ SciErr createNamedPointer(void* _pvCtx, const char* _pstName, void* _pvPtr)
     wchar_t* pwstName = to_wide_string(_pstName);
 
     Pointer* pP = new Pointer(_pvPtr);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), *pP);
+    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pP);
     FREE(pwstName);
 
     return sciErr;
index 9e5c878..50a3827 100644 (file)
@@ -271,7 +271,7 @@ SciErr createCommonNamedMatrixOfPoly(void* _pvCtx, const char* _pstName, char* _
         pP->setCoef(i, pD);
     }
 
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), *pP);
+    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pP);
     FREE(pwstName);
     return sciErr;
 }
index fd723a5..210505d 100644 (file)
@@ -186,7 +186,7 @@ SciErr createNamedMatrixOfString(void* _pvCtx, const char* _pstName, int _iRows,
     }
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), *pS);
+    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pS);
     FREE(pwstName);
 
     return sciErr;
index 9d3583c..689b1c1 100644 (file)
@@ -23,15 +23,15 @@ class ExpHistory
 {
 public :
     ExpHistory();
-    ExpHistory(ExpHistory*, const ast::SimpleVar*);
+    ExpHistory(ExpHistory*, ast::SimpleVar*);
     ExpHistory(ExpHistory*, types::typed_list*);
-    ExpHistory(ExpHistory*, const ast::SimpleVar*, types::typed_list*, int, bool, types::InternalType*);
+    ExpHistory(ExpHistory*, ast::SimpleVar*, types::typed_list*, int, bool, types::InternalType*);
 
     ~ExpHistory();
 
     // expression "a"
-    void                    setExp(const ast::SimpleVar*);
-    const ast::SimpleVar*   getExp();
+    void                    setExp(ast::SimpleVar*);
+    ast::SimpleVar*         getExp();
     std::wstring            getExpAsString();
 
     // arguments x of a(x)
@@ -73,7 +73,7 @@ private :
     int*                    m_piArgsDimsArray;
     int                     m_iArgsDims;
 
-    const ast::SimpleVar*   m_pExp;
+    ast::SimpleVar*         m_pExp;
     ExpHistory*             m_pParent;
     types::InternalType*    m_pITCurrent;
 
index f0fa39e..77bdf69 100644 (file)
@@ -81,7 +81,7 @@ public:
     ** \{ */
 public:
     /** \brief Return the name of the size (read only). */
-    const Exp& left_exp_get() const
+    Exp& left_exp_get() const
     {
         return *_left_exp;
     }
@@ -92,7 +92,7 @@ public:
     }
 
     /** \brief Return the name of the init (read only). */
-    const Exp& right_exp_get() const
+    Exp& right_exp_get() const
     {
         return *_right_exp;
     }
index 0d1847c..469eafe 100644 (file)
@@ -87,7 +87,7 @@ public:
     ** \{ */
 public:
     /** \brief Return the implicit variable declaration (read only) */
-    const VarDec& vardec_get () const
+    VarDec& vardec_get () const
     {
         return *_vardec;
     }
index c93c06b..04624ae 100644 (file)
@@ -55,7 +55,8 @@ public:
           _name (name),
           _args (&args),
           _returns (&returns),
-          _body (&body)
+          _body (&body),
+          _stack(NULL)
     {
     }
 
@@ -70,7 +71,7 @@ public:
     virtual FunctionDec* clone()
     {
         Location* newloc = const_cast<Location*>(&location_get())->clone();
-        FunctionDec* cloned = new FunctionDec(*newloc, *new symbol::Symbol(name_get().name_get()), *args_get().clone(), *returns_get().clone(), *body_get().clone());
+        FunctionDec* cloned = new FunctionDec(*newloc, name_get(), *args_get().clone(), *returns_get().clone(), *body_get().clone());
         cloned->set_verbose(is_verbose());
         return cloned;
     }
@@ -131,8 +132,19 @@ public:
         _body = body;
     }
 
+    symbol::Variable* stack_get()
+    {
+        if (_stack == NULL)
+        {
+            _stack = symbol::Context::getInstance()->getOrCreate(_name);
+        }
+
+        return _stack;
+    }
+
 protected:
     symbol::Symbol&    _name;
+    symbol::Variable*    _stack;
     ArrayListVar*      _args;
     ArrayListVar*      _returns;
     Exp*               _body;
index 04e1968..81457dc 100644 (file)
@@ -15,7 +15,7 @@
 #define AST_SIMPLEVAR_HXX
 
 #include "var.hxx"
-#include "symbol.hxx"
+#include "context.hxx"
 
 namespace ast
 {
@@ -34,7 +34,8 @@ public:
     SimpleVar (const Location& location,
                symbol::Symbol& name)
         : Var (location),
-          _name (name)
+          _name (name),
+          _stack(NULL)
     {
     }
     /** \brief Destroy a Field Variable node.
@@ -77,6 +78,16 @@ public:
     {
         return _name;
     }
+
+    symbol::Variable* stack_get()
+    {
+        if (_stack == NULL)
+        {
+            _stack = symbol::Context::getInstance()->getOrCreate(_name);
+        }
+
+        return _stack;
+    }
     /** \} */
 
 
@@ -88,6 +99,7 @@ public:
 protected:
     /** \brief Variable's name */
     symbol::Symbol& _name;
+    symbol::Variable* _stack;
 };
 
 } // namespace ast
index d4927a9..7200ba9 100644 (file)
@@ -21,7 +21,7 @@
 #include <assert.h>
 
 #include "dec.hxx"
-#include "symbol.hxx"
+#include "context.hxx"
 
 namespace ast
 {
@@ -50,7 +50,8 @@ public:
             symbol::Symbol& name, Exp& init)
         : Dec (location),
           _name (name),
-          _init (&init)
+          _init (&init),
+          _stack(NULL)
     {
     }
 
@@ -67,7 +68,7 @@ public:
     virtual VarDec* clone()
     {
         Location* newloc = const_cast<Location*>(&location_get())->clone();
-        VarDec* cloned = new VarDec(*newloc, *new symbol::Symbol(name_get().name_get()), *init_get().clone());
+        VarDec* cloned = new VarDec(*newloc, name_get(), *init_get().clone());
         cloned->set_verbose(is_verbose());
         return cloned;
     }
@@ -96,6 +97,16 @@ public:
         return _name;
     }
 
+    symbol::Variable* stack_get()
+    {
+        if (_stack == NULL)
+        {
+            _stack = symbol::Context::getInstance()->getOrCreate(_name);
+        }
+
+        return _stack;
+    }
+
     /** \brief Return the initial expression value (read only). */
     const Exp& init_get (void) const
     {
@@ -110,6 +121,7 @@ public:
 protected:
     /** \brief Name of the declared variable. */
     symbol::Symbol& _name;
+    symbol::Variable* _stack;
     /** \brief The initial value (expression) assigned to the variable. */
     Exp* _init;
 };
index 4b571a1..e8f3275 100644 (file)
@@ -20,6 +20,7 @@
 #include "overload.hxx"
 #include "scilabWrite.hxx"
 #include "context.hxx"
+#include "variables.hxx"
 
 extern "C" {
 #include "more.h"
@@ -39,7 +40,7 @@ public:
         _resultVect.push_back(NULL);
         _result = NULL;
         m_bSingleResult = true;
-        m_pAns = new symbol::Symbol(L"ans");
+        m_pAns = symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"ans"));
     }
 
     ~RunVisitor()
@@ -183,7 +184,7 @@ protected:
     types::InternalType*       _result;
     bool m_bSingleResult;
     int _excepted_result;
-    symbol::Symbol* m_pAns;
+    symbol::Variable* m_pAns;
 };
 
 template <class T>
@@ -293,7 +294,7 @@ public :
 
     void visitprivate(const SimpleVar &e)
     {
-        InternalType *pI = symbol::Context::getInstance()->get(e.name_get());
+        InternalType *pI = symbol::Context::getInstance()->get(((SimpleVar&)e).stack_get());
         result_set(pI);
         if (pI != NULL)
         {
index d1600e9..b724179 100644 (file)
@@ -47,7 +47,7 @@ EXTERN_AST types::InternalType* AddElementToVariableFromRow(
 
 EXTERN_AST const std::wstring* getStructNameFromExp(const ast::Exp* _pExp);
 
-EXTERN_AST bool getFieldsFromExp(const ast::Exp* _pExp, std::list<ExpHistory*>& fields);
+EXTERN_AST bool getFieldsFromExp(ast::Exp* _pExp, std::list<ExpHistory*>& fields);
 
 EXTERN_AST types::InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*>& fields, types::InternalType* pIT);
 
index 43c90a8..2e60140 100644 (file)
@@ -13,6 +13,7 @@
 #include "expHistory.hxx"
 #include "types_tools.hxx"
 #include "types.hxx"
+#include "context.hxx"
 
 /**
 ** Constructor & Destructor (public)
@@ -38,7 +39,7 @@ ExpHistory::ExpHistory()
 }
 
 
-ExpHistory::ExpHistory(ExpHistory* _pEH, const ast::SimpleVar* _pExp)
+ExpHistory::ExpHistory(ExpHistory* _pEH, ast::SimpleVar* _pExp)
 {
     initHistory();
 
@@ -54,7 +55,7 @@ ExpHistory::ExpHistory(ExpHistory* _pParent, types::typed_list* _pArgs)
     m_pParent   = _pParent;
 }
 
-ExpHistory::ExpHistory(ExpHistory* _pParent, const ast::SimpleVar* _pExp, types::typed_list* _pArgs, int _iLevel,  bool _bCellExp, types::InternalType* _pITCurrent)
+ExpHistory::ExpHistory(ExpHistory* _pParent, ast::SimpleVar* _pExp, types::typed_list* _pArgs, int _iLevel,  bool _bCellExp, types::InternalType* _pITCurrent)
 {
     initHistory();
 
@@ -78,12 +79,12 @@ ExpHistory::~ExpHistory()
 ** Accessor (public)
 */
 
-void ExpHistory::setExp(const ast::SimpleVar* _pExp)
+void ExpHistory::setExp(ast::SimpleVar* _pExp)
 {
     m_pExp = _pExp;
 }
 
-const ast::SimpleVar* ExpHistory::getExp()
+ast::SimpleVar* ExpHistory::getExp()
 {
     return m_pExp;
 }
@@ -149,9 +150,9 @@ void ExpHistory::computeArgs()
         }
         else
         {
-            for (int i = 0; i < std::min(m_iArgsDims, m_pITCurrent->getAs<types::GenericType>()->getDims()); i++)
+            for (int i = 0; i < Min(m_iArgsDims, m_pITCurrent->getAs<types::GenericType>()->getDims()); i++)
             {
-                m_piArgsDimsArray[i] = std::max(m_piArgsDimsArray[i], piDimsArray[i]);
+                m_piArgsDimsArray[i] = Max(m_piArgsDimsArray[i], piDimsArray[i]);
             }
         }
     }
@@ -316,4 +317,4 @@ void ExpHistory::setCellExp()
 bool ExpHistory::isCellExp()
 {
     return m_bCellExp;
-}
\ No newline at end of file
+}
index dd1576c..bf7bc8a 100644 (file)
@@ -19,7 +19,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
     try
     {
         /*get king of left hand*/
-        const SimpleVar *pVar = dynamic_cast<const SimpleVar*>(&e.left_exp_get());
+        SimpleVar *pVar = dynamic_cast<SimpleVar*>(&e.left_exp_get());
         if (pVar)
         {
             // x = ?
@@ -35,7 +35,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                     std::wostringstream os;
                     os << _W("Can not assign multiple value in a single variable") << std::endl;
                     //os << ((Location)e.right_exp_get().location_get()).location_getString() << std::endl;
-                    throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+                    throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
                 }
 
                 pIT = result_get();
@@ -63,12 +63,12 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             if (pReturn)
             {
                 //ReturnExp so, put the value in the previous scope
-                symbol::Context::getInstance()->putInPreviousScope(pVar->name_get(), *pIT);
+                symbol::Context::getInstance()->putInPreviousScope(pVar->stack_get(), pIT);
                 ((AssignExp*)&e)->return_set();
             }
             else
             {
-                symbol::Context::getInstance()->put(pVar->name_get(), *pIT);
+                symbol::Context::getInstance()->put(pVar->stack_get(), pIT);
             }
 
             if (e.is_verbose() && ConfigVariable::isPromptShow())
@@ -81,7 +81,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             return;
         }
 
-        const CellCallExp *pCell = dynamic_cast<const CellCallExp*>(&e.left_exp_get());
+        CellCallExp *pCell = dynamic_cast<CellCallExp*>(&e.left_exp_get());
         if (pCell)
         {
             InternalType *pOut = NULL;
@@ -101,7 +101,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 // if the right hand is NULL.
                 std::wostringstream os;
                 os << _W("Unable to extract right part expression.\n");
-                throw ScilabError(os.str(), 999, e.left_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.left_exp_get().location_get());
             }
 
             std::list<ExpHistory*> fields;
@@ -109,7 +109,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             {
                 std::wostringstream os;
                 os << _W("Get fields from expression failed.");
-                throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
             }
 
             pOut = evaluateFields(pCell, fields, pITR);
@@ -118,7 +118,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             {
                 std::wostringstream os;
                 os << _W("Fields evaluation failed.");
-                throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
             }
 
             if (pOut != NULL)
@@ -147,13 +147,13 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 //manage error
                 std::wostringstream os;
                 os << _W("Invalid Index.\n");
-                throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
             }
 
             return;
         }
 
-        const CallExp *pCall = dynamic_cast<const CallExp*>(&e.left_exp_get());
+        CallExp *pCall = dynamic_cast<CallExp*>(&e.left_exp_get());
         if (pCall)
         {
             //x(?) = ?
@@ -174,7 +174,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 // if the right hand is NULL.
                 std::wostringstream os;
                 os << _W("Unable to extract right part expression.\n");
-                throw ScilabError(os.str(), 999, e.left_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.left_exp_get().location_get());
             }
 
             std::list<ExpHistory*> fields;
@@ -182,7 +182,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             {
                 std::wostringstream os;
                 os << _W("Get fields from expression failed.");
-                throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
             }
 
             pOut = evaluateFields(pCall, fields, pITR);
@@ -191,7 +191,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             {
                 std::wostringstream os;
                 os << _W("Fields evaluation failed.");
-                throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
             }
 
             if (e.is_verbose() && ConfigVariable::isPromptShow())
@@ -216,7 +216,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             return;
         }
 
-        const AssignListExp *pList = dynamic_cast<const AssignListExp*>(&e.left_exp_get());
+        AssignListExp *pList = dynamic_cast<AssignListExp*>(&e.left_exp_get());
         if (pList)
         {
             //[x,y] = ?
@@ -232,7 +232,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 std::wostringstream os;
                 os << _W("Incompatible assignation: trying to assign ") << exec.result_getSize();
                 os << _W(" values in ") << iLhsCount << _W(" variables.") << std::endl;
-                throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
             }
 
             std::list<Exp *>::const_reverse_iterator it;
@@ -253,7 +253,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             return;
         }
 
-        const FieldExp *pField = dynamic_cast<const FieldExp*>(&e.left_exp_get());
+        FieldExp *pField = dynamic_cast<FieldExp*>(&e.left_exp_get());
         if (pField)
         {
             //a.b = x
@@ -278,14 +278,14 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             {
                 std::wostringstream os;
                 os << _W("Get fields from expression failed.");
-                throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
             }
 
             if (evaluateFields(pField, fields, pIT) == NULL)
             {
                 std::wostringstream os;
                 os << _W("Fields evaluation failed.");
-                throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+                throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
             }
 
             if (e.is_verbose() && ConfigVariable::isPromptShow())
@@ -306,9 +306,9 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
         std::wostringstream os;
         os << _W("unknow script form");
         //os << ((Location)e.right_exp_get().location_get()).location_getString() << std::endl;
-        throw ScilabError(os.str(), 999, e.right_exp_get().location_get());
+        throw ast::ScilabError(os.str(), 999, e.right_exp_get().location_get());
     }
-    catch (ScilabError error)
+    catch (ast::ScilabError error)
     {
         throw error;
     }
index d6db171..5630a58 100644 (file)
@@ -33,7 +33,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
         {
             std::wostringstream os;
             os << _W("Wrong number of output arguments.\n") << std::endl;
-            throw ScilabError(os.str(), 999, e.location_get());
+            throw ast::ScilabError(os.str(), 999, e.location_get());
         }
 
         //get function arguments
@@ -49,7 +49,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                 {
                     std::wostringstream os;
                     os << _W("left side of optional parameter must be a variable") << std::endl;
-                    throw ScilabError(os.str(), 999, e.location_get());
+                    throw ast::ScilabError(os.str(), 999, e.location_get());
                 }
 
                 Exp* pR = &pAssign->right_exp_get();
@@ -148,7 +148,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
 
                         std::wostringstream os;
                         os << _W("bad lhs, expected : ") << iRetCount << _W(" returned : ") << out.size() << std::endl;
-                        throw ScilabError(os.str(), 999, e.location_get());
+                        throw ast::ScilabError(os.str(), 999, e.location_get());
                     }
                 }
 
@@ -168,7 +168,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
             {
                 ConfigVariable::setLastErrorFunction(pCall->getName());
                 ConfigVariable::setLastErrorLine(e.location_get().first_line);
-                throw ScilabError();
+                throw ast::ScilabError();
             }
         }
         catch (ScilabMessage sm)
@@ -189,7 +189,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
             {
                 wchar_t szError[bsiz];
                 os_swprintf(szError, bsiz, _W("at line % 5d of function %ls called by :\n"), sm.GetErrorLocation().first_line, pCall->getName().c_str());
-                throw ScilabMessage(szError);
+                throw ast::ScilabMessage(szError);
             }
             else
             {
@@ -237,7 +237,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
         const SimpleVar *Var = dynamic_cast<const SimpleVar*>(&e.name_get());
         if (Var != NULL)
         {
-            pIT = symbol::Context::getInstance()->get(Var->name_get());
+            pIT = symbol::Context::getInstance()->get(((SimpleVar*)Var)->stack_get());
         }
         else
         {
@@ -388,7 +388,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                             //try to call specific exrtaction function
                             ret = Overload::call(L"%" + pIT->getAs<TList>()->getShortTypeStr() + L"_e", in, 1, ResultList, this);
                         }
-                        catch (ScilabError /*&e*/)
+                        catch (ast::ScilabError /*&e*/)
                         {
                             //if call failed try to call generic extraction function
                             ret = Overload::call(L"%l_e", in, 1, ResultList, this);
@@ -409,7 +409,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                             {
                                 std::wostringstream os;
                                 os << _W("Invalid index.\n");
-                                throw ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
+                                throw ast::ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
                             }
                             break;
                             case 1 :
@@ -425,7 +425,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                     }
                     else
                     {
-                        throw ScilabError();
+                        throw ast::ScilabError();
                     }
                     break;
                 }
@@ -484,7 +484,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                             //try to call specific exrtaction function
                             ret = Overload::call(L"%" + pIT->getAs<MList>()->getShortTypeStr() + L"_e", in, 1, ResultList, this);
                         }
-                        catch (ScilabError /*&e*/)
+                        catch (ast::ScilabError /*&e*/)
                         {
                             //if call failed try to call generic extraction function
                             ret = Overload::call(L"%l_e", in, 1, ResultList, this);
@@ -505,7 +505,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                             {
                                 std::wostringstream os;
                                 os << _W("Invalid index.\n");
-                                throw ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
+                                throw ast::ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
                             }
                             break;
                             case 1 :
@@ -521,7 +521,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                     }
                     else
                     {
-                        throw ScilabError();
+                        throw ast::ScilabError();
                     }
                     break;
                 }
@@ -553,7 +553,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                             {
                                 wchar_t szError[bsiz];
                                 os_swprintf(szError, bsiz, _W("Field \"%ls\" does not exists\n"), wstField.c_str());
-                                throw ScilabError(szError, 999, (*e.args_get().begin())->location_get());
+                                throw ast::ScilabError(szError, 999, (*e.args_get().begin())->location_get());
                             }
                         }
 
@@ -595,7 +595,13 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                         in.push_back(pS);
                         in.push_back(pH);
 
-                        Function* pCall = (Function*)symbol::Context::getInstance()->get(symbol::Symbol(L"%h_e"));
+                        static symbol::Variable* h_e = NULL;
+                        if (h_e == NULL)
+                        {
+                            h_e = symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"%h_e"));
+                        }
+
+                        Function* pCall = (Function*)symbol::Context::getInstance()->get(h_e);
                         Callable::ReturnValue ret =  pCall->call(in, opt, 1, out, this);
                         if (ret == Callable::OK)
                         {
@@ -638,7 +644,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                     std::wostringstream os;
                     os << _W("Invalid index.\n");
                     //os << ((*e.args_get().begin())->location_get()).location_getString() << std::endl;
-                    throw ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
+                    throw ast::ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
                 }
             }
             result_set(pOut);
@@ -656,7 +662,7 @@ void RunVisitorT<T>::visitprivate(const CallExp &e)
                     std::wostringstream os;
                     os << _W("inconsistent row/column dimensions\n");
                     //os << ((*e.args_get().begin())->location_get()).location_getString() << std::endl;
-                    throw ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
+                    throw ast::ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
                 }
             }
         }
@@ -689,7 +695,7 @@ void RunVisitorT<T>::visitprivate(const CellCallExp &e)
 
             if (pIT->isCell() == false)
             {
-                throw ScilabError(_W("[error] Cell contents reference from a non-cell array object.\n"), 999, (*e.args_get().begin())->location_get());
+                throw ast::ScilabError(_W("[error] Cell contents reference from a non-cell array object.\n"), 999, (*e.args_get().begin())->location_get());
             }
             //Create list of indexes
             types::typed_list *pArgs = GetArgumentList(e.args_get());
@@ -701,7 +707,7 @@ void RunVisitorT<T>::visitprivate(const CellCallExp &e)
                 std::wostringstream os;
                 os << _W("inconsistent row/column dimensions\n");
                 //os << ((*e.args_get().begin())->location_get()).location_getString() << std::endl;
-                throw ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
+                throw ast::ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
             }
 
             if (pList->getSize() == 1)
index 158ef34..f4f3542 100644 (file)
@@ -52,7 +52,7 @@ void RunVisitorT<T>::visitprivate(const MatrixExp &e)
                 {
                     std::wostringstream os;
                     os << _W("unable to concatenate\n");
-                    throw ScilabError(os.str(), 999, (*col)->location_get());
+                    throw ast::ScilabError(os.str(), 999, (*col)->location_get());
                 }
 
                 GenericType* pGT = pIT->getAs<GenericType>();
@@ -100,7 +100,7 @@ void RunVisitorT<T>::visitprivate(const MatrixExp &e)
                 {
                     std::wostringstream os;
                     os << _W("inconsistent row/column dimensions\n");
-                    throw ScilabError(os.str(), 999, (*row)->location_get());
+                    throw ast::ScilabError(os.str(), 999, (*row)->location_get());
                 }
 
                 // if we concatenate [Double Sparse], transform the Double to Sparse and perform [Sparse Sparse]
@@ -161,7 +161,7 @@ void RunVisitorT<T>::visitprivate(const MatrixExp &e)
             {
                 std::wostringstream os;
                 os << _W("inconsistent row/column dimensions\n");
-                throw ScilabError(os.str(), 999, (*e.lines_get().begin())->location_get());
+                throw ast::ScilabError(os.str(), 999, (*e.lines_get().begin())->location_get());
             }
 
             // if we concatenate [Double Sparse], transform the Double to Sparse and perform [Sparse Sparse]
@@ -199,7 +199,7 @@ void RunVisitorT<T>::visitprivate(const MatrixExp &e)
             result_set(Double::Empty());
         }
     }
-    catch (ScilabError error)
+    catch (ast::ScilabError error)
     {
         throw error;
     }
index 6b9e734..4e46911 100644 (file)
@@ -25,7 +25,7 @@ void RunVisitorT<T>::visitprivate(const OpExp &e)
             std::wostringstream os;
             os << _W("Incompatible output argument.\n");
             //os << ((Location)e.right_get().location_get()).location_getString() << std::endl;
-            throw ScilabError(os.str(), 999, e.right_get().location_get());
+            throw ast::ScilabError(os.str(), 999, e.right_get().location_get());
         }
 
         /*getting what to assign*/
@@ -36,7 +36,7 @@ void RunVisitorT<T>::visitprivate(const OpExp &e)
             std::wostringstream os;
             os << _W("Incompatible output argument.\n");
             //os << ((Location)e.right_get().location_get()).location_getString() << std::endl;
-            throw ScilabError(os.str(), 999, e.right_get().location_get());
+            throw ast::ScilabError(os.str(), 999, e.right_get().location_get());
         }
 
         if (pITL->getType() == GenericType::ScilabImplicitList)
@@ -202,7 +202,7 @@ void RunVisitorT<T>::visitprivate(const OpExp &e)
             delete pITR;
         }
     }
-    catch (ScilabError error)
+    catch (ast::ScilabError error)
     {
         result_clear();
         error.SetErrorLocation(e.location_get());
@@ -226,7 +226,7 @@ void RunVisitorT<T>::visitprivate(const LogicalOpExp &e)
             std::wostringstream os;
             os << _W("Incompatible output argument.\n");
             //os << ((Location)e.right_get().location_get()).location_getString() << std::endl;
-            throw ScilabError(os.str(), 999, e.right_get().location_get());
+            throw ast::ScilabError(os.str(), 999, e.right_get().location_get());
         }
 
         result_set(NULL);
@@ -264,7 +264,7 @@ void RunVisitorT<T>::visitprivate(const LogicalOpExp &e)
                     std::wostringstream os;
                     os << _W("Incompatible output argument.\n");
                     //os << ((Location)e.right_get().location_get()).location_getString() << std::endl;
-                    throw ScilabError(os.str(), 999, e.right_get().location_get());
+                    throw ast::ScilabError(os.str(), 999, e.right_get().location_get());
                 }
 
                 if (pITR->getType() == GenericType::ScilabImplicitList)
@@ -298,7 +298,7 @@ void RunVisitorT<T>::visitprivate(const LogicalOpExp &e)
                     std::wostringstream os;
                     os << _W("Incompatible output argument.\n");
                     //os << ((Location)e.right_get().location_get()).location_getString() << std::endl;
-                    throw ScilabError(os.str(), 999, e.right_get().location_get());
+                    throw ast::ScilabError(os.str(), 999, e.right_get().location_get());
                 }
 
                 if (pITR->getType() == GenericType::ScilabImplicitList)
@@ -336,7 +336,7 @@ void RunVisitorT<T>::visitprivate(const LogicalOpExp &e)
             delete pITR;
         }
     }
-    catch (ScilabError error)
+    catch (ast::ScilabError error)
     {
         result_clear();
         error.SetErrorLocation(e.location_get());
index 89b4cc7..2d8b23c 100644 (file)
@@ -414,7 +414,7 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
         for (int i = 0 ; i < pVar->getSize() ; i++)
         {
             pIL = pVar->extractValue(i);
-            symbol::Context::getInstance()->put(varName, *pIL);
+            symbol::Context::getInstance()->put(e.vardec_get().stack_get(), pIL);
 
             e.body_get().accept(*this);
             if (e.body_get().is_break())
@@ -442,7 +442,7 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
         for (int i = 0 ; i < pL->getSize() ; i++)
         {
             InternalType* pNew = pL->get(i);
-            symbol::Context::getInstance()->put(e.vardec_get().name_get(), *pNew);
+            symbol::Context::getInstance()->put(e.vardec_get().stack_get(), pNew);
             e.body_get().accept(*this);
             if (e.body_get().is_break())
             {
@@ -475,7 +475,7 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
         for (int i = 0 ; i < pVar->getCols() ; i++)
         {
             GenericType* pNew = pVar->getColumnValues(i);
-            symbol::Context::getInstance()->put(e.vardec_get().name_get(), *pNew);
+            symbol::Context::getInstance()->put(e.vardec_get().stack_get(), pNew);
             e.body_get().accept(*this);
             if (e.body_get().is_break())
             {
@@ -810,7 +810,7 @@ void RunVisitorT<T>::visitprivate(const SeqExp  &e)
                 {
                     //symbol::Context::getInstance()->put(symbol::Symbol(L"ans"), *execMe.result_get());
                     InternalType* pITAns = result_get();
-                    symbol::Context::getInstance()->put(*m_pAns, *pITAns);
+                    symbol::Context::getInstance()->put(m_pAns, pITAns);
                     if ((*itExp)->is_verbose() && ConfigVariable::isPromptShow())
                     {
                         //TODO manage multiple returns
@@ -1283,7 +1283,7 @@ void RunVisitorT<T>::visitprivate(const FunctionDec  &e)
     // funcprot(2) : error
     if (ConfigVariable::getFuncprot() == 1 && ConfigVariable::getWarningMode())
     {
-        types::InternalType* pITFunc = symbol::Context::getInstance()->get(symbol::Symbol(e.name_get().name_get()));
+        types::InternalType* pITFunc = symbol::Context::getInstance()->get(((FunctionDec&)e).stack_get());
 
         if (pITFunc && pITFunc->isCallable())
         {
@@ -1298,7 +1298,7 @@ void RunVisitorT<T>::visitprivate(const FunctionDec  &e)
     }
     else if (ConfigVariable::getFuncprot() == 2)
     {
-        types::InternalType* pITFunc = symbol::Context::getInstance()->get(symbol::Symbol(e.name_get().name_get()));
+        types::InternalType* pITFunc = symbol::Context::getInstance()->get(((FunctionDec&)e).stack_get());
 
         if (pITFunc && pITFunc->isCallable())
         {
@@ -1316,19 +1316,19 @@ void RunVisitorT<T>::visitprivate(const FunctionDec  &e)
     std::list<Var *>::const_iterator   i;
 
     //get input parameters list
-    std::list<symbol::Symbol> *pVarList = new std::list<symbol::Symbol>();
+    std::list<symbol::Variable*> *pVarList = new std::list<symbol::Variable*>();
     const ArrayListVar *pListVar = &e.args_get();
     for (i = pListVar->vars_get().begin() ; i != pListVar->vars_get().end() ; i++)
     {
-        pVarList->push_back(static_cast<SimpleVar*>(*i)->name_get());
+        pVarList->push_back(static_cast<SimpleVar*>(*i)->stack_get());
     }
 
     //get output parameters list
-    std::list<symbol::Symbol> *pRetList = new std::list<symbol::Symbol>();
+    std::list<symbol::Variable*> *pRetList = new std::list<symbol::Variable*>();
     const ArrayListVar *pListRet = &e.returns_get();
     for (i = pListRet->vars_get().begin() ; i != pListRet->vars_get().end() ; i++)
     {
-        pRetList->push_back(static_cast<SimpleVar*>(*i)->name_get());
+        pRetList->push_back(static_cast<SimpleVar*>(*i)->stack_get());
     }
 
     //            Location* newloc = const_cast<Location*>(&location_get())->clone();
@@ -1341,7 +1341,7 @@ void RunVisitorT<T>::visitprivate(const FunctionDec  &e)
     types::Macro *pMacro = new types::Macro(e.name_get().name_get(), *pVarList, *pRetList,
                                             static_cast<SeqExp&>(*exp), L"script");
     pMacro->setFirstLine(e.location_get().first_line);
-    symbol::Context::getInstance()->AddMacro(pMacro);
+    symbol::Context::getInstance()->addMacro(pMacro);
 }
 
 template <class T>
index 4b5f250..91b722f 100644 (file)
 
 #include "alltypes.hxx"
 
-using namespace types;
-using namespace ast;
-
-size_t Ast::globalNodeNumber = 0;
+size_t ast::Ast::globalNodeNumber = 0;
 static bool isIntTrue(InternalType* _pIT);
 
 bool bConditionState(types::InternalType *_pITResult)
@@ -646,11 +643,11 @@ types::InternalType* AddElementToVariable(types::InternalType* _poDest, types::I
     return NULL;
 }
 
-const std::wstring* getStructNameFromExp(const Exp* _pExp)
+const std::wstring* getStructNameFromExp(const ast::Exp* _pExp)
 {
-    const FieldExp* pField =  dynamic_cast<const FieldExp*>(_pExp);
-    const SimpleVar* pVar =  dynamic_cast<const SimpleVar*>(_pExp);
-    const CallExp* pCall =  dynamic_cast<const CallExp*>(_pExp);
+    const ast::FieldExp* pField =  dynamic_cast<const ast::FieldExp*>(_pExp);
+    const ast::SimpleVar* pVar =  dynamic_cast<const ast::SimpleVar*>(_pExp);
+    const ast::CallExp* pCall =  dynamic_cast<const ast::CallExp*>(_pExp);
 
     if (pField)
     {
@@ -669,7 +666,7 @@ const std::wstring* getStructNameFromExp(const Exp* _pExp)
         std::wostringstream os;
         os << _W("Unknow expression");
         //os << ((Location)e.right_exp_get().location_get()).location_getString() << std::endl;
-        throw ScilabError(os.str(), 999, _pExp->location_get());
+        throw ast::ScilabError(os.str(), 999, _pExp->location_get());
     }
     return NULL;
 }
@@ -679,7 +676,7 @@ const std::wstring* getStructNameFromExp(const Exp* _pExp)
 //i1, ..., in : indexes
 //dest : variable where insert data     || NULL
 //source : data to insert               || extract indexes from source
-types::InternalType* callOverload(const Exp& e, std::wstring _strType, types::typed_list* _pArgs, types::InternalType* _source, types::InternalType* _dest)
+types::InternalType* callOverload(const ast::Exp& e, std::wstring _strType, types::typed_list* _pArgs, types::InternalType* _source, types::InternalType* _dest)
 {
     types::InternalType* pITOut = NULL;
     types::typed_list in;
@@ -715,13 +712,13 @@ types::InternalType* callOverload(const Exp& e, std::wstring _strType, types::ty
     // For insertion in TList, call normal insertion if overload doesn't exits
     if ((_dest  && _dest->isTList() && pFunc == NULL) == false || _source->isListDelete())
     {
-        ExecVisitor exec;
+        ast::ExecVisitor exec;
         if (Overload::call(function_name, in, 1, out, &exec))
         {
             //manage error
             std::wostringstream os;
             os << _W("Error in overload function: ") << function_name << std::endl;
-            throw ScilabError(os.str(), 999, e.location_get());
+            throw ast::ScilabError(os.str(), 999, e.location_get());
         }
     }
 
@@ -755,12 +752,12 @@ types::InternalType* callOverload(const Exp& e, std::wstring _strType, types::ty
 }
 
 
-bool getFieldsFromExp(const Exp* _pExp, std::list<ExpHistory*>& fields)
+bool getFieldsFromExp(ast::Exp* _pExp, std::list<ExpHistory*>& fields)
 {
-    const FieldExp* pField      = dynamic_cast<const FieldExp*>(_pExp);
-    const SimpleVar* pVar       = dynamic_cast<const SimpleVar*>(_pExp);
-    const CallExp* pCall        = dynamic_cast<const CallExp*>(_pExp);
-    const CellCallExp* pCell    = dynamic_cast<const CellCallExp*>(_pExp);
+    ast::FieldExp* pField      = dynamic_cast<ast::FieldExp*>(_pExp);
+    ast::SimpleVar* pVar       = dynamic_cast<ast::SimpleVar*>(_pExp);
+    ast::CallExp* pCall        = dynamic_cast<ast::CallExp*>(_pExp);
+    ast::CellCallExp* pCell    = dynamic_cast<ast::CellCallExp*>(_pExp);
 
     if (pField)
     {
@@ -788,7 +785,7 @@ bool getFieldsFromExp(const Exp* _pExp, std::list<ExpHistory*>& fields)
     }
     else if (pCall)
     {
-        ExecVisitor execMe;
+        ast::ExecVisitor execMe;
         typed_list* pCurrentArgs = execMe.GetArgumentList(pCall->args_get());
 
         bool bErr = getFieldsFromExp(&pCall->name_get(), fields);
@@ -819,7 +816,7 @@ bool getFieldsFromExp(const Exp* _pExp, std::list<ExpHistory*>& fields)
     }
 }
 
-types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fields, InternalType* _pAssignValue)
+types::InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*>& fields, InternalType* _pAssignValue)
 {
     std::list<ExpHistory*> evalFields;
 
@@ -833,7 +830,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
         {
             // a{x}, where "a" doesn't exists
             pIT = new Cell(1, 1);
-            symbol::Context::getInstance()->put(pFirstField->getExp()->name_get(), *pIT);
+            symbol::Context::getInstance()->put(pFirstField->getExp()->stack_get(), pIT);
         }
         else if (fields.size() > 1)
         {
@@ -841,7 +838,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
             //"a" does not exist or it is another type, create it with size 1,1 and return it
             //create new structure variable
             pIT = new Struct(1, 1);
-            symbol::Context::getInstance()->put(pFirstField->getExp()->name_get(), *pIT);
+            symbol::Context::getInstance()->put(pFirstField->getExp()->stack_get(), pIT);
         }
         // else
         // is a call exp
@@ -851,7 +848,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
     else if (pIT->getRef() > 1 && pIT->isHandle() == false)
     {
         pIT = pIT->clone();
-        symbol::Context::getInstance()->put(pFirstField->getExp()->name_get(), *pIT);
+        symbol::Context::getInstance()->put(pFirstField->getExp()->stack_get(), pIT);
     }
     else if (pIT == _pAssignValue)
     {
@@ -883,7 +880,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
         {
             std::wostringstream os;
             os << _W("Wrong insertion : use extraction with {} only on a Cell.");
-            throw ScilabError(os.str(), 999, _pExp->location_get());
+            throw ast::ScilabError(os.str(), 999, _pExp->location_get());
         }
 
         if (pITCurrent->isStruct())
@@ -898,7 +895,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
                 {
                     std::wostringstream os;
                     os << _W("Invalid index.");
-                    throw ScilabError(os.str(), 999, _pExp->location_get());
+                    throw ast::ScilabError(os.str(), 999, _pExp->location_get());
                 }
 
                 // resize current struct
@@ -1258,7 +1255,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
                             {
                                 std::wostringstream os;
                                 os << _W("Invalid index.");
-                                throw ScilabError(os.str(), 999, _pExp->location_get());
+                                throw ast::ScilabError(os.str(), 999, _pExp->location_get());
                             }
 
                             // resize current Cell
@@ -1281,7 +1278,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
                             {
                                 std::wostringstream os;
                                 os << _W("Invalid index.");
-                                throw ScilabError(os.str(), 999, _pExp->location_get());
+                                throw ast::ScilabError(os.str(), 999, _pExp->location_get());
                             }
 
                             // resize current Cell
@@ -1297,7 +1294,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
                         // only a(x)
                         std::wostringstream os;
                         os << _W("Wrong insertion in a Cell.");
-                        throw ScilabError(os.str(), 999, _pExp->location_get());
+                        throw ast::ScilabError(os.str(), 999, _pExp->location_get());
                     }
                 }
             }
@@ -1305,7 +1302,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
             {
                 std::wostringstream os;
                 os << _W("Wrong insertion in a Cell.");
-                throw ScilabError(os.str(), 999, _pExp->location_get());
+                throw ast::ScilabError(os.str(), 999, _pExp->location_get());
             }
         }
         else
@@ -1343,7 +1340,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
                 {
                     std::wostringstream os;
                     os << _W("Wrong insertion in a Cell.");
-                    throw ScilabError(os.str(), 999, _pExp->location_get());
+                    throw ast::ScilabError(os.str(), 999, _pExp->location_get());
                 }
 
                 pCell->insertCell(pArgs, _pAssignValue);
@@ -1356,7 +1353,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
                 {
                     std::wostringstream os;
                     os << _W("Error in insertion of Struct.");
-                    throw ScilabError(os.str(), 999, _pExp->location_get());
+                    throw ast::ScilabError(os.str(), 999, _pExp->location_get());
                 }
 
                 if (pEH->setCurrent(pIT))
@@ -1392,7 +1389,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
                     {
                         std::wostringstream os;
                         os << _W("Error in insertion of TList.");
-                        throw ScilabError(os.str(), 999, _pExp->location_get());
+                        throw ast::ScilabError(os.str(), 999, _pExp->location_get());
                     }
 
                     if (pEH->getParent()->setCurrent(pIT))
@@ -1424,7 +1421,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
 
             if (pEHParent == NULL)
             {
-                symbol::Context::getInstance()->put(pEH->getExp()->name_get(), *pEH->getCurrent());
+                symbol::Context::getInstance()->put(pEH->getExp()->stack_get(), pEH->getCurrent());
                 break;
             }
 
@@ -1480,7 +1477,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
             {
                 std::wostringstream os;
                 os << _W("Error in insertion of Struct.");
-                throw ScilabError(os.str(), 999, _pExp->location_get());
+                throw ast::ScilabError(os.str(), 999, _pExp->location_get());
             }
 
             if (pEHParent->setCurrent(pIT))
@@ -1500,7 +1497,7 @@ types::InternalType* evaluateFields(const Exp* _pExp, std::list<ExpHistory*>& fi
     return symbol::Context::getInstance()->getCurrentLevel(pFirstField->getExp()->name_get());
 }
 
-InternalType* insertionCall(const Exp& e, typed_list* _pArgs, InternalType* _pVar, InternalType* _pInsert)
+InternalType* insertionCall(const ast::Exp& e, typed_list* _pArgs, InternalType* _pVar, InternalType* _pInsert)
 {
     InternalType* pOut = NULL;
     //fisrt extract implicit list
@@ -1609,7 +1606,7 @@ InternalType* insertionCall(const Exp& e, typed_list* _pArgs, InternalType* _pVa
                 //manage error
                 std::wostringstream os;
                 os << _W("Invalid Index.\n");
-                throw ScilabError(os.str(), 999, e.location_get());
+                throw ast::ScilabError(os.str(), 999, e.location_get());
             }
 
             pStr->addField(pS->get(0));
@@ -1836,7 +1833,7 @@ InternalType* insertionCall(const Exp& e, typed_list* _pArgs, InternalType* _pVa
                     //manage error
                     std::wostringstream os;
                     os << _W("Invalid Index.\n");
-                    throw ScilabError(os.str(), 999, e.location_get());
+                    throw ast::ScilabError(os.str(), 999, e.location_get());
                 }
 
                 pStruct->addField(pS->get(0));
@@ -1918,7 +1915,7 @@ InternalType* insertionCall(const Exp& e, typed_list* _pArgs, InternalType* _pVa
                         //manage error
                         std::wostringstream os;
                         os << _W("Invalid Index.\n");
-                        throw ScilabError(os.str(), 999, e.location_get());
+                        throw ast::ScilabError(os.str(), 999, e.location_get());
                     }
 
                     if (_pInsert->isListDelete())
@@ -2002,7 +1999,7 @@ InternalType* insertionCall(const Exp& e, typed_list* _pArgs, InternalType* _pVa
                 typed_list in;
                 typed_list out;
                 optional_list opt;
-                ExecVisitor exec;
+                ast::ExecVisitor exec;
 
                 in.push_back(pH);
                 in.push_back(pS);
@@ -2033,23 +2030,30 @@ InternalType* insertionCall(const Exp& e, typed_list* _pArgs, InternalType* _pVa
 
 void callOnPrompt(void)
 {
+    static symbol::Variable* onPrompt = NULL;
+
+    if (onPrompt == NULL)
+    {
+        onPrompt = symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"%onprompt"));
+    }
+
     types::InternalType* pOnPrompt = NULL;
-    pOnPrompt = symbol::Context::getInstance()->get(symbol::Symbol(L"%onprompt"));
+    pOnPrompt = onPrompt->get();
     if (pOnPrompt != NULL && pOnPrompt->isCallable())
     {
         types::typed_list in;
         types::typed_list out;
         types::optional_list opt;
-        ExecVisitor execCall;
+        ast::ExecVisitor execCall;
         pOnPrompt->getAs<types::Callable>()->call(in, opt, 1, out, &execCall);
     }
 }
 
-List* getPropertyTree(Exp* e, List* pList)
+List* getPropertyTree(ast::Exp* e, List* pList)
 {
 
     //a.b
-    SimpleVar* pVar = dynamic_cast<SimpleVar*>(e);
+    ast::SimpleVar* pVar = dynamic_cast<ast::SimpleVar*>(e);
     if (pVar)
     {
         pList->append(new String(pVar->name_get().name_get().c_str()));
@@ -2057,23 +2061,23 @@ List* getPropertyTree(Exp* e, List* pList)
     }
 
     //a(x).b
-    CallExp* pCall = dynamic_cast<CallExp*>(e);
+    ast::CallExp* pCall = dynamic_cast<ast::CallExp*>(e);
     if (pCall)
     {
         pList = getPropertyTree(&pCall->name_get(), pList);
-        ExecVisitor exec;
-        std::list<Exp*> l = pCall->args_get();
-        std::list<Exp*>::const_iterator it;
+        ast::ExecVisitor exec;
+        std::list<ast::Exp*> l = pCall->args_get();
+        std::list<ast::Exp*>::const_iterator it;
         for (it = l.begin() ; it != l.end() ; it++)
         {
-            Exp* pArg = (*it);
+            ast::Exp* pArg = (*it);
             try
             {
                 pArg->accept(exec);
                 pList->append(exec.result_get());
                 exec.result_clear();
             }
-            catch (ScilabException e)
+            catch (ast::ScilabException e)
             {
                 throw e;
             }
@@ -2083,7 +2087,7 @@ List* getPropertyTree(Exp* e, List* pList)
     }
 
     //a.b.c
-    FieldExp* pField = dynamic_cast<FieldExp*>(e);
+    ast::FieldExp* pField = dynamic_cast<ast::FieldExp*>(e);
     if (pField)
     {
         pList = getPropertyTree(pField->head_get(), pList);
@@ -15,7 +15,7 @@
 #define __SCI_TOOLS_H__
 
 #include "machine.h"
-#include "dynlib_elementary_functions.h"
+#include "dynlib_core.h"
 
 #define DATA_TYPE_SCALAR     1
 
 #define SET_NB_COL(ptr,m) (((int*) (ptr))[-2] = (m))
 #define SET_NB_ROW(ptr,n) (((int*) (ptr))[-3] = (n))
 
-ELEMENTARY_FUNCTIONS_IMPEXP void SciToF77(double *ptr, int size, int lda);
-ELEMENTARY_FUNCTIONS_IMPEXP void F77ToSci(double *ptr, int size, int lda);
-
-ELEMENTARY_FUNCTIONS_IMPEXP void double2z(double *ptr, double *ptr77z, int size, int lda);
-ELEMENTARY_FUNCTIONS_IMPEXP void z2double(double *ptrz, double *ptrsci, int size, int lda);
+//CORE_IMPEXP void SciToF77(double *ptr, int size, int lda);
+//CORE_IMPEXP void F77ToSci(double *ptr, int size, int lda);
+//
+//CORE_IMPEXP void double2z(double *ptr, double *ptr77z, int size, int lda);
+//CORE_IMPEXP void z2double(double *ptrz, double *ptrsci, int size, int lda);
 
 #endif /* __SCI_TOOLS_H__ */
index 1ffcf58..463db4f 100644 (file)
 
 #include "machine.h"
 
-/**
- * Convert an Scilab array of double to a fortran format
- *
- * @param ptr the array of double
- * @param size size of the array
- * @param lda
- */
-//void SciToF77(double *ptr, int size, int lda);
-
-/**
- * Convert an Fortran array of double to a Scilab format
- *
- * @param ptr the array of double
- * @param size size of the array
- * @param lda
- */
-void F77ToSci(double *ptr, int size, int lda);
-void double2z(double *ptr,  double *ptr77z, int size, int lda);
-void z2double(double *ptrz, double *ptrsci, int size, int lda);
-
 /* from int */
 
 extern  int C2F(tpconv)(int *, int *, int *, void *, int *, void *, int *);
index 16cdddf..dd8e569 100644 (file)
@@ -25,6 +25,9 @@ using namespace types;
 
 types::Function::ReturnValue sci_argn(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
+    static symbol::Variable* varIn = NULL;
+    static symbol::Variable* varOut = NULL;
+
     int iRhs = static_cast<int>(in.size());
     //check input arguments
     if (iRhs > 1)
@@ -67,8 +70,22 @@ types::Function::ReturnValue sci_argn(types::typed_list &in, int _iRetCount, typ
     }
 
     symbol::Context* pContext = symbol::Context::getInstance();
-    InternalType *pOut = pContext->get(symbol::Symbol(L"nargout"));
-    InternalType *pIn = pContext->get(symbol::Symbol(L"nargin"));
+
+    InternalType *pIn = NULL;
+    InternalType *pOut = NULL;
+
+    if (varIn == NULL)
+    {
+        varIn = symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"nargin"));
+    }
+
+    if (varOut == NULL)
+    {
+        varOut = symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"nargout"));
+    }
+
+    pIn = pContext->get(varIn);
+    pOut = pContext->get(varOut);
 
     if (pIn == NULL || pOut == NULL)
     {
index 8c138e8..8bc6dc2 100644 (file)
@@ -30,6 +30,13 @@ Function::ReturnValue sci_clear(types::typed_list &in, int _iRetCount, types::ty
     types::typed_list::iterator inIterator;
     int iWrongType = 1;
 
+    if (in.size() == 0)
+    {
+        //clear();
+        symbol::Context::getInstance()->removeAll();
+        return Function::OK;
+    }
+
     // First check if all arguments are Single Strings.
     for (inIterator = in.begin() ; inIterator != in.end() ; iWrongType++, inIterator++)
     {
index 78026df..bd9eeb8 100644 (file)
@@ -52,34 +52,38 @@ types::Function::ReturnValue sci_global(types::typed_list &in, int _iRetCount, t
 
     for (int i = 0 ; i < in.size() ; i++)
     {
-        symbol::Symbol pstVar = *new symbol::Symbol(in[i]->getAs<types::String>()->get(0));
+        symbol::Symbol pstVar(symbol::Symbol(in[i]->getAs<types::String>()->get(0)));
 
-        //does it visible in current global scope
-        if (pCtx->isGlobalVisible(pstVar) == false)
+        if (pCtx->isGlobalVisible(pstVar))
         {
-            //does it exist in global
-            if (pCtx->isGlobalExists(pstVar) == false)
-            {
-                InternalType* pIT = pCtx->get(pstVar);
+            continue;
+        }
+
+        types::InternalType* pIT = NULL;
 
-                //create a empty global variable => []
-                pCtx->createEmptyGlobalValue(pstVar);
+        if (pCtx->isGlobal(pstVar))
+        {
+            pIT = pCtx->getGlobalValue(pstVar);
+        }
+        else
+        {
+            pIT = pCtx->getCurrentLevel(pstVar);
+            pCtx->setGlobal(pstVar);
+        }
 
-                //set visible in current global scope
-                pCtx->setGlobalVisible(pstVar);
+        //set global variable visible in current scope
+        pCtx->setGlobalVisible(pstVar, true);
 
-                if (pIT)
-                {
-                    //assign old local value
-                    pCtx->put(pstVar, *pIT);
-                }
-            }
-            else
-            {
-                //set visible in current global scope
-                pCtx->setGlobalVisible(pstVar);
-            }
+        if (pIT)
+        {
+            //assign local value to new global variable
+            pCtx->put(pstVar, pIT);
         }
+        else
+        {
+            pCtx->put(pstVar, types::Double::Empty());
+        }
+
     }
     return types::Function::OK;
 }
index c4d15cb..9d1d4ad 100644 (file)
@@ -50,7 +50,7 @@ Function::ReturnValue sci_isglobal(types::typed_list &in, int _iRetCount, types:
             return Function::Error;
         }
 
-        if (symbol::Context::getInstance()->isGlobalExists(symbol::Symbol(pS->get(0))))
+        if (symbol::Context::getInstance()->isGlobalVisible(symbol::Symbol(pS->get(0))))
         {
             out.push_back(new types::Bool(1));
         }
index f73c439..34a4845 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 
+#include <sstream>
 #include "core_gw.hxx"
 #include "function.hxx"
 #include "context.hxx"
index 76f8ef4..91f5a5d 100644 (file)
@@ -384,6 +384,7 @@ cd ..
     <ClInclude Include="..\..\includes\scimem.h" />
     <ClInclude Include="..\..\includes\scirun.h" />
     <ClInclude Include="..\..\includes\scisparse.h" />
+    <ClInclude Include="..\..\includes\sci_tools.h" />
     <ClInclude Include="..\..\includes\sci_types.h" />
     <ClInclude Include="..\..\includes\setformat.h" />
     <ClInclude Include="..\..\includes\setieee.h" />
index 50dce2f..ff6ef27 100644 (file)
     <ClInclude Include="..\..\includes\getmacrosname.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\includes\sci_tools.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\core.iss" />
index e849560..cf69db4 100644 (file)
 #include "localization.h"
 #include "Scierror.h"
 
-void SciToF77(double *ptr, int size, int lda)
-{
-    int i;
-    double *tab;
-
-    if ((tab = (double *) MALLOC(size * sizeof(double))) == NULL)
-    {
-        Scierror(999, _("%s: No more memory.\n"), "SciToF77");
-        return;
-    }
-
-    /* for (i = size; --i >= 0; ) { */
-    /*     tab[i] = ptr[i]; */
-    /*   } */
-
-    memcpy(tab, ptr, size * sizeof(double));
-
-    for (i = 0; i < size; ++i)
-    {
-        ptr[2 * i] = tab[i];
-        ptr[2 * i + 1] = ptr[lda + i];
-    }
-
-    FREE(tab);
-} /* SciToF77 */
-
-
-void F77ToSci(double *ptr, int size, int lda)
-{
-    int i;
-    double *tab;
-
-    if ((tab = (double *) MALLOC(size * sizeof(double))) == NULL)
-    {
-        Scierror(999, _("%s: No more memory.\n"), "F77ToSci");
-        return;
-    }
-
-    for (i = 0; i < size; ++i)
-    {
-        tab[i] = ptr[2 * i + 1];
-        ptr[i] = ptr[2 * i];
-    }
-
-    memcpy(ptr + lda, tab, size * sizeof(double));
-
-    /*   for (i = size; --i >= 0; ) { */
-    /*     ptr[lda+i] = tab[i]; */
-    /*   } */
-
-    FREE(tab);
-} /* F77ToSci */
+//void SciToF77(double *ptr, int size, int lda)
+//{
+//    int i;
+//    double *tab;
+//
+//    if ((tab = (double *) MALLOC(size * sizeof(double))) == NULL)
+//    {
+//        Scierror(999, _("%s: No more memory.\n"), "SciToF77");
+//        return;
+//    }
+//
+//    /* for (i = size; --i >= 0; ) { */
+//    /*     tab[i] = ptr[i]; */
+//    /*   } */
+//
+//    memcpy(tab, ptr, size * sizeof(double));
+//
+//    for (i = 0; i < size; ++i)
+//    {
+//        ptr[2 * i] = tab[i];
+//        ptr[2 * i + 1] = ptr[lda + i];
+//    }
+//
+//    FREE(tab);
+//} /* SciToF77 */
+//
+//
+//void F77ToSci(double *ptr, int size, int lda)
+//{
+//    int i;
+//    double *tab;
+//
+//    if ((tab = (double *) MALLOC(size * sizeof(double))) == NULL)
+//    {
+//        Scierror(999, _("%s: No more memory.\n"), "F77ToSci");
+//        return;
+//    }
+//
+//    for (i = 0; i < size; ++i)
+//    {
+//        tab[i] = ptr[2 * i + 1];
+//        ptr[i] = ptr[2 * i];
+//    }
+//
+//    memcpy(ptr + lda, tab, size * sizeof(double));
+//
+//    /*   for (i = size; --i >= 0; ) { */
+//    /*     ptr[lda+i] = tab[i]; */
+//    /*   } */
+//
+//    FREE(tab);
+//} /* F77ToSci */
 
 
 /* double2z and z2double : same as above with two pointers dest and src
    double2z ptr = src, ptr77z = dest (z format)
    z2double ptr = src (z format) , ptrsci = dest */
 
-void
-double2z(double *ptr, double *ptr77z, int size, int lda)
-{
-    int i;
-    double *tab;
-
-    if ((tab = (double *) MALLOC(size * sizeof(double))) == NULL)
-    {
-        Scierror(999, _("%s: No more memory.\n"), "double2z");
-        return;
-    }
-
-    memcpy(tab, ptr, size * sizeof(double));
-
-    for (i = 0; i < size; ++i)
-    {
-        ptr77z[2 * i] = tab[i];
-        ptr77z[2 * i + 1] = ptr[lda + i];
-    }
-
-    FREE(tab);
-}
+//void double2z(double *ptr, double *ptr77z, int size, int lda)
+//{
+//    int i;
+//    double *tab;
+//
+//    if ((tab = (double *) MALLOC(size * sizeof(double))) == NULL)
+//    {
+//        Scierror(999, _("%s: No more memory.\n"), "double2z");
+//        return;
+//    }
+//
+//    memcpy(tab, ptr, size * sizeof(double));
+//
+//    for (i = 0; i < size; ++i)
+//    {
+//        ptr77z[2 * i] = tab[i];
+//        ptr77z[2 * i + 1] = ptr[lda + i];
+//    }
+//
+//    FREE(tab);
+//}
 
 
 //
@@ -192,27 +191,26 @@ double2z(double *ptr, double *ptr77z, int size, int lda)
 //   The Scilab internal representation is block-ordered, that is
 //   R1, ..., Rn, I1, ..., In.
 //
-void
-z2double(double *ptrz, double *ptrsci, int size, int lda)
-{
-    int i;
-    double *tab;
-
-    if ((tab = (double *) MALLOC(size * sizeof(double))) == NULL)
-    {
-        Scierror(999, _("%s: No more memory.\n"), "z2double");
-        return;
-    }
-    // Put the real parts in place and stores the imaginary parts
-    // in the array tab.
-    for (i = 0; i < size; ++i)
-    {
-        tab[i] = ptrz[2 * i + 1]; // imaginary part
-        ptrsci[i] = ptrz[2 * i]; // real part
-    }
-    // Puts the imaginary parts in the imaginary block.
-    memcpy(ptrsci + lda, tab, size * sizeof(double));
-
-    FREE(tab);
-}
+//void z2double(double *ptrz, double *ptrsci, int size, int lda)
+//{
+//    int i;
+//    double *tab;
+//
+//    if ((tab = (double *) MALLOC(size * sizeof(double))) == NULL)
+//    {
+//        Scierror(999, _("%s: No more memory.\n"), "z2double");
+//        return;
+//    }
+//    // Put the real parts in place and stores the imaginary parts
+//    // in the array tab.
+//    for (i = 0; i < size; ++i)
+//    {
+//        tab[i] = ptrz[2 * i + 1]; // imaginary part
+//        ptrsci[i] = ptrz[2 * i]; // real part
+//    }
+//    // Puts the imaginary parts in the imaginary block.
+//    memcpy(ptrsci + lda, tab, size * sizeof(double));
+//
+//    FREE(tab);
+//}
 
index 15e67b7..e3ed038 100644 (file)
@@ -98,6 +98,8 @@ static int interactiveMain(ScilabEngineInfo* _pSEI);
 static Parser::ControlStatus processCommand(ScilabEngineInfo* _pSEI);
 static void stateShow(Parser::ControlStatus status);
 
+using namespace ast;
+
 ScilabEngineInfo* InitScilabEngineInfo()
 {
     ScilabEngineInfo* pSEI = (ScilabEngineInfo*)MALLOC(sizeof(ScilabEngineInfo));
@@ -764,7 +766,7 @@ static void Add_Poly_Constant(wstring _szName, wstring _szPolyVar, int _iRank, D
     SinglePoly *poPoly = pVar->get(0, 0);
 
     poPoly->setCoef(_pdbl);
-    symbol::Context::getInstance()->put(symbol::Symbol(_szName), *pVar);
+    symbol::Context::getInstance()->put(symbol::Symbol(_szName), pVar);
 }
 
 static void Add_Double_Constant(wstring _szName, double _dblReal, double _dblImg, bool _bComplex)
@@ -772,17 +774,17 @@ static void Add_Double_Constant(wstring _szName, double _dblReal, double _dblImg
     types::Double * pVal = new types::Double(1, 1, _bComplex);
     pVal->set(0, 0, _dblReal);
     pVal->setImg(0, 0, _dblImg);
-    symbol::Context::getInstance()->put(symbol::Symbol(_szName), *pVal);
+    symbol::Context::getInstance()->put(symbol::Symbol(_szName), pVal);
 }
 
 static void Add_Boolean_Constant(wstring _szName, bool _bBool)
 {
     types::Bool * pVal = new types::Bool(_bBool);
-    symbol::Context::getInstance()->put(symbol::Symbol(_szName), *pVal);
+    symbol::Context::getInstance()->put(symbol::Symbol(_szName), pVal);
 }
 
 static void Add_String_Constant(wstring _szName, const char *_pstString)
 {
     types::String * ps = new types::String(_pstString);
-    symbol::Context::getInstance()->put(symbol::Symbol(_szName), *ps);
+    symbol::Context::getInstance()->put(symbol::Symbol(_szName), ps);
 }
index cc11fb8..63fbb1e 100644 (file)
 extern "C" {
 #include "MALLOC.h"
 #include "getfunctionsname.h"
+#include "charEncoding.h"
 }
 /*----------------------------------------------------------------------------------*/
 char **getFunctionsName(int *sizearray)
 {
     std::list<std::wstring>* plMacrosList = symbol::Context::getInstance()->getFunctionsName();
-    std::list<std::wstring>::iterator it;
     *sizearray = (int)plMacrosList->size();
-    char** functions = (char**)MALLOC(*sizearray * sizeof(char*));
+    char** functions = NULL;
+    if (*sizearray != 0)
+    {
+        functions = (char**)MALLOC(*sizearray * sizeof(char*));
 
-    plMacrosList->sort();
+        plMacrosList->sort();
 
-    int i = 0;
-    for (it = plMacrosList->begin(); it != plMacrosList->end(); ++it, i++)
-    {
-        functions[i] = wide_string_to_UTF8((*it).c_str());
+        std::list<std::wstring>::iterator it = plMacrosList->begin();
+        for (int i = 0; it != plMacrosList->end(); ++it, i++)
+        {
+            functions[i] = wide_string_to_UTF8((*it).c_str());
+        }
+
+        delete plMacrosList;
     }
 
-    delete plMacrosList;
     return functions;
 }
index d2bbf99..064e22a 100644 (file)
 extern "C" {
 #include "MALLOC.h"
 #include "getmacrosname.h"
+#include "charEncoding.h"
 }
 /*----------------------------------------------------------------------------------*/
 char **getMacrosName(int *sizearray)
 {
     std::list<std::wstring>* plMacrosList = symbol::Context::getInstance()->getMacrosName();
-    std::list<std::wstring>::iterator it;
 
     //sort list
     plMacrosList->sort();
@@ -28,16 +28,20 @@ char **getMacrosName(int *sizearray)
     plMacrosList->unique();
 
     *sizearray = (int)plMacrosList->size();
-    char** macros = (char**)MALLOC(*sizearray * sizeof(char*));
+    char** macros = NULL;
+    if (*sizearray != 0)
+    {
+        macros = (char**)MALLOC(*sizearray * sizeof(char*));
 
+        std::list<std::wstring>::iterator it = plMacrosList->begin();
+        for (int i = 0; it != plMacrosList->end(); ++it, i++)
+        {
+            macros[i] = wide_string_to_UTF8((*it).c_str());
+        }
 
-    int i = 0;
-    for (it = plMacrosList->begin(); it != plMacrosList->end(); ++it, i++)
-    {
-        macros[i] = wide_string_to_UTF8((*it).c_str());
+        delete plMacrosList;
     }
 
-    delete plMacrosList;
     return macros;
 }
 /*----------------------------------------------------------------------------------*/
index 7289df3..6927923 100644 (file)
 extern "C" {
 #include "MALLOC.h"
 #include "getvariablesname.h"
+#include "charEncoding.h"
 }
 /*----------------------------------------------------------------------------------*/
 char **getVariablesName(int *sizearray, BOOL sorted)
 {
     std::list<std::wstring>* plVarNames = symbol::Context::getInstance()->getVarsName();
-    std::list<std::wstring>::iterator it;
     *sizearray = (int)plVarNames->size();
-    char** variables = (char**)MALLOC(*sizearray * sizeof(char*));
+    char** variables = NULL;
 
-    if (sorted)
+    if (*sizearray != 0)
     {
-        plVarNames->sort();
-    }
+        variables = (char**)MALLOC(*sizearray * sizeof(char*));
 
-    int i = 0;
-    for (it = plVarNames->begin(); it != plVarNames->end(); ++it, i++)
-    {
-        variables[i] = wide_string_to_UTF8((*it).c_str());
+        if (sorted)
+        {
+            plVarNames->sort();
+        }
+
+        std::list<std::wstring>::iterator it = plVarNames->begin();
+        for (int i = 0; it != plVarNames->end(); ++it, i++)
+        {
+            variables[i] = wide_string_to_UTF8((*it).c_str());
+        }
+
+        delete plVarNames;
     }
 
-    delete plVarNames;
     return variables;
 }
 
index ce0d839..8f533f7 100644 (file)
@@ -16,6 +16,8 @@ __threadLock Runner::m_lock;
 __threadSignal Runner::m_awakeScilab;
 __threadSignalLock Runner::m_awakeScilabLock;
 
+using namespace ast;
+
 void Runner::init()
 {
     __InitSignal(&m_awakeScilab);
index d72f9cd..3539001 100644 (file)
@@ -22,6 +22,7 @@ extern "C"
 #include "scilabWrite.hxx"
 #include "scilabexception.hxx"
 
+using namespace ast;
 /*--------------------------------------------------------------------------*/
 /*
  *  Command queue functions
index bdca3d4..0422107 100644 (file)
@@ -291,7 +291,6 @@ lib /DEF:"$(ProjectDir)cacsd_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfor
     <ClInclude Include="..\..\includes\rea2b.h" />
     <ClInclude Include="..\..\includes\rea2db.h" />
     <ClInclude Include="..\..\includes\scidcopy.h" />
-    <ClInclude Include="..\..\includes\sci_tools.h" />
     <ClInclude Include="..\..\includes\sign.h" />
     <ClInclude Include="..\..\includes\sin.h" />
     <ClInclude Include="..\..\includes\sqrt.h" />
index 1632f5c..87fabad 100644 (file)
     <ClInclude Include="..\cpp\prod.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\includes\sci_tools.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\includes\gsort.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
index 11a774f..30e99ba 100644 (file)
@@ -22,14 +22,12 @@ extern "C"
 }
 
 
-using namespace types;
-
-int getMode(typed_list &in, int _iProcess, int _iRef)
+int getMode(types::typed_list &in, int _iProcess, int _iRef)
 {
     int iMode = 0;
     if (in[_iProcess]->isString())
     {
-        String* pS = in[_iProcess]->getAs<String>();
+        types::String* pS = in[_iProcess]->getAs<types::String>();
         if (pS->getSize() != 1)
         {
             Scierror(999, _("%s: Wrong size for argument %d: (%d,%d) expected.\n"), "size", _iProcess + 1, 1, 1);
@@ -55,9 +53,9 @@ int getMode(typed_list &in, int _iProcess, int _iRef)
                 break;
         }
     }
-    else if (in[1]->isDouble() && in[1]->getAs<Double>()->isComplex() == false)
+    else if (in[1]->isDouble() && in[1]->getAs<types::Double>()->isComplex() == false)
     {
-        Double* pD = in[_iProcess]->getAs<Double>();
+        types::Double* pD = in[_iProcess]->getAs<types::Double>();
         if (pD->getSize() != 1)
         {
             Scierror(999, _("%s: Wrong size for argument %d: (%d,%d) expected.\n"), "size", _iProcess + 1, 1, 1);
@@ -87,11 +85,11 @@ int getMode(typed_list &in, int _iProcess, int _iRef)
     if (iMode == -1)
     {
         iMode = 0;
-        if (in[_iRef]->getAs<GenericType>()->getRows() > 1)
+        if (in[_iRef]->getAs<types::GenericType>()->getRows() > 1)
         {
             iMode = 1;
         }
-        else if (in[_iRef]->getAs<GenericType>()->getCols() > 1)
+        else if (in[_iRef]->getAs<types::GenericType>()->getCols() > 1)
         {
             iMode = 2;
         }
index dfb479e..465f39a 100644 (file)
@@ -20,8 +20,6 @@
 #include "file.hxx"
 
 using namespace std;
-using namespace types;
-
 class FILEIO_IMPEXP FileManager
 {
     //static attributs instantiation
@@ -30,9 +28,9 @@ public :
     static int                  getFileMaxID();
     static bool                 isOpened(wstring _stFilename);
     static int                  getFileID(wstring _stFilename);
-    static File*                getFile(int _iID);
+    static types::File*         getFile(int _iID);
     static int                  getCurrentFile();
-    static int                  addFile(File* _file);
+    static int                  addFile(types::File* _file);
     static int                  getFirstFreeFileID();
     static void                 deleteFile(int _iID);
     static int                  getOpenedCount();
@@ -45,10 +43,9 @@ public :
     static void                 initialize();
     static void                 destroy();
 private :
-    typedef std::vector<File*>  vectFile;
+    typedef std::vector<types::File*>  vectFile;
     static vectFile             m_fileList;
     static int                  m_iCurrentFile;     //memorize current using file
-
 };
 
 #endif /* __FILEMANAGER_HXX__ */
index d2c620f..004c90a 100644 (file)
@@ -23,6 +23,9 @@ extern "C"
 #include "deleteafile.h"
 #include "localization.h"
 }
+
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_deletefile(typed_list &in, int _iRetCount, typed_list &out)
 {
index d517642..67ec1b5 100644 (file)
@@ -23,6 +23,9 @@ extern "C"
 #include "splitpath.h"
 #include "localization.h"
 }
+
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_fileext(typed_list &in, int _iRetCount, typed_list &out)
 {
index 9c5981a..807c6ac 100644 (file)
@@ -35,6 +35,8 @@ enum PartialPart
 #define FILEPARTS_PATH_SELECTOR L"path"
 #define FILEPARTS_FNAME_SELECTOR L"fname"
 #define FILEPARTS_EXTENSION_SELECTOR L"extension"
+
+using namespace types;
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_fileparts(typed_list &in, int _iRetCount, typed_list &out)
 {
index d25d279..93580f4 100644 (file)
@@ -26,6 +26,8 @@ extern "C"
 #include "os_wcsicmp.h"
 }
 
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_filesep(typed_list &in, int _iRetCount, typed_list &out)
 {
index d536205..f4e79a1 100644 (file)
@@ -25,9 +25,10 @@ extern "C"
 #include "Scierror.h"
 #include "localization.h"
 }
-/*--------------------------------------------------------------------------*/
 
+using namespace types;
 
+/*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_get_absolute_file_path(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
     int dimsArray[2]                = {1, 1};
index 5be3d93..eb79c0d 100644 (file)
@@ -30,8 +30,10 @@ extern "C"
 #include "localization.h"
 #include "getrelativefilename.h"
 }
-/*--------------------------------------------------------------------------*/
 
+using namespace types;
+
+/*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_getrelativefilename(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
     wchar_t* wcsAbsDir  = NULL;
index 41cd9ad..9732d4f 100644 (file)
@@ -28,9 +28,10 @@ extern "C"
 #include "Scierror.h"
 #include "localization.h"
 }
-/*--------------------------------------------------------------------------*/
 
+using namespace types;
 
+/*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_mclearerr(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
     int iRet  = 0;
index 81e8100..9df30ca 100644 (file)
@@ -28,6 +28,9 @@ extern "C"
 #include "localization.h"
 #include "PATH_MAX.h"
 }
+
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 types::Function::ReturnValue sci_meof(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
index a5d07ea..f0fd3dc 100644 (file)
@@ -24,8 +24,10 @@ extern "C"
 #include "Scierror.h"
 #include "localization.h"
 }
-/*--------------------------------------------------------------------------*/
 
+using namespace types;
+
+/*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_merror(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
     int iRet  = 0;
index d6dfd9c..88f1527 100644 (file)
@@ -35,6 +35,9 @@ extern "C"
 #ifdef _MSC_VER
 static BOOL forceSTDERRredirect = TRUE;
 #endif
+
+using namespace types;
+using namespace ast;
 /*--------------------------------------------------------------------------*/
 
 Function::ReturnValue sci_mfprintf(types::typed_list &in, int _iRetCount, types::typed_list &out)
index b9bf5f8..28a007a 100644 (file)
@@ -27,6 +27,9 @@ extern "C"
 #include "charEncoding.h"
 #include "os_strdup.h"
 }
+
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_mget(typed_list &in, int _iRetCount, typed_list &out)
 {
index e8078cd..9e742d5 100644 (file)
@@ -28,6 +28,8 @@ extern "C"
 #include "expandPathVariable.h"
 }
 
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_mgetl(typed_list &in, int _iRetCount, typed_list &out)
 {
index b784d30..4293ef3 100644 (file)
@@ -27,6 +27,9 @@ extern "C"
 #include "charEncoding.h"
 #include "mgetstr.h"
 }
+
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_mgetstr(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
index 90722f2..b88d882 100644 (file)
@@ -28,6 +28,9 @@ extern "C"
 #include "charEncoding.h"
 #include "os_strdup.h"
 }
+
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_mput(typed_list &in, int _iRetCount, typed_list &out)
 {
index 9ec6cac..47c09bc 100644 (file)
@@ -27,6 +27,9 @@ extern "C"
 #include "mclose.h"
 #include "expandPathVariable.h"
 }
+
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_mputl(typed_list &in, int _iRetCount, typed_list &out)
 {
index d397e87..a275b50 100644 (file)
@@ -27,6 +27,9 @@ extern "C"
 #include "Scierror.h"
 #include "charEncoding.h"
 }
+
+using namespace types;
+
 /*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_mputstr(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
index 1e946fd..0ba519e 100644 (file)
@@ -36,6 +36,8 @@ char *strerror (int errcode);
 #define SEEK_CUR 1
 #define SEEK_END 2
 #endif
+
+using namespace types;
 /*--------------------------------------------------------------------------*/
 
 Function::ReturnValue sci_mseek(types::typed_list &in, int _iRetCount, types::typed_list &out)
index ecc0123..31e4225 100644 (file)
@@ -26,6 +26,7 @@ extern "C"
 #include "mtell.h"
 }
 
+using namespace types;
 
 types::Function::ReturnValue sci_mtell(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
index 58728f2..382a3fb 100644 (file)
@@ -35,21 +35,22 @@ struct VARIABLEALIAS
 {
     wchar_t *Alias;
     wchar_t *VariableName;
+    symbol::Variable* var;
 };
 /*--------------------------------------------------------------------------*/
 #define NB_ALIAS 7
 static struct VARIABLEALIAS VARIABLES_words[NB_ALIAS] =
 {
-    {L"SCIHOME", L"SCIHOME"},
-    {L"WSCI", L"WSCI"},
-    {L"SCI", L"SCI"},
-    {L"~", L"home"},
-    {L"HOME", L"home"},
-    {L"home", L"home"},
-    {L"TMPDIR", L"TMPDIR"}
+    {L"SCIHOME", L"SCIHOME", NULL},
+    {L"WSCI", L"WSCI", NULL},
+    {L"SCI", L"SCI", NULL},
+    {L"~", L"home", NULL},
+    {L"HOME", L"home", NULL},
+    {L"home", L"home", NULL},
+    {L"TMPDIR", L"TMPDIR", NULL}
 };
 /*--------------------------------------------------------------------------*/
-static wchar_t *getVariableValueDefinedInScilab(wchar_t *wcVarName);
+static wchar_t *getVariableValueDefinedInScilab(VARIABLEALIAS* var);
 static wchar_t *convertFileSeparators(wchar_t *wcStr);
 /*--------------------------------------------------------------------------*/
 wchar_t *expandPathVariableW(wchar_t *wcstr)
@@ -67,7 +68,7 @@ wchar_t *expandPathVariableW(wchar_t *wcstr)
             /* input is ALIAS without subdirectory */
             if (wcscmp(VARIABLES_words[i].Alias, wcstr) == 0)
             {
-                wchar_t *wcexpanded = getVariableValueDefinedInScilab(VARIABLES_words[i].VariableName);
+                wchar_t *wcexpanded = getVariableValueDefinedInScilab(&VARIABLES_words[i]);
                 if (wcexpanded)
                 {
                     return convertFileSeparators(wcexpanded);
@@ -88,7 +89,7 @@ wchar_t *expandPathVariableW(wchar_t *wcstr)
                     {
                         if ( (wcstr[lenAlias] == L'/') || (wcstr[lenAlias] == L'\\') )
                         {
-                            wchar_t * newBegin = getVariableValueDefinedInScilab(VARIABLES_words[i].VariableName);
+                            wchar_t * newBegin = getVariableValueDefinedInScilab(&VARIABLES_words[i]);
                             if (newBegin)
                             {
                                 int lengthnewBegin = (int)wcslen(newBegin);
@@ -145,12 +146,17 @@ char *expandPathVariable(char* str)
     return expanded;
 }
 /*--------------------------------------------------------------------------*/
-wchar_t *getVariableValueDefinedInScilab(wchar_t *wcVarName)
+wchar_t *getVariableValueDefinedInScilab(VARIABLEALIAS* _var)
 {
-    if (wcVarName)
+    if (_var)
     {
-        types::InternalType *pIT = symbol::Context::getInstance()->get(symbol::Symbol(wcVarName));
-        if (pIT->isString() == false)
+        if (_var->var == NULL)
+        {
+            _var->var = symbol::Context::getInstance()->getOrCreate(symbol::Symbol(_var->VariableName));
+        }
+
+        types::InternalType *pIT = _var->var->get();
+        if (pIT == NULL || pIT->isString() == false)
         {
             return NULL;
         }
index dbba697..fe76edd 100644 (file)
@@ -238,21 +238,21 @@ double* FileManager::getSwaps()
 
 void FileManager::initialize()
 {
-    File* pErr = new File();
+    types::File* pErr = new types::File();
     pErr->setFileMode(L"wb");
     pErr->setFileDesc(stderr);
     pErr->setFileSwap(0);
     pErr->setFileType(1);
     pErr->setFilename(L"stderr");
 
-    File* pIn = new File();
+    types::File* pIn = new types::File();
     pIn->setFileMode(L"rb");
     pIn->setFileDesc(stdin);
     pIn->setFileSwap(0);
     pIn->setFileType(1);
     pIn->setFilename(L"stdin");
 
-    File* pOut = new File();
+    types::File* pOut = new types::File();
     pOut->setFileMode(L"wb");
     pOut->setFileDesc(stdout);
     pOut->setFileSwap(0);
index 27c1e8e..12f3b32 100644 (file)
@@ -82,7 +82,7 @@ void C2F(mgetnc)(int* fd, void* res, int* n1, const char* type, int* ierr)
     int items   = *n1;
     int n       = *n1;
     FILE* fa; // used in MGET_GEN_NC => MGET_NC
-    File* pFile = FileManager::getFile(*fd);
+    types::File* pFile = FileManager::getFile(*fd);
 
     *ierr = 0;
 
@@ -244,7 +244,7 @@ void C2F(mget) (int *fd, double *res, int *n, const char *type, int *ierr)
         return;
     }
 
-    File* pFile = FileManager::getFile(*fd);
+    types::File* pFile = FileManager::getFile(*fd);
     if (pFile && pFile->getFiledesc())
     {
         mget2(pFile->getFiledesc(), pFile->getFileSwap(), res, *n, type, ierr);
index 9e71eca..4924cd8 100644 (file)
@@ -41,14 +41,14 @@ extern "C"
 /*--------------------------------------------------------------------------*/
 static wchar_t *removeEOL(wchar_t *_inString);
 static char *convertAnsiToUtf(char *_inString);
-static wchar_t* getLine(wchar_t* _pstLine, int _iLineSize, File* _pFile);
+static wchar_t* getLine(wchar_t* _pstLine, int _iLineSize, types::File* _pFile);
 /*--------------------------------------------------------------------------*/
 #define UTF_16BE_BOM 0xFEFF // 0xFEFF = to_wide_string(0xEFBBBF)
 /*--------------------------------------------------------------------------*/
 wchar_t **mgetl(int fd, int nbLinesIn, int *nbLinesOut, int *ierr)
 {
     wchar_t **strLines = NULL;
-    File* pFile     = NULL;
+    types::File* pFile = NULL;
     int iLineSizeMult = 1;
     *ierr = MGETL_ERROR;
     *nbLinesOut = 0;
@@ -246,7 +246,7 @@ wchar_t **mgetl(int fd, int nbLinesIn, int *nbLinesOut, int *ierr)
     return strLines;
 }
 /*--------------------------------------------------------------------------*/
-wchar_t* getLine(wchar_t* _pstLine, int _iLineSize, File* _pFile)
+wchar_t* getLine(wchar_t* _pstLine, int _iLineSize, types::File* _pFile)
 {
     if (_pFile->getFileModeAsInt() % 2 == 1)
     {
index 39fa519..70d97d8 100644 (file)
@@ -24,7 +24,7 @@ extern "C"
 wchar_t* mgetstr(int _iFileId, int _iSizeToRead)
 {
     wchar_t* pwstOut = NULL;
-    File* pF = FileManager::getFile(_iFileId);
+    types::File* pF = FileManager::getFile(_iFileId);
 
     if (pF != NULL)
     {
index 6a83d6f..bf5ae93 100644 (file)
@@ -254,7 +254,7 @@ void C2F(mput) (int *fd, double *res, int *n, char *type, int *ierr)
         return;
     }
 
-    File *pFile = FileManager::getFile(*fd);
+    types::File *pFile = FileManager::getFile(*fd);
     if (pFile && pFile->getFiledesc())
     {
         mput2(pFile->getFiledesc(), pFile->getFileSwap(), res, *n, type, ierr);
index 9976999..46119bd 100644 (file)
@@ -28,7 +28,7 @@ extern "C"
 mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings, BOOL _CR)
 {
     int i = 0;
-    File* pF = NULL;
+    types::File* pF = NULL;
 
     if (pstStrings == NULL)
     {
index 2319937..f6b1286 100644 (file)
@@ -32,7 +32,7 @@ int mseek(int fd, long long offset, int iflag)
     int irep;
 #endif
 
-    File* pF = FileManager::getFile(fd);
+    types::File* pF = FileManager::getFile(fd);
     if (pF == NULL)
     {
         sciprint(_("%s: No input file associated to logical unit %d.\n"), "mseek", fd);
index eeadc24..5d19452 100644 (file)
@@ -25,7 +25,7 @@ extern "C"
 /*--------------------------------------------------------------------------*/
 long long mtell(int fd)
 {
-    File* pF        = FileManager::getFile(fd);
+    types::File* pF = FileManager::getFile(fd);
     long long offset = -1;
 
     if (pF == NULL)
index 32b253c..88a5ba5 100644 (file)
@@ -312,11 +312,11 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
                             {
                                 wchar_t szError[bsiz];
                                 os_swprintf(szError, bsiz, _W("at line % 5d of function %ls called by :\n"), (*j)->location_get().first_line, pCall->getName().c_str());
-                                throw ScilabMessage(szError);
+                                throw ast::ScilabMessage(szError);
                             }
                             else
                             {
-                                throw ScilabMessage();
+                                throw ast::ScilabMessage();
                             }
                         }
                     }
@@ -339,7 +339,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
                             szAllError = szError + os.str();
                             os_swprintf(szError, bsiz, _W("at line % 5d of exec file called by :\n"), (*j)->location_get().first_line);
                             szAllError += szError;
-                            throw ScilabMessage(szAllError);
+                            throw ast::ScilabMessage(szAllError);
                         }
                         else
                         {
@@ -355,7 +355,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
                 if (execMe.result_get() != NULL && (pVar == NULL || bImplicitCall))
                 {
                     InternalType* pITAns = execMe.result_get();
-                    symbol::Context::getInstance()->put(symbol::Symbol(L"ans"), *pITAns);
+                    symbol::Context::getInstance()->put(symbol::Symbol(L"ans"), pITAns);
                     if ( (*j)->is_verbose() && bErrCatch == false)
                     {
                         //TODO manage multiple returns
@@ -400,14 +400,14 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
                     mclose(iID);
                     //restore previous prompt mode
                     ConfigVariable::setPromptMode(oldVal);
-                    throw ScilabMessage(os.str(), 0, (*j)->location_get());
+                    throw ast::ScilabMessage(os.str(), 0, (*j)->location_get());
                 }
             }
 
             mclose(iID);
-            throw ScilabMessage((*j)->location_get());
+            throw ast::ScilabMessage((*j)->location_get());
         }
-        catch (ScilabError se)
+        catch (ast::ScilabError se)
         {
             if (ConfigVariable::getLastErrorNumber() == 0)
             {
@@ -436,7 +436,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
                 mclose(iID);
                 //restore previous prompt mode
                 ConfigVariable::setPromptMode(oldVal);
-                //throw ScilabMessage(szError, 1, (*j)->location_get());
+                //throw ast::ScilabMessage(szError, 1, (*j)->location_get());
                 //print already done, so just foward exception but with message
                 throw ast::ScilabError();
             }
index 1a9efbb..cfd3445 100644 (file)
@@ -248,11 +248,11 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
                         {
                             wchar_t szError[bsiz];
                             os_swprintf(szError, bsiz, _W("at line % 5d of function %ls called by :\n"), (*j)->location_get().first_line, pCall->getName().c_str());
-                            throw ScilabMessage(szError);
+                            throw ast::ScilabMessage(szError);
                         }
                         else
                         {
-                            throw ScilabMessage();
+                            throw ast::ScilabMessage();
                         }
                     }
                 }
@@ -276,7 +276,7 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
                         szAllError = szError + os.str();
                         os_swprintf(szError, bsiz, _W("in  execstr instruction    called by :\n"));
                         szAllError += szError;
-                        throw ScilabMessage(szAllError);
+                        throw ast::ScilabMessage(szAllError);
                     }
                     else
                     {
@@ -290,7 +290,7 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
             if (execMe.result_get() != NULL && execMe.result_get()->isDeletable())
             {
                 InternalType* pITAns = execMe.result_get();
-                symbol::Context::getInstance()->put(symbol::Symbol(L"ans"), *pITAns);
+                symbol::Context::getInstance()->put(symbol::Symbol(L"ans"), pITAns);
                 if ( (*j)->is_verbose() && bErrCatch == false)
                 {
                     std::wostringstream ostr;
@@ -344,10 +344,10 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
 
                         //restore previous prompt mode
                         ConfigVariable::setPromptMode(oldVal);
-                        throw ScilabMessage(os.str(), 0, (*j)->location_get());
+                        throw ast::ScilabMessage(os.str(), 0, (*j)->location_get());
                     }
                 }
-                throw ScilabMessage((*j)->location_get());
+                throw ast::ScilabMessage((*j)->location_get());
             }
             else
             {
@@ -355,7 +355,7 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
                 break;
             }
         }
-        catch (ScilabError se)
+        catch (ast::ScilabError se)
         {
             ConfigVariable::setSilentError(iOldSilentError);
             // check on error number because error message can be empty.
@@ -380,7 +380,7 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
                 sciprint(_("in  execstr instruction    called by :\n"));
                 //restore previous prompt mode
                 ConfigVariable::setPromptMode(oldVal);
-                //throw ScilabMessage(szError, 1, (*j)->location_get());
+                //throw ast::ScilabMessage(szError, 1, (*j)->location_get());
                 //print already done, so just foward exception but with message
                 //throw ast::ScilabError();
                 return Function::Error;
index a15db66..5b006c8 100644 (file)
@@ -51,8 +51,7 @@ Function::ReturnValue sci_funclist(types::typed_list &in, int _iRetCount, types:
         pstLibName = L"";
     }
 
-    wstring libName(pstLibName);
-    std::list<symbol::Symbol>* FuncList = pContext->getFunctionList(libName, false);
+    std::list<symbol::Symbol>* FuncList = pContext->getFunctionList(pstLibName);
 
     String *pS = new String((int)FuncList->size(), 1);
 
index 44c58e4..d510e32 100644 (file)
@@ -17,6 +17,8 @@
 #include "functions_gw.hxx"
 #include "macrovarvisitor.hxx"
 #include "list.hxx"
+#include "macro.hxx"
+#include "macrofile.hxx"
 
 #include <iostream>
 #include <fstream>
@@ -33,8 +35,8 @@ using namespace ast;
 using namespace std;
 
 InternalType* createString(std::list<std::wstring>& lst);
-void addIn(MacrovarVisitor& pVisit, std::list<symbol::Symbol>* pSym);
-void addOut(MacrovarVisitor& pVisit, std::list<symbol::Symbol>* pSym);
+void addIn(MacrovarVisitor& pVisit, std::list<symbol::Variable*>* pSym);
+void addOut(MacrovarVisitor& pVisit, std::list<symbol::Variable*>* pSym);
 
 Function::ReturnValue sci_macrovar(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
@@ -107,30 +109,30 @@ InternalType* createString(std::list<std::wstring>& lst)
     return pS;
 }
 
-void addOut(MacrovarVisitor& visit, std::list<symbol::Symbol>* pSym)
+void addOut(MacrovarVisitor& visit, std::list<symbol::Variable*>* pSym)
 {
     if (pSym == 0 || pSym->size() == 0)
     {
         return;
     }
 
-    std::list<symbol::Symbol>::iterator it = pSym->begin();
+    std::list<symbol::Variable*>::iterator it = pSym->begin();
     for (int i = 0 ; it != pSym->end() ; it++, i++)
     {
-        visit.addOut((*it).name_get().c_str());
+        visit.addOut((*it)->name_get().name_get().c_str());
     }
 }
 
-void addIn(MacrovarVisitor& visit, std::list<symbol::Symbol>* pSym)
+void addIn(MacrovarVisitor& visit, std::list<symbol::Variable*>* pSym)
 {
     if (pSym == 0 || pSym->size() == 0)
     {
         return;
     }
 
-    std::list<symbol::Symbol>::iterator it = pSym->begin();
+    std::list<symbol::Variable*>::iterator it = pSym->begin();
     for (int i = 0 ; it != pSym->end() ; it++, i++)
     {
-        visit.addIn((*it).name_get().c_str());
+        visit.addIn((*it)->name_get().name_get().c_str());
     }
 }
\ No newline at end of file
index 7bdebf1..099f631 100644 (file)
@@ -14,6 +14,7 @@
 #include "functions_gw.hxx"
 #include "context.hxx"
 #include "string.hxx"
+#include "double.hxx"
 
 extern "C" {
 #include "Scierror.h"
@@ -23,6 +24,7 @@ extern "C" {
 /*--------------------------------------------------------------------------*/
 
 using namespace types;
+using namespace std;
 
 Function::ReturnValue sci_whereis(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
index 9b690e4..829caf1 100644 (file)
@@ -371,6 +371,8 @@ bool FuncManager::LoadFuncByModule(void)
         }
     }
 
+    //protected all variables after scilab start
+    symbol::Context::getInstance()->scope_begin();
     return bRet;
 }
 
index 418b258..e1ebf86 100644 (file)
@@ -43,7 +43,7 @@ types::Function::ReturnValue sci_get(types::typed_list &in, int _iRetCount, type
     int iObjUID = 0;
     types::InternalType* pOut = NULL;
 
-    if (in.size() > 2)
+    if (in.size() < 1 || in.size() > 2)
     {
         Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), "get", 1, 2);
         return types::Function::Error;
@@ -67,7 +67,7 @@ types::Function::ReturnValue sci_get(types::typed_list &in, int _iRetCount, type
     if (p1->isDouble())
     {
         types::Double* pDbll1 = p1->getAs<types::Double>();
-        if (pDbll1->isScalar())
+        if (pDbll1->isScalar() == false)
         {
             Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), "get", 1);
             return types::Function::Error;
index 1abb0f2..3162481 100644 (file)
@@ -20,8 +20,6 @@ extern "C"
 #include "gw_graphics.h"
 }
 
-using namespace types;
-
 int GraphicsModule::Load()
 {
     return 1;
index a3b0d64..7dd7826 100644 (file)
@@ -17,7 +17,9 @@
 #include "context.hxx"
 #include "io_gw.hxx"
 #include "filemanager.hxx"
+#include "function.hxx"
 #include "string.hxx"
+#include "double.hxx"
 
 extern "C"
 {
@@ -363,22 +365,22 @@ types::Function::ReturnValue sci_file(types::typed_list &in, int _iRetCount, typ
     return types::Function::OK;
 }
 /*--------------------------------------------------------------------------*/
-Function::ReturnValue sci_file_no_rhs(types::typed_list &in, int _iRetCount, types::typed_list &out)
+types::Function::ReturnValue sci_file_no_rhs(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
     int iCount = FileManager::getOpenedCount();
     if (iCount == 0)
     {
         for (int i = 0 ; i < _iRetCount ; i++)
         {
-            out.push_back(Double::Empty());
+            out.push_back(types::Double::Empty());
         }
-        return Function::OK;
+        return types::Function::OK;
     }
 
     int* piIds = FileManager::getIDs();
     if (piIds)
     {
-        Double *pD = new Double(1, iCount);
+        types::Double *pD = new types::Double(1, iCount);
         pD->setInt(piIds);
         out.push_back(pD);
         delete[] piIds;
@@ -389,7 +391,7 @@ Function::ReturnValue sci_file_no_rhs(types::typed_list &in, int _iRetCount, typ
         wchar_t** pstTypes = FileManager::getTypesAsString();
         if (pstTypes != NULL)
         {
-            String* pS = new String(1, iCount);
+            types::String* pS = new types::String(1, iCount);
             pS->set(pstTypes);
             out.push_back(pS);
             for (int i = 0 ; i < iCount ; i++)
@@ -405,7 +407,7 @@ Function::ReturnValue sci_file_no_rhs(types::typed_list &in, int _iRetCount, typ
         wchar_t** pstNames = FileManager::getFilenames();
         if (pstNames != NULL)
         {
-            String* pS = new String(1, iCount);
+            types::String* pS = new types::String(1, iCount);
             pS->set(pstNames);
             out.push_back(pS);
             for (int i = 0 ; i < iCount ; i++)
@@ -421,7 +423,7 @@ Function::ReturnValue sci_file_no_rhs(types::typed_list &in, int _iRetCount, typ
         double* pdblModes = FileManager::getModes();
         if (pdblModes != NULL)
         {
-            Double* pD = new Double(1, iCount);
+            types::Double* pD = new types::Double(1, iCount);
             pD->set(pdblModes);
             out.push_back(pD);
             delete[] pdblModes;
@@ -433,51 +435,51 @@ Function::ReturnValue sci_file_no_rhs(types::typed_list &in, int _iRetCount, typ
         double* pdblSwaps = FileManager::getSwaps();
         if (pdblSwaps != NULL)
         {
-            Double* pD = new Double(1, iCount);
+            types::Double* pD = new types::Double(1, iCount);
             pD->set(pdblSwaps);
             out.push_back(pD);
             delete[] pdblSwaps;
         }
     }
 
-    return Function::OK;
+    return types::Function::OK;
 }
 /*--------------------------------------------------------------------------*/
-Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCount, types::typed_list &out)
+types::Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
-    if (in[0]->isDouble() == false || in[0]->getAs<Double>()->getSize() != 1)
+    if (in[0]->isDouble() == false || in[0]->getAs<types::Double>()->getSize() != 1)
     {
         Scierror(201, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), "file", 1);
-        return Function::Error;
+        return types::Function::Error;
     }
 
-    Double* pD = in[0]->getAs<Double>();
+    types::Double* pD = in[0]->getAs<types::Double>();
     int iID = static_cast<int>(pD->getReal()[0]);
 
     //check if double value is an integer to exclude decimal values
     if (static_cast<double>(iID) != pD->getReal()[0])
     {
         Scierror(201, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), "file", 1);
-        return Function::Error;
+        return types::Function::Error;
     }
 
-    File *pF = FileManager::getFile(iID);
+    types::File *pF = FileManager::getFile(iID);
     if (pF == NULL)
     {
         for (int i = 0 ; i < _iRetCount ; i++)
         {
-            out.push_back(Double::Empty());
+            out.push_back(types::Double::Empty());
         }
-        return Function::OK;
+        return types::Function::OK;
     }
 
-    out.push_back(new Double(iID));
+    out.push_back(new types::Double(iID));
     if (_iRetCount > 1) /*type*/
     {
         wchar_t* pstType = os_wcsdup(pF->getFileTypeAsString().c_str());
         if (pstType != NULL)
         {
-            String* pS = new String(pstType);
+            types::String* pS = new types::String(pstType);
             out.push_back(pS);
             delete[] pstType;
         }
@@ -488,7 +490,7 @@ Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCount, ty
         wchar_t* pstName =  os_wcsdup(pF->getFilename().c_str());
         if (pstName != NULL)
         {
-            String* pS = new String(pstName);
+            types::String* pS = new types::String(pstName);
             out.push_back(pS);
             delete[] pstName;
         }
@@ -498,17 +500,17 @@ Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCount, ty
     {
         if (pF->getFileType() == 1)
         {
-            out.push_back(new Double((double)pF->getFileFortranMode()));
+            out.push_back(new types::Double((double)pF->getFileFortranMode()));
         }
         else // if(pF->getFileType() == 2)
         {
-            out.push_back(new Double((double)pF->getFileModeAsInt()));
+            out.push_back(new types::Double((double)pF->getFileModeAsInt()));
         }
     }
 
     if (_iRetCount > 4) /* swap */
     {
-        out.push_back(new Double(pF->getFileSwap()));
+        out.push_back(new types::Double(pF->getFileSwap()));
     }
-    return Function::OK;
+    return types::Function::OK;
 }
index 6cce178..f97878b 100644 (file)
@@ -213,7 +213,7 @@ Function::ReturnValue sci_genlib(types::typed_list &in, int _iRetCount, types::t
             delete parser.getTree();
         }
 
-        symbol::Context::getInstance()->put(symbol::Symbol(pstLibName), *pLib);
+        symbol::Context::getInstance()->put(symbol::Symbol(pstLibName), pLib);
     }
 
 
index 38596ee..7468b73 100644 (file)
@@ -13,6 +13,7 @@
 #include "configvariable.hxx"
 #include "context.hxx"
 #include "loadlib.hxx"
+#include "macrofile.hxx"
 
 extern "C"
 {
@@ -27,14 +28,14 @@ extern "C"
 
 #define DEFAULT_ENCODING "UTF-8"
 
-static char *GetXmlFileEncoding(string _filename);
+static char *GetXmlFileEncoding(std::string _filename);
 
 types::Library* loadlib(std::wstring _wstXML, bool _isFile, bool _bAddInContext)
 {
     types::Library* lib = NULL;
 
-    wstring wstFile(_wstXML);
-    wstring wstPath(_wstXML);
+    std::wstring wstFile(_wstXML);
+    std::wstring wstPath(_wstXML);
 
     if (_isFile)
     {
@@ -132,7 +133,7 @@ types::Library* loadlib(std::wstring _wstXML, bool _isFile, bool _bAddInContext)
 
             if (pstName && pstFileName)
             {
-                wstring stFilename(wstPath);
+                std::wstring stFilename(wstPath);
                 if (stFilename.empty() == false && *stFilename.rbegin() != DIR_SEPARATORW[0])
                 {
                     stFilename += DIR_SEPARATORW;
@@ -171,7 +172,7 @@ types::Library* loadlib(std::wstring _wstXML, bool _isFile, bool _bAddInContext)
 
     if (_bAddInContext)
     {
-        symbol::Context::getInstance()->put(symbol::Symbol(pstLibName), *lib);
+        symbol::Context::getInstance()->put(symbol::Symbol(pstLibName), lib);
     }
 
     xmlFreeDoc(doc);
@@ -179,7 +180,7 @@ types::Library* loadlib(std::wstring _wstXML, bool _isFile, bool _bAddInContext)
     return lib;
 }
 
-static char *GetXmlFileEncoding(string _filename)
+static char *GetXmlFileEncoding(std::string _filename)
 {
     char *encoding = NULL;
     xmlDocPtr doc = NULL;
index 92d990e..d7edff1 100644 (file)
@@ -94,6 +94,8 @@ using namespace ast;
 static char *the_current_mex_name;
 static void (*exitFcn)(void);
 
+using namespace ast;
+
 mxClassID mxGetClassID(const mxArray *ptr)
 {
     types::InternalType *pIT = (types::InternalType *) ptr;
@@ -1571,11 +1573,11 @@ int mexEvalString(const char *name)
                         {
                             wchar_t szError[bsiz];
                             os_swprintf(szError, bsiz, _W("at line % 5d of function %ls called by :\n"), (*j)->location_get().first_line, pCall->getName().c_str());
-                            throw ScilabMessage(szError);
+                            throw ast::ScilabMessage(szError);
                         }
                         else
                         {
-                            throw ScilabMessage();
+                            throw ast::ScilabMessage();
                         }
                     }
                 }
@@ -1598,7 +1600,7 @@ int mexEvalString(const char *name)
                         szAllError = szError + os.str();
                         os_swprintf(szError, bsiz, _W("in  execstr instruction    called by :\n"));
                         szAllError += szError;
-                        throw ScilabMessage(szAllError);
+                        throw ast::ScilabMessage(szAllError);
                     }
                     else
                     {
@@ -1611,7 +1613,7 @@ int mexEvalString(const char *name)
             //update ans variable.
             if (execMe.result_get() != NULL && execMe.result_get()->isDeletable())
             {
-                symbol::Context::getInstance()->put(symbol::Symbol(L"ans"), *execMe.result_get());
+                symbol::Context::getInstance()->put(symbol::Symbol(L"ans"), execMe.result_get());
                 if ((*j)->is_verbose() && bErrCatch == false)
                 {
                     std::wostringstream ostr;
@@ -1658,10 +1660,10 @@ int mexEvalString(const char *name)
 
                         //restore previous prompt mode
                         ConfigVariable::setPromptMode(oldVal);
-                        throw ScilabMessage(os.str(), 0, (*j)->location_get());
+                        throw ast::ScilabMessage(os.str(), 0, (*j)->location_get());
                     }
                 }
-                throw ScilabMessage((*j)->location_get());
+                throw ast::ScilabMessage((*j)->location_get());
             }
             else
             {
@@ -1669,7 +1671,7 @@ int mexEvalString(const char *name)
                 break;
             }
         }
-        catch (ScilabError se)
+        catch (ast::ScilabError se)
         {
             if (ConfigVariable::getLastErrorMessage() == L"")
             {
@@ -1694,7 +1696,7 @@ int mexEvalString(const char *name)
                 os_swprintf(szError, bsiz, _W("at line % 5d of exec file called by :\n"), (*j)->location_get().first_line);
                 //restore previous prompt mode
                 ConfigVariable::setPromptMode(oldVal);
-                throw ScilabMessage(szError, 1, (*j)->location_get());
+                throw ast::ScilabMessage(szError, 1, (*j)->location_get());
             }
             break;
         }
@@ -1745,15 +1747,16 @@ int mexPutVariable(const char *workspace, const char *varname, const mxArray *pm
     wchar_t *dest = to_wide_string(varname);
     if (strcmp(workspace, "base") == 0)
     {
-        context->putInPreviousScope(*(new symbol::Symbol(dest)), *(types::InternalType *) pm);
+        context->putInPreviousScope(context->getOrCreate(symbol::Symbol(dest)), (types::InternalType *) pm);
     }
     else if (strcmp(workspace, "caller") == 0)
     {
-        context->put(*(new symbol::Symbol(dest)), *(types::InternalType *) pm);
+        context->put(symbol::Symbol(dest), (types::InternalType *) pm);
     }
     else if (strcmp(workspace, "global") == 0)
     {
-        context->setGlobalValue(*(new symbol::Symbol(dest)), *(types::InternalType *) pm);
+        context->setGlobalVisible(symbol::Symbol(dest), true);
+        context->put(symbol::Symbol(dest), (types::InternalType *) pm);
     }
     else
     {
index 57781a2..1407fe2 100644 (file)
@@ -1014,7 +1014,7 @@ types::Function::ReturnValue sci_optim(types::typed_list &in, types::optional_li
         Scierror(999, pstrMsg);
         FREE(pstrMsg);
     }
-    catch (ast::ScilabMessage &m)
+    catch (ast::ScilabMessage& /*m*/)
     {
     }
 
index 6464ade..121c45e 100644 (file)
@@ -151,21 +151,21 @@ void getPrefs()
             return;
         }
 
-        scilabPref.heapSize = os_strdup(getAttribute(doc, xpathCtxt, HEAPSIZE_XPATH));
-        scilabPref.adaptToDisplay = os_strdup(getAttribute(doc, xpathCtxt, ADAPTTODISPLAY_XPATH));
-        scilabPref.columnsToDisplay = os_strdup(getAttribute(doc, xpathCtxt, COLUMNSTODISPLAY_XPATH));
-        scilabPref.linesToDisplay = os_strdup(getAttribute(doc, xpathCtxt, LINESTODISPLAY_XPATH));
-        scilabPref.historySaveAfter = os_strdup(getAttribute(doc, xpathCtxt, HISTORYSAVEAFTER_XPATH));
-        scilabPref.historyFile = os_strdup(getAttribute(doc, xpathCtxt, HISTORYFILE_XPATH));
-        scilabPref.historyLines = os_strdup(getAttribute(doc, xpathCtxt, HISTORYLINES_XPATH));
-        scilabPref.historyEnable = os_strdup(getAttribute(doc, xpathCtxt, HISTORYENABLE_XPATH));
-        scilabPref.ieee = os_strdup(getAttribute(doc, xpathCtxt, IEEE_XPATH));
-        scilabPref.format = os_strdup(getAttribute(doc, xpathCtxt, FORMAT_XPATH));
-        scilabPref.formatWidth = os_strdup(getAttribute(doc, xpathCtxt, FORMATWIDTH_XPATH));
-        scilabPref.language = os_strdup(getAttribute(doc, xpathCtxt, LANGUAGE_XPATH));
-        scilabPref.startup_dir_use = os_strdup(getAttribute(doc, xpathCtxt, STARTUP_DIR_USE_XPATH));
-        scilabPref.startup_dir_default = os_strdup(getAttribute(doc, xpathCtxt, STARTUP_DIR_DEFAULT_XPATH));
-        scilabPref.startup_dir_previous = os_strdup(getAttribute(doc, xpathCtxt, STARTUP_DIR_PREVIOUS_XPATH));
+        scilabPref.heapSize = os_strdup(getAttribute(doc, xpathCtxt, (char*)HEAPSIZE_XPATH));
+        scilabPref.adaptToDisplay = os_strdup(getAttribute(doc, xpathCtxt, (char*)ADAPTTODISPLAY_XPATH));
+        scilabPref.columnsToDisplay = os_strdup(getAttribute(doc, xpathCtxt, (char*)COLUMNSTODISPLAY_XPATH));
+        scilabPref.linesToDisplay = os_strdup(getAttribute(doc, xpathCtxt, (char*)LINESTODISPLAY_XPATH));
+        scilabPref.historySaveAfter = os_strdup(getAttribute(doc, xpathCtxt, (char*)HISTORYSAVEAFTER_XPATH));
+        scilabPref.historyFile = os_strdup(getAttribute(doc, xpathCtxt, (char*)HISTORYFILE_XPATH));
+        scilabPref.historyLines = os_strdup(getAttribute(doc, xpathCtxt, (char*)HISTORYLINES_XPATH));
+        scilabPref.historyEnable = os_strdup(getAttribute(doc, xpathCtxt, (char*)HISTORYENABLE_XPATH));
+        scilabPref.ieee = os_strdup(getAttribute(doc, xpathCtxt, (char*)IEEE_XPATH));
+        scilabPref.format = os_strdup(getAttribute(doc, xpathCtxt, (char*)FORMAT_XPATH));
+        scilabPref.formatWidth = os_strdup(getAttribute(doc, xpathCtxt, (char*)FORMATWIDTH_XPATH));
+        scilabPref.language = os_strdup(getAttribute(doc, xpathCtxt, (char*)LANGUAGE_XPATH));
+        scilabPref.startup_dir_use = os_strdup(getAttribute(doc, xpathCtxt, (char*)STARTUP_DIR_USE_XPATH));
+        scilabPref.startup_dir_default = os_strdup(getAttribute(doc, xpathCtxt, (char*)STARTUP_DIR_DEFAULT_XPATH));
+        scilabPref.startup_dir_previous = os_strdup(getAttribute(doc, xpathCtxt, (char*)STARTUP_DIR_PREVIOUS_XPATH));
 
         xmlXPathFreeContext(xpathCtxt);
         xmlFreeDoc(doc);
index f679887..99cfd09 100644 (file)
@@ -17,6 +17,7 @@ using regular expression .                                      */
 #include "function.hxx"
 #include "context.hxx"
 #include "string.hxx"
+#include "double.hxx"
 #include "string_gw.hxx"
 
 extern "C"
@@ -154,10 +155,10 @@ Function::ReturnValue sci_regexp(typed_list &in, int _iRetCount, typed_list &out
 
     if (iOccurs == 0)
     {
-        out.push_back(Double::Empty());
+        out.push_back(types::Double::Empty());
         if (_iRetCount > 1)
         {
-            out.push_back(Double::Empty());
+            out.push_back(types::Double::Empty());
         }
 
         if (_iRetCount > 2)
index 2d1f147..ad9c81d 100644 (file)
@@ -80,7 +80,7 @@ static void getMacroString(Macro* _pM, InternalType** _pOut, InternalType** _pIn
     *_pBody = pBody;
 
     //get inputs
-    list<symbol::Symbol>* pIn = _pM->inputs_get();
+    std::list<symbol::Variable*>* pIn = _pM->inputs_get();
 
     if (pIn->size() == 0)
     {
@@ -90,17 +90,17 @@ static void getMacroString(Macro* _pM, InternalType** _pOut, InternalType** _pIn
     {
         String *pSIn = new String(1, (int)pIn->size());
 
-        list<symbol::Symbol>::iterator itIn = pIn->begin();
+        list<symbol::Variable*>::iterator itIn = pIn->begin();
         for (int i = 0 ; i < pIn->size() ; i++, itIn++)
         {
-            pSIn->set(i, (*itIn).name_get().c_str());
+            pSIn->set(i, (*itIn)->name_get().name_get().c_str());
         }
 
         *_pIn = pSIn;
     }
 
     //get outputs
-    list<symbol::Symbol>* pOut = _pM->outputs_get();
+    list<symbol::Variable*>* pOut = _pM->outputs_get();
     if (pOut->size() == 0)
     {
         *_pOut = Double::Empty();
@@ -109,10 +109,10 @@ static void getMacroString(Macro* _pM, InternalType** _pOut, InternalType** _pIn
     {
         String* pSOut = new String(1, (int)pOut->size());
 
-        list<symbol::Symbol>::iterator itOut = pOut->begin();
+        list<symbol::Variable*>::iterator itOut = pOut->begin();
         for (int i = 0 ; i < pOut->size() ; i++, itOut++)
         {
-            pSOut->set(i, (*itOut).name_get().c_str());
+            pSOut->set(i, (*itOut)->name_get().name_get().c_str());
         }
 
         *_pOut = pSOut;
index a148b19..f90f157 100644 (file)
@@ -15,6 +15,7 @@
 #include "context.hxx"
 #include "types.hxx"
 #include "bool.hxx"
+#include "double.hxx"
 #include "stripblanks.hxx"
 /*--------------------------------------------------------------------------*/
 extern "C"
@@ -32,14 +33,14 @@ types::Function::ReturnValue sci_stripblanks(types::typed_list &in, int _iRetCou
     if (in.size() < 1 || in.size() > 2)
     {
         Scierror(999, _("%s: Wrong number of input arguments: %d or %d expected.\n"), FUNCNAME, 1, 2);
-        return Function::Error;
+        return types::Function::Error;
     }
 
     // check output parameters
     if (_iRetCount != 1 && _iRetCount != -1)
     {
         Scierror(999, _("%s: Wrong number of output arguments: %d expected.\n"), FUNCNAME, 1);
-        return Function::Error;
+        return types::Function::Error;
     }
 
     if (in.size() == 2)
@@ -47,7 +48,7 @@ types::Function::ReturnValue sci_stripblanks(types::typed_list &in, int _iRetCou
         if (in[1]->isBool() == false || in[1]->getAs<types::Bool>()->getSize() != 1)
         {
             Scierror(999, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), FUNCNAME, 2);
-            return Function::Error;
+            return types::Function::Error;
         }
 
         if (in[1]->getAs<types::Bool>()->get()[0] == 1)
@@ -58,34 +59,34 @@ types::Function::ReturnValue sci_stripblanks(types::typed_list &in, int _iRetCou
 
     switch (in[0]->getType())
     {
-        case InternalType::ScilabString:
+        case types::InternalType::ScilabString:
         {
-            String *pS = stripblanks(in[0]->getAs<types::String>(), bRemoveTab);
+            types::String *pS = stripblanks(in[0]->getAs<types::String>(), bRemoveTab);
             if (pS == NULL)
             {
                 Scierror(999, _("%s : No more memory.\n"), FUNCNAME);
-                return Function::Error;
+                return types::Function::Error;
             }
 
             out.push_back(pS);
         }
         break;
-        case InternalType::ScilabDouble://manage []
+        case types::InternalType::ScilabDouble://manage []
         {
-            if (in[0]->getAs<Double>()->getSize() != 0)
+            if (in[0]->getAs<types::Double>()->getSize() != 0)
             {
                 Scierror(999, _("%s: Wrong type for input argument #%d: Matrix of strings or empty matrix expected.\n"), FUNCNAME, 1);
-                return Function::Error;
+                return types::Function::Error;
             }
 
-            out.push_back(Double::Empty());
+            out.push_back(types::Double::Empty());
         }
         break;
         default:
             Scierror(999, _("%s: Wrong type for input argument #%d: Matrix of strings or empty matrix expected.\n"), FUNCNAME, 1);
-            return Function::Error;
+            return types::Function::Error;
     }
 
-    return Function::OK;
+    return types::Function::OK;
 }
 /*--------------------------------------------------------------------------*/
index 7396f89..04e248e 100644 (file)
@@ -25,9 +25,9 @@ extern "C"
 /*--------------------------------------------------------------------------*/
 static wchar_t* subwcs(const wchar_t *_pstStr, int _iStartPos, int _iEndPos);
 /*--------------------------------------------------------------------------*/
-String * stripblanks(String *InputStrings, bool bRemoveTAB)
+types::String * stripblanks(types::String *InputStrings, bool bRemoveTAB)
 {
-    String *pOutputStrings = new String(InputStrings->getRows(), InputStrings->getCols());
+    types::String *pOutputStrings = new types::String(InputStrings->getRows(), InputStrings->getCols());
     if (pOutputStrings)
     {
         pOutputStrings->set(InputStrings->get());
index 5621fe1..f685cbd 100644 (file)
 #include "dynlib_string.h"
 #include "string.hxx"
 
-using namespace types;
-
 /**
 * remove blank or tab characters in a string matrix
 * @param[in] String: input Strings
 * @param[in] Bool: remove TAB if get() != 0
 * @return String: output String
 */
-STRING_IMPEXP String * stripblanks(String *InputStrings, bool bWithTAB);
+STRING_IMPEXP types::String * stripblanks(types::String *InputStrings, bool bWithTAB);
 
 #endif /* __STRIPBLANKS_HXX__ */
 /*--------------------------------------------------------------------------*/
index 2ff2a10..26ea704 100644 (file)
 
 SYMBOL_CXX_SOURCES = \
 src/cpp/symbol.cpp \
-src/cpp/context.cpp \
-src/cpp/scope.cpp \
-src/cpp/variables.cpp \
-src/cpp/libraries.cpp
+src/cpp/context.cpp
     
 
 pkglib_LTLIBRARIES             = libscisymbol.la
index 13e4472..be5e8f2 100644 (file)
@@ -158,10 +158,7 @@ LTLIBRARIES = $(pkglib_LTLIBRARIES)
 libscisymbol_la_DEPENDENCIES =
 am__dirstamp = $(am__leading_dot)dirstamp
 am__objects_1 = src/cpp/libscisymbol_la-symbol.lo \
-       src/cpp/libscisymbol_la-context.lo \
-       src/cpp/libscisymbol_la-scope.lo \
-       src/cpp/libscisymbol_la-variables.lo \
-       src/cpp/libscisymbol_la-libraries.lo
+       src/cpp/libscisymbol_la-context.lo
 am_libscisymbol_la_OBJECTS = $(am__objects_1)
 libscisymbol_la_OBJECTS = $(am_libscisymbol_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -515,10 +512,7 @@ top_srcdir = @top_srcdir@
 yacc_present = @yacc_present@
 SYMBOL_CXX_SOURCES = \
 src/cpp/symbol.cpp \
-src/cpp/context.cpp \
-src/cpp/scope.cpp \
-src/cpp/variables.cpp \
-src/cpp/libraries.cpp
+src/cpp/context.cpp
 
 pkglib_LTLIBRARIES = libscisymbol.la
 libscisymbol_la_SOURCES = $(SYMBOL_CXX_SOURCES)
@@ -694,12 +688,6 @@ src/cpp/libscisymbol_la-symbol.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscisymbol_la-context.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
-src/cpp/libscisymbol_la-scope.lo: src/cpp/$(am__dirstamp) \
-       src/cpp/$(DEPDIR)/$(am__dirstamp)
-src/cpp/libscisymbol_la-variables.lo: src/cpp/$(am__dirstamp) \
-       src/cpp/$(DEPDIR)/$(am__dirstamp)
-src/cpp/libscisymbol_la-libraries.lo: src/cpp/$(am__dirstamp) \
-       src/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscisymbol.la: $(libscisymbol_la_OBJECTS) $(libscisymbol_la_DEPENDENCIES) $(EXTRA_libscisymbol_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libscisymbol_la_OBJECTS) $(libscisymbol_la_LIBADD) $(LIBS)
@@ -713,10 +701,7 @@ distclean-compile:
        -rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisymbol_la-context.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisymbol_la-libraries.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisymbol_la-scope.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisymbol_la-symbol.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisymbol_la-variables.Plo@am__quote@
 
 .cpp.o:
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -756,27 +741,6 @@ src/cpp/libscisymbol_la-context.lo: src/cpp/context.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) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscisymbol_la-context.lo `test -f 'src/cpp/context.cpp' || echo '$(srcdir)/'`src/cpp/context.cpp
 
-src/cpp/libscisymbol_la-scope.lo: src/cpp/scope.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscisymbol_la-scope.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscisymbol_la-scope.Tpo -c -o src/cpp/libscisymbol_la-scope.lo `test -f 'src/cpp/scope.cpp' || echo '$(srcdir)/'`src/cpp/scope.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscisymbol_la-scope.Tpo src/cpp/$(DEPDIR)/libscisymbol_la-scope.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/scope.cpp' object='src/cpp/libscisymbol_la-scope.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) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscisymbol_la-scope.lo `test -f 'src/cpp/scope.cpp' || echo '$(srcdir)/'`src/cpp/scope.cpp
-
-src/cpp/libscisymbol_la-variables.lo: src/cpp/variables.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscisymbol_la-variables.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscisymbol_la-variables.Tpo -c -o src/cpp/libscisymbol_la-variables.lo `test -f 'src/cpp/variables.cpp' || echo '$(srcdir)/'`src/cpp/variables.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscisymbol_la-variables.Tpo src/cpp/$(DEPDIR)/libscisymbol_la-variables.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/variables.cpp' object='src/cpp/libscisymbol_la-variables.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) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscisymbol_la-variables.lo `test -f 'src/cpp/variables.cpp' || echo '$(srcdir)/'`src/cpp/variables.cpp
-
-src/cpp/libscisymbol_la-libraries.lo: src/cpp/libraries.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscisymbol_la-libraries.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscisymbol_la-libraries.Tpo -c -o src/cpp/libscisymbol_la-libraries.lo `test -f 'src/cpp/libraries.cpp' || echo '$(srcdir)/'`src/cpp/libraries.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscisymbol_la-libraries.Tpo src/cpp/$(DEPDIR)/libscisymbol_la-libraries.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/libraries.cpp' object='src/cpp/libscisymbol_la-libraries.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) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscisymbol_la-libraries.lo `test -f 'src/cpp/libraries.cpp' || echo '$(srcdir)/'`src/cpp/libraries.cpp
-
 mostlyclean-libtool:
        -rm -f *.lo
 
index 4b7b65b..9477139 100644 (file)
 
 #ifndef __CONTEXT_HXX__
 #define __CONTEXT_HXX__
-//#include "stack.hxx"
-//#include "heap.hxx"
-#include "scope.hxx"
-#include "variables.hxx"
-#include "internal.hxx"
+
 #include "function.hxx"
-#include "macro.hxx"
-#include "macrofile.hxx"
+#include "typesdecl.hxx"
+#include "variables.hxx"
+#include "libraries.hxx"
 #include "export_symbol.h"
 
 namespace symbol
@@ -49,22 +46,24 @@ public :
 
     /** If key was associated to some Entry_T in the open scopes, return the
     ** most recent insertion. Otherwise return the empty pointer. */
-    types::InternalType* get(const symbol::Symbol& key) const;
+    types::InternalType* get(const Symbol& key);
+    types::InternalType* get(const Variable* _var);
+    Variable* getOrCreate(const Symbol& _key);
 
     /** If key was associated to some Entry_T in the last opened scope, return it.
     ** Otherwise return the empty pointer. */
-    types::InternalType* getCurrentLevel(const symbol::Symbol& key) const;
+    types::InternalType* getCurrentLevel(const Symbol& key);
 
     /** If key was associated to some Entry_T in the open scopes, return the
     ** most recent insertion DESPITE the current/last one. Otherwise return the empty pointer. */
-    types::InternalType* getAllButCurrentLevel(const symbol::Symbol& key) const;
+    types::InternalType* getAllButCurrentLevel(const Symbol& key);
 
     /** If key was associated to some Entry_T in the open scopes, return the
     ** most recent insertion. Otherwise return the empty pointer. */
-    types::InternalType* getFunction(const symbol::Symbol& key) const;
+    types::InternalType* getFunction(const Symbol& key);
 
     /*return function list in the module _stModuleName*/
-    std::list<symbol::Symbol>* getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd = true);
+    std::list<Symbol>* getFunctionList(std::wstring _stModuleName);
 
     std::list<std::wstring>* getVarsName();
     std::list<std::wstring>* getMacrosName();
@@ -73,44 +72,53 @@ public :
     /* global functions */
 
     /*return global variable visibility status*/
-    bool isGlobalVisible(const symbol::Symbol& key) const;
-
-    /*return global variable, search in global scope ( highest )*/
-    types::InternalType* getGlobalValue(const symbol::Symbol& key) const;
+    bool isGlobalVisible(const Symbol& key);
 
     /*return global variable existance status*/
-    bool isGlobalExists(const symbol::Symbol& key) const;
-
-    /*create or update a global variable*/
-    void setGlobalValue(const symbol::Symbol& key, types::InternalType &value);
+    bool isGlobal(const Symbol& key);
 
     /*remove global variable and all visibility references */
-    void removeGlobal(const symbol::Symbol& key);
+    //clearglobal("a")
+    void removeGlobal(const Symbol& key);
 
     /*remove all global variables and references */
+    //clearglobal
     void removeGlobalAll();
 
-    /*create an empty variable*/
-    void createEmptyGlobalValue(const symbol::Symbol& key);
-
     /*set variable visible/hidden in current global scope*/
-    void setGlobalVisible(const symbol::Symbol& key, bool bVisible = true);
+    void setGlobalVisible(const Symbol& key, bool bVisible);
+    void setGlobal(const Symbol& key);
+
+    types::InternalType* getGlobalValue(const Symbol& _key);
 
     /*add symbol and value in the stack*/
-    bool put(const symbol::Symbol& key, types::InternalType& type);
+    void put(const Symbol& _key, types::InternalType* _pIT);
+    void put(Variable* _var, types::InternalType* _pIT);
     /*add symbol and value in the previous scope*/
-    bool putInPreviousScope(const symbol::Symbol& key, types::InternalType& type);
+    bool putInPreviousScope(Variable* _var, types::InternalType* _pIT);
 
     /* remove symbol/value association */
-    bool remove(const symbol::Symbol& key);
+    //clear("a")
+    bool remove(const Symbol& key);
+    //clear();
+    bool removeAll();
 
     bool addFunction(types::Function *_info);
-    bool AddMacro(types::Macro *_info);
-    bool AddMacroFile(types::MacroFile *_info);
+    bool addMacro(types::Macro *_info);
+    bool addMacroFile(types::MacroFile *_info);
     void print(std::wostream& ostr) const;
 private :
 
-    Scopes* m_scopes;
+    types::InternalType* get(const Symbol& key, int _iLevel);
+    bool clearCurrentScope(bool _bClose);
+
+    typedef std::map<Symbol, Variable*> VarList;
+    typedef std::stack<VarList*> VarStack;
+    std::list<Symbol>* globals;
+    VarStack varStack;
+    Variables variables;
+    Libraries libraries;
+    int m_iLevel;
 
     Context();
     static Context* me;
index 5699649..cd8cf61 100644 (file)
 #ifndef __LIBRARIES_HXX__
 #define __LIBRARIES_HXX__
 
-#include <map>
-#include <list>
-#include "types.hxx"
+#include <stack>
 #include "symbol.hxx"
-#include "function.hxx"
+#include "types.hxx"
 #include "library.hxx"
-#include "variables.hxx"
+#include "export_symbol.h"
 
 
 namespace symbol
 {
-class LibBox
+struct EXTERN_SYMBOL ScopedLibrary
 {
-public :
-    LibBox(int _iLevel, types::Library& _lib) : m_iLevel(_iLevel), m_pLib(&_lib) {};
-    virtual ~LibBox() {};
+    ScopedLibrary(int _iLevel, types::Library* _pLib) : m_iLevel(_iLevel), m_pLib(_pLib) {};
 
-    types::Library* getValue()
+    types::MacroFile* getMacroFile(const Symbol& _key)
     {
-        return m_pLib;
+        return m_pLib->get(_key.name_get());
     }
-    types::MacroFile* getMacroFile(const Symbol& _key);
-    void setValue(types::Library& _lib)
+
+    int m_iLevel;
+    types::Library* m_pLib;
+};
+
+struct EXTERN_SYMBOL Library
+{
+    Library(const Symbol& _name) : name(_name) {};
+
+    void put(types::Library* _pLib, int _iLevel)
     {
-        m_pLib = &_lib;
+        if (empty() || top()->m_iLevel < _iLevel)
+        {
+            //create a new level
+            stack.push(new ScopedLibrary(_iLevel, _pLib));
+            _pLib->IncreaseRef();
+        }
+        else
+        {
+            //update current level
+            types::Library* pLib = top()->m_pLib;
+            if (pLib != _pLib)
+            {
+                pLib->DecreaseRef();
+                if (pLib->isDeletable())
+                {
+                    delete pLib;
+                }
+
+                top()->m_pLib = _pLib;
+                _pLib->IncreaseRef();
+            }
+        }
     }
-    int getLevel()
+
+    types::MacroFile* get(const Symbol& _keyMacro) const
     {
-        return m_iLevel;
-    };
-    void setLevel(int _iLevel)
+        if (empty() == false)
+        {
+            return top()->getMacroFile(_keyMacro);
+        }
+
+        return NULL;
+    }
+
+    std::list<std::wstring>* getMacrosName()
+    {
+        if (empty() == false)
+        {
+            return top()->m_pLib->getMacrosName();
+        }
+
+        return new std::list<std::wstring>();
+    }
+
+    bool empty() const
+    {
+        return stack.empty();
+    }
+
+    ScopedLibrary* top() const
     {
-        m_iLevel = _iLevel;
-    };
+        return stack.top();
+    }
+
+    void pop()
+    {
+        stack.pop();
+    }
+
 private :
-    int m_iLevel;
-    types::Library* m_pLib;
+    typedef std::stack<ScopedLibrary*> StackLib;
+    StackLib stack;
+    Symbol name;
+    bool m_global;
 };
 
-class Libraries
+struct Libraries
 {
-private :
-    typedef std::list<LibBox* > LibBoxList;
-    typedef std::map<Symbol, LibBoxList*> LibMap;
-    typedef std::list<Symbol> LibList;
-    LibMap m_libmap;
-    LibList m_liblist;
-    int m_iLevel;
+    Libraries() {};
+
+    Library* getOrCreate(const Symbol& _key)
+    {
+        MapLibs::const_iterator it = libs.find(_key);
+        if (it == libs.end())
+        {
+            //create an empty StackedValues
+            Library* lib = new Library(_key);
+            libs[_key] = lib;
+            return lib;
+        }
 
-public :
-    Libraries() : m_iLevel(-1) {}
+        return it->second;
+    }
 
-    virtual ~Libraries() {}
+    void put(const Symbol& _keyLib, types::Library* _pLib, int _iLevel)
+    {
+        Library* lib = getOrCreate(_keyLib);
+        lib->put(_pLib, _iLevel);
+    }
 
-    void IncreaseLevel()
+    types::InternalType* get(const Symbol& _key, int _iLevel)
     {
-        m_iLevel++;
+        MapLibs::reverse_iterator it = libs.rbegin();
+        for (; it != libs.rend() ; ++it)
+        {
+            if (it->second->empty() == false)
+            {
+                if (_iLevel == -1 || it->second->top()->m_iLevel == _iLevel)
+                {
+                    types::MacroFile* pMF = it->second->get(_key);
+                    if (pMF)
+                    {
+                        return (types::InternalType*)pMF;
+                    }
+                }
+            }
+        }
+
+        return NULL;
     }
-    void DecreaseLevel()
+
+    bool remove(const Symbol& _key, int _iLevel)
     {
-        m_iLevel--;
+        MapLibs::iterator it = libs.find(_key);
+        if (it != libs.end())
+        {
+            if (it->second->empty() == false)
+            {
+                if (it->second->top()->m_iLevel == _iLevel)
+                {
+                    types::Library* pIT = it->second->top()->m_pLib;
+                    pIT->DecreaseRef();
+                    if (pIT->isDeletable())
+                    {
+                        delete pIT;
+                    }
+
+                    it->second->pop();
+                    return true;
+                }
+            }
+        }
+
+        return false;
     }
 
-    void put(const Symbol& _key, types::InternalType& _IT);
-    types::MacroFile* get(const Symbol& _key) const;
-    bool remove(const Symbol& _key);
+    std::list<std::wstring>* getMacrosName()
+    {
+        std::list<std::wstring>* names = new std::list<std::wstring>();
+        MapLibs::iterator it = libs.begin();
+        for (; it != libs.end() ; ++it)
+        {
+            std::list<std::wstring>* temp = it->second->getMacrosName();
+            names->insert(names->end(), temp->begin(), temp->end());
+            delete temp;
+        }
 
-    std::list<std::wstring>* getMacrosName();
+        return names;
+    }
 
+private:
+    typedef std::map<Symbol, Library*> MapLibs;
+    MapLibs libs;
 };
 }
 #endif /* !__LIBRARIES_HXX__ */
index c138021..93d3a37 100644 (file)
 /*
-*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-*  Copyright (C) 2013 - 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
-*
-*/
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
+ *
+ *  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 __VARIABLES_HXX__
 #define __VARIABLES_HXX__
 
-#include <map>
-#include <list>
-#include "types.hxx"
+#include <string>
+#include <stack>
 #include "symbol.hxx"
-#include "function.hxx"
+#include "internal.hxx"
+#include "double.hxx"
+#include "export_symbol.h"
 
 namespace symbol
 {
-struct VarBox
+struct EXTERN_SYMBOL ScopedVariable
 {
-    VarBox(int _iLevel, types::InternalType* _pIT, bool _bGlobal = false, bool _bGlobalVisible = false);
+    ScopedVariable(int _iLevel, types::InternalType* _pIT)
+        : m_iLevel(_iLevel), m_pIT(_pIT), m_globalVisible(false) {}
 
     int m_iLevel;
+    bool m_globalVisible;
     types::InternalType* m_pIT;
-    bool m_bGlobal;
-    bool m_bGlobalVisible;
 };
 
-class Variables
+struct EXTERN_SYMBOL Variable
 {
+    Variable(const Symbol& _name) : name(_name), m_Global(false), m_GlobalValue(NULL) {};
+
+    void put(types::InternalType* _pIT, int _iLevel)
+    {
+        if (isGlobal() && isGlobalVisible(_iLevel))
+        {
+            setGlobalValue(_pIT);
+            return;
+        }
+
+        if (empty() || top()->m_iLevel < _iLevel)
+        {
+            //create a new level
+            stack.push(new ScopedVariable(_iLevel, _pIT));
+            _pIT->IncreaseRef();
+        }
+        else
+        {
+            //update current level
+            types::InternalType* pIT = top()->m_pIT;
+            if (pIT != _pIT)
+            {
+                pIT->DecreaseRef();
+                if (pIT->isDeletable())
+                {
+                    delete pIT;
+                }
+
+                top()->m_pIT = _pIT;
+                _pIT->IncreaseRef();
+            }
+        }
+    }
+
+    types::InternalType* get() const
+    {
+        if (empty())
+        {
+            return NULL;
+        }
+
+        if (m_Global && top()->m_globalVisible)
+        {
+            return m_GlobalValue;
+        }
+        else
+        {
+            return top()->m_pIT;
+        }
+    }
+
+    bool empty() const
+    {
+        return stack.empty();
+    }
+
+    ScopedVariable* top() const
+    {
+        return stack.top();
+    }
+
+    void pop()
+    {
+        stack.pop();
+    }
+
+    Symbol name_get() const
+    {
+        return name;
+    }
+
+    //globals
+
+    void setGlobal(bool _bGlobal)
+    {
+        m_Global = _bGlobal;
+    }
+
+    bool isGlobal()
+    {
+        return m_Global;
+    }
+
+    bool isGlobalVisible(int _iLevel)
+    {
+        if (empty() == false)
+        {
+            if (top()->m_iLevel == _iLevel)
+            {
+                return top()->m_globalVisible;
+            }
+        }
+
+        return false;
+    }
+
+    void setGlobalVisible(int _iLevel, bool _bVisible)
+    {
+        if (empty() || top()->m_iLevel != _iLevel)
+        {
+            stack.push(new ScopedVariable(_iLevel, types::Double::Empty()));
+        }
+
+
+        top()->m_globalVisible = _bVisible;
+    }
+
+    void setGlobalValue(types::InternalType* _pIT)
+    {
+        if (m_GlobalValue != _pIT)
+        {
+            if (m_GlobalValue)
+            {
+                m_GlobalValue->DecreaseRef();
+                if (m_GlobalValue->isDeletable())
+                {
+                    delete m_GlobalValue;
+                }
+            }
+
+            m_GlobalValue = _pIT;
+            if (_pIT != NULL)
+            {
+                _pIT->IncreaseRef();
+            }
+        }
+    }
+
+    types::InternalType* getGlobalValue()
+    {
+        return m_GlobalValue;
+    }
+
 private :
-    //current scope level
-    int m_iLevel;
+    Symbol name;
+    types::InternalType* m_GlobalValue;
+    bool m_Global;
+    typedef std::stack<ScopedVariable*> StackVar;
+    StackVar stack;
+};
+
+struct Variables
+{
+    Variables() {};
+
+    Variable* getOrCreate(const Symbol& _key)
+    {
+        std::wstring toto = _key.name_get();
+        MapVars::const_iterator it = vars.find(_key);
+        if (it == vars.end())
+        {
+            //create an empty StackedValues
+            Variable* var = new Variable(_key);
+            vars[_key] = var;
+            return var;
+        }
+
+        return it->second;
+    }
+
+    void put(const Symbol& _key, types::InternalType* _pIT, int _iLevel)
+    {
+        Variable* var = getOrCreate(_key);
+        var->put(_pIT, _iLevel);
+    }
+
+    types::InternalType* get(const Symbol& _key, int _iLevel)
+    {
+        MapVars::const_iterator it = vars.find(_key);
+        if (it != vars.end() && it->second->empty() == false)
+        {
+            if (_iLevel == -1 || it->second->top()->m_iLevel == _iLevel)
+            {
+                return it->second->get();
+            }
+        }
+
+        return NULL;
+    }
+
+    types::InternalType* get(Variable* _var, int _iLevel)
+    {
+        if (_var != NULL && _var->empty() == false)
+        {
+            if (_iLevel == -1 || _var->top()->m_iLevel == _iLevel)
+            {
+                return _var->get();
+            }
+        }
+
+        return NULL;
+    }
+
+    types::InternalType* getAllButCurrentLevel(const Symbol& _key, int _iLevel)
+    {
+        MapVars::const_iterator it = vars.find(_key);
+        if (it != vars.end() && it->second->empty() == false)
+        {
+            if (it->second->top()->m_iLevel < _iLevel)
+            {
+                return it->second->get();
+            }
+            else
+            {
+                ScopedVariable* pSave = it->second->top();
+                it->second->pop();
+                types::InternalType* pIT = getAllButCurrentLevel(_key, _iLevel);
+                it->second->put(pSave->m_pIT, pSave->m_iLevel);
+                return pIT;
+            }
+        }
+
+        return NULL;
+    }
+
+    bool remove(Variable* _var, int _iLevel)
+    {
+        if (_var->empty() == false)
+        {
+            if (_var->top()->m_iLevel == _iLevel)
+            {
+                types::InternalType* pIT = _var->top()->m_pIT;
+                pIT->DecreaseRef();
+                if (pIT->isDeletable())
+                {
+                    delete pIT;
+                }
+
+                _var->pop();
+            }
+        }
+
+        return true;
+    }
+
+    bool remove(const Symbol& _key, int _iLevel)
+    {
+        MapVars::iterator it = vars.find(_key);
+        if (it != vars.end())
+        {
+            Variable* pVar = it->second;
+            return remove(pVar, _iLevel);
+        }
 
-    typedef std::list<VarBox* > VarBoxList;
-    typedef std::map<Symbol, VarBoxList*> VarMap;
-    typedef std::map<Symbol, types::InternalType*> GlobalMap;
-    VarMap m_vars;
-    GlobalMap m_globals;
+        return false;
+    }
 
-    void removeGlobal(GlobalMap::iterator& _it);
-public :
-    Variables() : m_iLevel(-1) {}
+    std::list<std::wstring>* getMacrosName()
+    {
+        std::list<std::wstring>* plOut = new std::list<std::wstring>();
+        MapVars::const_iterator it = vars.begin();
+        for (; it != vars.end(); ++it)
+        {
+            if (it->second->empty() == false)
+            {
+                types::InternalType* pIT = it->second->top()->m_pIT;
+                if (pIT && (pIT->isMacro() || pIT->isMacroFile()))
+                {
+                    plOut->push_back(it->first.name_get().c_str());
+                }
+            }
+        }
 
-    virtual ~Variables() {}
+        return plOut;
+    }
 
-    void put(const Symbol& _key, types::InternalType& _pIT);
-    void put(const Symbol& _key, types::InternalType& _iT, int _iLevel);
-    void putInPreviousScope(const Symbol& _key, types::InternalType& _iT);
+    std::list<Symbol>* getFunctionList(std::wstring _stModuleName, int _iLevel)
+    {
+        std::list<Symbol>* symb = new std::list<Symbol>();
 
-    types::InternalType* get(const Symbol& _key) const;
-    types::InternalType* getCurrentLevel(const Symbol& _key) const;
-    types::InternalType* getAllButCurrentLevel(const Symbol& _key) const;
-    types::InternalType* getInSpecificLevel(const Symbol& _key, int _iLevel) const;
+        MapVars::iterator it = vars.begin();
+        for (; it != vars.end() ; ++it)
+        {
+            if (it->second->empty())
+            {
+                continue;
+            }
 
-    std::list<symbol::Symbol>* getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd) const;
-    std::list<std::wstring>* getVarsName();
-    std::list<std::wstring>* getMacrosName();
-    std::list<std::wstring>* getFunctionsName();
+            if ((it->second->top()->m_iLevel == _iLevel || _iLevel == 1) && it->second->top()->m_pIT->isCallable())
+            {
+                types::Callable* pCall = it->second->top()->m_pIT->getAs<types::Callable>();
+                if (_stModuleName == L"" || _stModuleName == pCall->getModule())
+                {
+                    symb->push_back(it->first);
+                }
+            }
+        }
 
-    /*globals*/
-    bool isGlobalVisible(const symbol::Symbol& _key) const;
-    void setGlobalVisible(const symbol::Symbol& _key, bool bVisible);
-    void removeGlobal(const symbol::Symbol& _key);
-    void removeGlobalAll();
-    void createEmptyGlobalValue(const symbol::Symbol& _key);
-    bool isGlobalExists(const symbol::Symbol& _key) const;
-    types::InternalType* getGlobalValue(const symbol::Symbol& _key) const;
-    void setGlobalValue(const symbol::Symbol& _key, types::InternalType& _value);
+        return symb;
+    }
 
-    bool remove(const Symbol& _key);
+    bool putInPreviousScope(Variable* _var, types::InternalType* _pIT, int _iLevel)
+    {
+        if (_var->empty())
+        {
+            _var->put(_pIT, _iLevel);
+        }
+        else if (_var->top()->m_iLevel > _iLevel)
+        {
+            ScopedVariable* pVar = _var->top();
+            _var->pop();
+            putInPreviousScope(_var, _pIT, _iLevel);
+            _var->put(pVar->m_pIT, pVar->m_iLevel);
+        }
+        else
+        {
+            _var->put(_pIT, _iLevel);
+        }
 
-    void IncreaseLevel()
+        return true;
+    }
+
+    //globals
+
+    void setGlobal(const Symbol& _key)
+    {
+        getOrCreate(_key)->setGlobal(true);
+    }
+
+    void setGlobalVisible(const Symbol& _key, bool _bVisible, int _iLevel)
     {
-        m_iLevel++;
+        Variable* pVar = getOrCreate(_key);
+        pVar->setGlobalVisible(_iLevel, _bVisible);
+        if (_bVisible)
+        {
+            pVar->setGlobal(true);
+        }
     }
-    void DecreaseLevel()
+
+    bool isGlobalVisible(const Symbol& _key, int _iLevel)
     {
-        m_iLevel--;
+        return getOrCreate(_key)->isGlobalVisible(_iLevel);
     }
+
+    bool isGlobal(const Symbol& _key, int _iLevel)
+    {
+        return getOrCreate(_key)->isGlobal();
+    }
+
+    types::InternalType* getGlobalValue(const Symbol& _key)
+    {
+        return getOrCreate(_key)->getGlobalValue();
+    }
+
+    void removeGlobal(const Symbol& _key, int _iLevel)
+    {
+        Variable* pVar = getOrCreate(_key);
+        if (pVar->isGlobal())
+        {
+            pVar->setGlobal(false);
+            pVar->setGlobalValue(NULL);
+        }
+
+        remove(pVar, _iLevel);
+    }
+
+private:
+    typedef std::map<Symbol, Variable*> MapVars;
+    MapVars vars;
 };
 }
-#endif /* !__VARIABLES_HXX__ */
+
+#endif // !__VARIABLES_HXX__
index 0956d16..a4f0dcb 100644 (file)
@@ -9,11 +9,12 @@
 *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 *
 */
-
 #include "context.hxx"
+#include "internal.hxx"
 #include "function.hxx"
 #include "macro.hxx"
 #include "macrofile.hxx"
+#include "variables.hxx"
 
 namespace symbol
 {
@@ -21,8 +22,9 @@ Context* Context::me;
 
 Context::Context()
 {
-    m_scopes = new Scopes();
-    m_scopes->scope_begin();
+    m_iLevel = 0;
+    varStack.push(new VarList());
+    globals = new std::list<Symbol>();
 }
 
 Context* Context::getInstance(void)
@@ -36,138 +38,279 @@ Context* Context::getInstance(void)
 
 void Context::scope_begin()
 {
-    m_scopes->scope_begin();
+    m_iLevel++;
+    varStack.push(new VarList());
 }
 
 void Context::scope_end()
 {
-    m_scopes->scope_end();
+    //clear varList of current scope
+    if (varStack.empty() == false)
+    {
+        clearCurrentScope(true);
+    }
+
+    m_iLevel--;
+}
+
+bool Context::clearCurrentScope(bool _bClose)
+{
+    if (varStack.empty())
+    {
+        return true;
+    }
+
+    VarList* varList = varStack.top();
+    std::map<Symbol, Variable*>::iterator it = varList->begin();
+    for (; it != varList->end() ; ++it)
+    {
+        if (it->second->empty() == false && it->second->top()->m_iLevel == m_iLevel)
+        {
+            types::InternalType* pIT = it->second->top()->m_pIT;
+            pIT->DecreaseRef();
+            if (pIT->isDeletable())
+            {
+                delete pIT;
+            }
+
+            it->second->pop();
+        }
+    }
+
+    varList->clear();
+
+    if (_bClose)
+    {
+        delete varList;
+        varStack.pop();
+    }
+
+    return true;
+}
+
+Variable* Context::getOrCreate(const Symbol& _key)
+{
+    return variables.getOrCreate(_key);
+}
+
+types::InternalType* Context::get(const Symbol& _key)
+{
+    return get(_key, -1);
+}
+
+types::InternalType* Context::get(const Variable* _var)
+{
+    types::InternalType* pIT = _var->get();
+
+    if (pIT == NULL)
+    {
+        //look in libraries
+        pIT = libraries.get(_var->name_get(), -1);
+        if (pIT)
+        {
+            put((Variable*)_var, pIT);
+        }
+    }
+
+    return pIT;
 }
 
-types::InternalType* Context::get(const symbol::Symbol& _key) const
+types::InternalType* Context::get(const Symbol& _key, int _iLevel)
 {
-    return m_scopes->get(_key);
+    types::InternalType* pIT = NULL;
+    if (_iLevel == m_iLevel || _iLevel == -1)
+    {
+        //look for in current VarList
+        VarList::iterator it = varStack.top()->find(_key);
+        if (it != varStack.top()->end())
+        {
+            if (it->second->empty() == false)
+            {
+                return it->second->top()->m_pIT;
+            }
+        }
+    }
+
+    if (pIT == NULL)
+    {
+        pIT = variables.get(_key, _iLevel);
+        if (pIT == NULL)
+        {
+            //find in libraries
+            pIT = libraries.get(_key, _iLevel);
+            if (pIT)
+            {
+                //add symbol to current scope
+                put(_key, pIT);
+            }
+        }
+    }
+
+    return pIT;
 }
 
-types::InternalType* Context::getCurrentLevel(const symbol::Symbol& _key) const
+types::InternalType* Context::getCurrentLevel(const Symbol& _key)
 {
-    return m_scopes->getCurrentLevel(_key);
+    return variables.get(_key, m_iLevel);
 }
 
-types::InternalType* Context::getAllButCurrentLevel(const symbol::Symbol& _key) const
+types::InternalType* Context::getAllButCurrentLevel(const Symbol& _key)
 {
-    return m_scopes->getAllButCurrentLevel(_key);
+    return variables.getAllButCurrentLevel(_key, m_iLevel);
 }
 
-types::InternalType* Context::getFunction(const symbol::Symbol& _key) const
+types::InternalType* Context::getFunction(const Symbol& _key)
 {
-    return m_scopes->get(_key);
+    return get(_key);
 }
 
-std::list<symbol::Symbol>* Context::getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd)
+std::list<Symbol>* Context::getFunctionList(std::wstring _stModuleName)
 {
-    return m_scopes->getFunctionList(_stModuleName, _bFromEnd);
+    return variables.getFunctionList(_stModuleName, m_iLevel);
 }
 
 std::list<std::wstring>* Context::getVarsName()
 {
-    return m_scopes->getVarsName();
+    return new std::list<std::wstring>();
+    //return scopes.getVarsName();
 }
 
 std::list<std::wstring>* Context::getMacrosName()
 {
-    return m_scopes->getMacrosName();
+    std::list<std::wstring>* vars = variables.getMacrosName();
+    std::list<std::wstring>* libs = libraries.getMacrosName();
+    vars->insert(vars->end(), libs->begin(), libs->end());
+    delete libs;
+    return vars;
 }
 
 std::list<std::wstring>* Context::getFunctionsName()
 {
-    return m_scopes->getFunctionsName();
+    return new std::list<std::wstring>();
+    //return scopes.getFunctionsName();
 }
 
-bool Context::put(const symbol::Symbol& _key, types::InternalType &type)
+void Context::put(Variable* _var, types::InternalType* _pIT)
 {
-    m_scopes->put(_key, type);
-    return true;
+    _var->put(_pIT, m_iLevel);
+    if (varStack.empty() == false)
+    {
+        (*varStack.top())[_var->name_get()] = _var;
+    }
 }
 
-bool Context::remove(const symbol::Symbol& _key)
+void Context::put(const Symbol& _key, types::InternalType* _pIT)
 {
-    m_scopes->remove(_key);
-    return true;
+    Variable* var = variables.getOrCreate(_key);
+    put(var, _pIT);
+    if (_pIT->isLibrary())
+    {
+        Library* lib = libraries.getOrCreate(_key);
+        lib->put((types::Library*)_pIT, m_iLevel);
+    }
 }
 
-bool Context::putInPreviousScope(const symbol::Symbol& _key, types::InternalType &type)
+bool Context::remove(const Symbol& _key)
 {
-    m_scopes->putInPreviousScope(_key, type);
-    return true;
+    if (variables.remove(_key, m_iLevel))
+    {
+        varStack.top()->erase(_key);
+        libraries.remove(_key, m_iLevel);
+        return true;
+    }
+
+    return false;
 }
 
-bool Context::addFunction(types::Function *_info)
+bool Context::removeAll()
 {
-    m_scopes->addFunction(symbol::Symbol(_info->getName()), *_info);
+    return clearCurrentScope(false);
+}
+
+bool Context::putInPreviousScope(Variable* _var, types::InternalType* _pIT)
+{
+    //add variable in previous scope
+    variables.putInPreviousScope(_var, _pIT, m_iLevel - 1);
+
+    //add variable in stack of using variables
+    if (varStack.empty() == false)
+    {
+        VarList *list =  varStack.top();
+        varStack.pop();
+        if (varStack.empty() == false)
+        {
+            (*varStack.top())[_var->name_get()] = _var;
+            varStack.push(list);
+        }
+    }
     return true;
 }
 
-bool Context::AddMacro(types::Macro *_info)
+bool Context::addFunction(types::Function *_info)
 {
-    m_scopes->put(symbol::Symbol(_info->getName()), *_info);
+    put(Symbol(_info->getName()), _info);
     return true;
 }
 
-bool Context::AddMacroFile(types::MacroFile *_info)
+bool Context::addMacro(types::Macro *_info)
 {
-    m_scopes->put(symbol::Symbol(_info->getName()), *_info);
+    put(Symbol(_info->getName()), _info);
     return true;
 }
 
-bool Context::isGlobalVisible(const symbol::Symbol& _key) const
+bool Context::addMacroFile(types::MacroFile *_info)
 {
-    return m_scopes->isGlobalVisible(_key);
+    put(Symbol(_info->getName()), _info);
+    return true;
 }
 
-/*return global variable, search in global scope ( highest )*/
-types::InternalType* Context::getGlobalValue(const symbol::Symbol& _key) const
+bool Context::isGlobalVisible(const Symbol& _key)
 {
-    m_scopes->getGlobalValue(_key);
-    return NULL;
+    return variables.isGlobalVisible(_key, m_iLevel);
 }
 
 /*return global variable existance status*/
-bool Context::isGlobalExists(const symbol::Symbol& _key) const
+bool Context::isGlobal(const Symbol& _key)
 {
-    return m_scopes->isGlobalExists(_key);
+    return variables.isGlobal(_key, m_iLevel);
 }
 
-void Context::setGlobalValue(const symbol::Symbol& _key, types::InternalType &value)
+types::InternalType* Context::getGlobalValue(const Symbol& _key)
 {
-    m_scopes->setGlobalValue(_key, value);
+    return variables.getGlobalValue(_key);
 }
 
-void Context::createEmptyGlobalValue(const symbol::Symbol& _key)
+void Context::setGlobalVisible(const Symbol& _key, bool bVisible)
 {
-    m_scopes->createEmptyGlobalValue(_key);
+    variables.setGlobalVisible(_key, bVisible, m_iLevel);
 }
 
-void Context::setGlobalVisible(const symbol::Symbol& _key, bool bVisible)
+void Context::setGlobal(const Symbol& _key)
 {
-    m_scopes->setGlobalVisible(_key, bVisible);
+    variables.setGlobal(_key);
+    globals->push_back(_key);
 }
 
-void Context::removeGlobal(const symbol::Symbol& _key)
+void Context::removeGlobal(const Symbol& _key)
 {
-    m_scopes->removeGlobal(_key);
+    variables.removeGlobal(_key, m_iLevel);
 }
 
 void Context::removeGlobalAll()
 {
-    m_scopes->removeGlobalAll();
+    std::list<Symbol>::iterator it = globals->begin();
+    for (; it != globals->end(); ++it)
+    {
+        removeGlobal(*it);
+    }
+
+    globals->clear();
 }
 
 void Context::print(std::wostream& ostr) const
 {
     ostr << L"  Environment Variables:" << std::endl;
     ostr << L"==========================" << std::endl;
-    ostr << *m_scopes;
 }
 
 }
diff --git a/scilab/modules/symbol/src/cpp/libraries.cpp b/scilab/modules/symbol/src/cpp/libraries.cpp
deleted file mode 100644 (file)
index edae211..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
-*  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
-*
-*/
-
-#include "libraries.hxx"
-#include "context.hxx"
-
-namespace symbol
-{
-types::MacroFile* LibBox::getMacroFile(const Symbol& _key)
-{
-    return m_pLib->get(_key.name_get());
-}
-
-void Libraries::put(const Symbol& _key, types::InternalType& _iT)
-{
-    if (_iT.isLibrary() == false)
-    {
-        return;
-    }
-
-    types::Library* pLib = _iT.getAs<types::Library>();
-
-    LibMap::iterator itVar = m_libmap.find(_key);
-    LibBoxList* pL = NULL;
-    LibBox* pBox = NULL;
-
-    if (itVar != m_libmap.end())
-    {
-        //item alreay exists
-
-        //check scope level
-        LibBoxList::reverse_iterator itBox = itVar->second->rbegin();
-
-        bool bInserted = false;
-        for (; itBox != itVar->second->rend() ; itBox++)
-        {
-            pBox = *itBox;
-            if ((*itBox)->getValue() == pLib)
-            {
-                return;
-            }
-
-            //update value
-            (*itBox)->setValue(*pLib);
-            bInserted = true;
-            break;
-        }
-    }
-    else
-    {
-        //new var
-        pBox = new LibBox(m_iLevel, *pLib);
-        pL = new LibBoxList();
-        pL->push_back(pBox);
-        m_libmap[_key] = pL;
-        m_liblist.push_back(_key);
-    }
-
-    return;
-}
-
-types::MacroFile* Libraries::get(const Symbol& _key) const
-{
-    types::MacroFile* pIT = NULL;
-    LibList::const_reverse_iterator it = m_liblist.rbegin();
-    for (; it != m_liblist.rend() ; ++it)
-    {
-        LibBoxList* l = m_libmap.find(*it)->second;
-        LibBoxList::const_reverse_iterator itBox = l->rbegin();
-        for (; itBox != l->rend(); ++itBox)
-        {
-            pIT = (*itBox)->getMacroFile(_key);
-            if (pIT)
-            {
-                Context::getInstance()->AddMacroFile(pIT);
-                return pIT;
-            }
-        }
-    }
-
-    return pIT;
-}
-
-bool Libraries::remove(const Symbol& _key)
-{
-    LibMap::iterator itVar = m_libmap.find(_key);
-    if (itVar != m_libmap.end())
-    {
-        LibBox* pBox = itVar->second->back();
-        if (pBox->getLevel() != m_iLevel)
-        {
-            return false;
-        }
-
-        if (pBox->getValue())
-        {
-            delete pBox;
-        }
-
-        itVar->second->pop_back();
-
-        //remove empty entries from variable map
-        if (itVar->second->empty())
-        {
-            m_liblist.remove(itVar->first);
-            m_libmap.erase(itVar);
-        }
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-std::list<std::wstring>* Libraries::getMacrosName()
-{
-    std::list<std::wstring>* plOut = new std::list<std::wstring>();
-    types::Library* pLib = NULL;
-    LibMap::const_iterator it = m_libmap.begin();
-
-    for (; it != m_libmap.end(); it++)
-    {
-        pLib = it->second->back()->getValue();
-        std::list<std::wstring>* tmpList = pLib->getMacrosName();
-        plOut->insert(plOut->end(), tmpList->begin(), tmpList->end());
-        delete tmpList;
-    }
-
-    return plOut;
-}
-
-}
diff --git a/scilab/modules/symbol/src/cpp/variables.cpp b/scilab/modules/symbol/src/cpp/variables.cpp
deleted file mode 100644 (file)
index 20d8673..0000000
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
-*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-*  Copyright (C) 2013 - 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
-*
-*/
-
-#include "variables.hxx"
-#include "callable.hxx"
-#include "double.hxx"
-
-namespace symbol
-{
-VarBox::VarBox(int _iLevel, types::InternalType* _pIT, bool _bGlobal, bool _bGlobalVisible)
-    : m_iLevel(_iLevel), m_pIT(_pIT), m_bGlobal(_bGlobal), m_bGlobalVisible(_bGlobalVisible)
-{
-    if (m_pIT)
-    {
-        m_pIT->IncreaseRef();
-    }
-}
-
-void Variables::put(const Symbol& _key, types::InternalType& _pIT)
-{
-    put(_key, _pIT, m_iLevel);
-}
-
-void Variables::put(const Symbol& _key, types::InternalType& _iT, int _iLevel)
-{
-    if (isGlobalVisible(_key))
-    {
-        setGlobalValue(_key, _iT);
-        return;
-    }
-    VarMap::iterator itVar = m_vars.find(_key);
-    VarBoxList* pL = NULL;
-    VarBox* pBox = NULL;
-
-    if (itVar != m_vars.end())
-    {
-        //item alreay exists
-
-        //check scope level
-        VarBoxList::reverse_iterator itBox = itVar->second->rbegin();
-
-        bool bInserted = false;
-        for (; itBox != itVar->second->rend() ; itBox++)
-        {
-            pBox = *itBox;
-            if ((*itBox)->m_iLevel > _iLevel)
-            {
-                continue;
-            }
-            else if ((*itBox)->m_iLevel < _iLevel)
-            {
-                pBox = new VarBox(_iLevel, &_iT);
-                itVar->second->insert(itBox.base(), pBox);
-                bInserted = true;
-                break;
-            }
-            else if ((*itBox)->m_iLevel == _iLevel)
-            {
-                if ((*itBox)->m_pIT == &_iT)
-                {
-                    return;
-                }
-
-                //increase ref
-                _iT.IncreaseRef();
-
-                (*itBox)->m_pIT->DecreaseRef();
-                if ((*itBox)->m_pIT->isDeletable())
-                {
-                    delete (*itBox)->m_pIT;
-                }
-
-                //update value
-                (*itBox)->m_pIT = &_iT;
-                bInserted = true;
-                break;
-            }
-        }
-
-        if (bInserted == false)
-        {
-            //for case of first var ref is in higher scope
-            pBox = new VarBox(_iLevel, &_iT);
-            itVar->second->push_front(pBox);
-        }
-    }
-    else
-    {
-        //new var
-        pBox = new VarBox(_iLevel, &_iT);
-        pL = new VarBoxList();
-        pL->push_back(pBox);
-        m_vars[_key] = pL;
-    }
-
-    return;
-}
-
-void Variables::putInPreviousScope(const Symbol& _key, types::InternalType& _iT)
-{
-    put(_key, _iT, Max(0, m_iLevel - 1));
-}
-
-types::InternalType* Variables::get(const Symbol& _key) const
-{
-    if (isGlobalExists(_key) && isGlobalVisible(_key))
-    {
-        return getGlobalValue(_key);
-    }
-    else
-    {
-        VarMap::const_iterator itVar = m_vars.find(_key);
-        if (itVar != m_vars.end())
-        {
-            if (m_iLevel != itVar->second->back()->m_iLevel && itVar->second->back()->m_bGlobal == true)
-            {
-                return getGlobalValue(_key);
-            }
-
-            return itVar->second->back()->m_pIT;
-        }
-        else
-        {
-            return NULL;
-        }
-    }
-}
-
-types::InternalType* Variables::getCurrentLevel(const Symbol& _key) const
-{
-    if (isGlobalExists(_key) && isGlobalVisible(_key))
-    {
-        return getGlobalValue(_key);
-    }
-    else
-    {
-        VarMap::const_iterator itVar = m_vars.find(_key);
-        if (itVar != m_vars.end() && itVar->second->back()->m_iLevel == m_iLevel)
-        {
-            return itVar->second->back()->m_pIT;
-        }
-        else
-        {
-            return NULL;
-        }
-    }
-}
-
-types::InternalType* Variables::getAllButCurrentLevel(const Symbol& _key) const
-{
-    VarMap::const_iterator itVar = m_vars.find(_key);
-    if (itVar != m_vars.end())
-    {
-        VarBoxList* pL = itVar->second;
-        VarBoxList::iterator itBox = pL->begin();
-        for (; itBox != pL->end() ; itBox++)
-        {
-            if ((*itBox)->m_iLevel < m_iLevel)
-            {
-                return (*itBox)->m_pIT;
-            }
-        }
-    }
-
-    return NULL;
-}
-
-types::InternalType* Variables::getInSpecificLevel(const Symbol& _key, int _iLevel) const
-{
-    VarMap::const_iterator itVar = m_vars.find(_key);
-    if (itVar != m_vars.end())
-    {
-        VarBoxList* pL = itVar->second;
-        VarBoxList::iterator itBox = pL->begin();
-        for (; itBox != pL->end() ; itBox++)
-        {
-            if ((*itBox)->m_iLevel == _iLevel)
-            {
-                return (*itBox)->m_pIT;
-            }
-        }
-    }
-
-    return NULL;
-}
-
-bool Variables::remove(const Symbol& _key)
-{
-    VarMap::iterator itVar = m_vars.find(_key);
-    if (itVar != m_vars.end())
-    {
-        VarBox* pBox = itVar->second->back();
-        if (pBox->m_iLevel != m_iLevel)
-        {
-            return false;
-        }
-
-        if (pBox->m_pIT)
-        {
-            pBox->m_pIT->DecreaseRef();
-            if (pBox->m_pIT->isDeletable())
-            {
-                delete pBox->m_pIT;
-            }
-
-            delete pBox;
-        }
-
-        itVar->second->pop_back();
-
-        //remove empty entries from variable map
-        if (itVar->second->empty())
-        {
-            m_vars.erase(itVar);
-        }
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-std::list<std::wstring>* Variables::getVarsName()
-{
-    std::list<std::wstring>* plOut = new std::list<std::wstring>();
-    types::InternalType* pIT = NULL;
-    VarMap::const_iterator it = m_vars.begin();
-
-    for (; it != m_vars.end(); it++)
-    {
-        pIT = it->second->front()->m_pIT;
-        if (pIT && pIT->isCallable() == false)
-        {
-            plOut->push_back(it->first.name_get().c_str());
-        }
-    }
-
-    return plOut;
-}
-
-std::list<std::wstring>* Variables::getMacrosName()
-{
-    std::list<std::wstring>* plOut = new std::list<std::wstring>();
-    types::InternalType* pIT = NULL;
-    VarMap::const_iterator it = m_vars.begin();
-
-    for (; it != m_vars.end(); it++)
-    {
-        pIT = it->second->front()->m_pIT;
-        if (pIT && (pIT->isMacro() || pIT->isMacroFile()))
-        {
-            plOut->push_back(it->first.name_get().c_str());
-        }
-    }
-
-    return plOut;
-}
-
-std::list<std::wstring>* Variables::getFunctionsName()
-{
-    std::list<std::wstring>* plOut = new std::list<std::wstring>();
-    types::InternalType* pIT = NULL;
-    VarMap::const_iterator it = m_vars.begin();
-
-    for (; it != m_vars.end(); it++)
-    {
-        pIT = it->second->front()->m_pIT;
-        if (pIT && pIT->isFunction())
-        {
-            plOut->push_back(it->first.name_get().c_str());
-        }
-    }
-
-    return plOut;
-}
-
-std::list<symbol::Symbol>* Variables::getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd) const
-{
-    bool bAll = _stModuleName == L"";
-    std::list<symbol::Symbol>* lst = new std::list<symbol::Symbol>;
-
-    VarMap::const_iterator it = m_vars.begin();
-    for (; it != m_vars.end(); it++)
-    {
-        types::InternalType* pIT = NULL;
-        if (it->second->size() == 0)
-        {
-            continue;
-        }
-
-        if (_bFromEnd)
-        {
-            pIT = it->second->front()->m_pIT;
-        }
-        else
-        {
-            VarBox* pBox = it->second->back();
-            if (pBox->m_iLevel != m_iLevel)
-            {
-                continue;
-            }
-
-            pIT = pBox->m_pIT;
-        }
-
-        //exclude globals
-        if (pIT == NULL)
-        {
-            continue;
-        }
-
-        if (pIT->isCallable() == false)
-        {
-            continue;
-        }
-
-        if (bAll)
-        {
-            lst->push_back(it->first);
-            continue;
-        }
-
-        types::Callable* pC = pIT->getAs<types::Callable>();
-        if (_stModuleName == pC->getModule())
-        {
-            lst->push_back(it->first);
-        }
-
-    }
-    return lst;
-}
-
-bool Variables::isGlobalVisible(const symbol::Symbol& _key) const
-{
-    VarMap::const_iterator itVar = m_vars.find(_key);
-    if (itVar != m_vars.end())
-    {
-        VarBoxList* pL = itVar->second;
-        VarBox* pBox = pL->back();
-        if (pBox->m_iLevel == m_iLevel && pBox->m_bGlobal && pBox->m_bGlobalVisible)
-        {
-            return true;
-        }
-    }
-
-    return false;
-}
-
-void Variables::setGlobalVisible(const symbol::Symbol& _key, bool bVisible)
-{
-    VarBox* pBox = NULL;
-    VarBoxList* pL = NULL;
-
-    VarMap::const_iterator itVar = m_vars.find(_key);
-    if (itVar != m_vars.end())
-    {
-        VarBoxList* pL = itVar->second;
-        pBox = pL->back();
-        if (pBox->m_iLevel == m_iLevel)
-        {
-            //update
-
-            pBox->m_bGlobalVisible = true;
-            pBox->m_bGlobal = true;
-        }
-        else
-        {
-            //add in existing VarBoxList
-            pBox = new VarBox(m_iLevel, NULL);
-            pBox->m_bGlobalVisible = true;
-            pBox->m_bGlobal = true;
-            pL->push_back(pBox);
-        }
-    }
-    else
-    {
-        //create a new VarBoxList
-        pBox = new VarBox(m_iLevel, NULL);
-        pBox->m_bGlobalVisible = true;
-        pBox->m_bGlobal = true;
-        pL = new VarBoxList();
-        pL->push_back(pBox);
-        m_vars[_key] = pL;
-    }
-}
-
-void Variables::removeGlobal(const symbol::Symbol& _key)
-{
-    GlobalMap::iterator it = m_globals.find(_key);
-    if (it != m_globals.end())
-    {
-        removeGlobal(it);
-    }
-}
-
-void Variables::removeGlobal(GlobalMap::iterator& _it)
-{
-    //remove all refs in scopes
-    Symbol key = _it->first;
-
-    VarMap::iterator itVar = m_vars.find(key);
-    if (itVar != m_vars.end())
-    {
-        VarBoxList* pLBox = itVar->second;
-        VarBoxList::iterator itBox = pLBox->begin();
-        while (itBox != pLBox->end())
-        {
-            VarBox* pBox = (*itBox);
-            if (pBox->m_pIT != NULL)
-            {
-                pBox->m_bGlobal = false;
-                pBox->m_bGlobalVisible = false;
-                itBox++;
-            }
-            else
-            {
-                VarBoxList::iterator itSave = itBox;
-                itSave++;
-                pLBox->erase(itBox);
-                itBox = itSave;
-            }
-
-        }
-
-        if (pLBox->empty())
-        {
-            m_vars.erase(key);
-        }
-    }
-
-    _it->second->DecreaseRef();
-    if (_it->second->isDeletable())
-    {
-        delete _it->second;
-    }
-
-    m_globals.erase(_it);
-}
-
-void Variables::removeGlobalAll()
-{
-    //for all globals, remove them and all references in scopes
-    GlobalMap::iterator it;
-    while ((it = m_globals.begin()) != m_globals.end())
-    {
-        removeGlobal(it);
-    }
-}
-
-void Variables::createEmptyGlobalValue(const symbol::Symbol& _key)
-{
-    types::InternalType* pIT = types::Double::Empty();
-    pIT->IncreaseRef();
-    m_globals[_key] = pIT;
-}
-
-bool Variables::isGlobalExists(const symbol::Symbol& _key) const
-{
-    return (m_globals.find(_key) != m_globals.end());
-}
-
-types::InternalType* Variables::getGlobalValue(const symbol::Symbol& _key) const
-{
-    GlobalMap::const_iterator it = m_globals.find(_key);
-    if (it != m_globals.end())
-    {
-        return it->second;
-    }
-    else
-    {
-        return NULL;
-    }
-}
-
-void Variables::setGlobalValue(const symbol::Symbol& _key, types::InternalType& _value)
-{
-    GlobalMap::iterator it = m_globals.find(_key);
-    if (it != m_globals.end())
-    {
-        if (it->second != NULL)
-        {
-            it->second->DecreaseRef();
-            if (it->second->isDeletable())
-            {
-                delete it->second;
-            }
-        }
-
-        _value.IncreaseRef();
-        m_globals[_key] = &_value;
-    }
-}
-
-}
index 6175c57..f643c46 100644 (file)
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="src\cpp\context.cpp" />
-    <ClCompile Include="src\cpp\libraries.cpp" />
-    <ClCompile Include="src\cpp\scope.cpp" />
     <ClCompile Include="src\cpp\symbol.cpp" />
-    <ClCompile Include="src\cpp\variables.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\context.hxx" />
     <ClInclude Include="includes\export_symbol.h" />
     <ClInclude Include="includes\libraries.hxx" />
-    <ClInclude Include="includes\scope.hxx" />
     <ClInclude Include="includes\symbol.hxx" />
     <ClInclude Include="includes\variables.hxx" />
   </ItemGroup>
index 7ea6bc0..1f071d1 100644 (file)
     <ClCompile Include="src\cpp\symbol.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="src\cpp\variables.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="src\cpp\scope.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="src\cpp\libraries.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\context.hxx">
     <ClInclude Include="includes\symbol.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="includes\variables.hxx">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="includes\scope.hxx">
+    <ClInclude Include="includes\libraries.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="includes\libraries.hxx">
+    <ClInclude Include="includes\variables.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
   </ItemGroup>
index 781b4b4..ed592a5 100644 (file)
@@ -52,7 +52,7 @@ void setHOMEW(const wchar_t* _home)
 {
     //add SCI value in context as variable
     types::String *pS = new types::String(_home);
-    symbol::Context::getInstance()->put(symbol::Symbol(L"home"), *pS);
+    symbol::Context::getInstance()->put(symbol::Symbol(L"home"), pS);
 
     std::wstring home(_home);
     ConfigVariable::setHOME(home);
index 1ca4e10..1bd4d55 100644 (file)
@@ -31,6 +31,7 @@ extern "C"
 #include "getenvc.h"
 }
 
+using namespace std;
 /*--------------------------------------------------------------------------*/
 wchar_t* getSCIHOMEW(void)
 {
@@ -58,7 +59,7 @@ void setSCIHOMEW(const wchar_t* _sci_home)
 {
     //add SCI value in context as variable
     types::String *pS = new types::String(_sci_home);
-    symbol::Context::getInstance()->put(symbol::Symbol(L"SCIHOME"), *pS);
+    symbol::Context::getInstance()->put(symbol::Symbol(L"SCIHOME"), pS);
 
     std::wstring sci_home(_sci_home);
     ConfigVariable::setSCIHOME(sci_home);
index 049850b..34c9867 100644 (file)
@@ -29,6 +29,7 @@ extern "C"
 #include "getenvc.h"
 }
 
+using namespace std;
 char *getSCI(void)
 {
     return wide_string_to_UTF8(ConfigVariable::getSCIPath().c_str());
@@ -61,7 +62,7 @@ void setSCI(const char* _sci_path)
     //SCI
     wchar_t* pwstSCI = to_wide_string(pstSlash);
     types::String *pSSCI = new types::String(pwstSCI);
-    symbol::Context::getInstance()->put(symbol::Symbol(L"SCI"), *pSSCI);
+    symbol::Context::getInstance()->put(symbol::Symbol(L"SCI"), pSSCI);
 
     //WSCI
     wchar_t* pwstWSCI = NULL;
@@ -71,7 +72,7 @@ void setSCI(const char* _sci_path)
     SlashToAntislash(_sci_path, pstBackSlash);
     pwstWSCI = to_wide_string(pstBackSlash);
     types::String *pSWSCI = new types::String(pwstWSCI);
-    symbol::Context::getInstance()->put(symbol::Symbol(L"WSCI"), *pSWSCI);
+    symbol::Context::getInstance()->put(symbol::Symbol(L"WSCI"), pSWSCI);
     delete[] pstBackSlash;
 #else
     pwstWSCI = to_wide_string(_sci_path);
index eb495d9..3703cd2 100644 (file)
@@ -54,7 +54,7 @@ void setTMPDIRW(const wchar_t* _sci_tmpdir)
 {
     //add SCI value in context as variable
     types::String *pS = new types::String(_sci_tmpdir);
-    symbol::Context::getInstance()->put(symbol::Symbol(L"TMPDIR"), *pS);
+    symbol::Context::getInstance()->put(symbol::Symbol(L"TMPDIR"), pS);
 
     //add SCI value ConfigVariable
     std::wstring sci_tmpdir(_sci_tmpdir);
index 61accee..1a7ae5c 100644 (file)
@@ -13,7 +13,7 @@
 #include "time_gw.hxx"
 #include "function.hxx"
 #include "callable.hxx"
-#include "arrayof.hxx"
+#include "double.hxx"
 #include "timer.hxx"
 
 static Timer timer;
index 0fd1849..6024913 100644 (file)
@@ -58,5 +58,6 @@
 #include "sparse.hxx"
 #include "graphichandle.hxx"
 #include "void.hxx"
+#include "library.hxx"
 
 #endif /* !ALL_TYPES_HXX */
index 7542e70..180eed4 100644 (file)
@@ -13,7 +13,8 @@
 #ifndef __LIBRARY_HXX__
 #define __LIBRARY_HXX__
 
-#include "macrofile.hxx"
+#include <list>
+#include "typesdecl.hxx"
 #include "dynlib_types.h"
 
 namespace types
index 44cd483..5a929b1 100644 (file)
 #define __MACRO_HXX__
 
 #include <list>
+#include <string>
+#include "context.hxx"
 #include "types.hxx"
 #include "callable.hxx"
 #include "double.hxx"
 #include "seqexp.hxx"
 
-using namespace std;
 namespace types
 {
 class Macro : public Callable
 {
 public :
-    Macro() : Callable(), m_ArgInSymb(symbol::Symbol(L"nargin")), m_ArgOutSymb(symbol::Symbol(L"nargout")) {}
-    Macro(const std::wstring& _stName, std::list<symbol::Symbol> &_inputArgs, std::list<symbol::Symbol> &_outputArgs, ast::SeqExp &_body, const wstring& _stModule);
+    Macro() : Callable(),
+        m_Nargin(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"nargin"))),
+        m_Nargout(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"nargout"))),
+        m_Varargin(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"varargin"))),
+        m_Varargout(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"varargout")))
+    {
+    }
+
+    Macro(const std::wstring& _stName, std::list<symbol::Variable*> &_inputArgs, std::list<symbol::Variable*> &_outputArgs, ast::SeqExp &_body, const std::wstring& _stModule);
     virtual                     ~Macro();
 
     // FIXME : Should not return NULL;
@@ -47,31 +55,33 @@ public :
     ast::SeqExp*                getBody();
 
     /* return type as string ( double, int, cell, list, ... )*/
-    virtual wstring             getTypeStr()
+    virtual std::wstring        getTypeStr()
     {
         return L"function";
     }
     /* return type as short string ( s, i, ce, l, ... )*/
-    virtual wstring             getShortTypeStr()
+    virtual std::wstring        getShortTypeStr()
     {
         return L"function";
     }
 
-    list<symbol::Symbol>*       inputs_get();
-    list<symbol::Symbol>*       outputs_get();
+    std::list<symbol::Variable*>*   inputs_get();
+    std::list<symbol::Variable*>*   outputs_get();
 
     virtual int getNbInputArgument(void);
     virtual int getNbOutputArgument(void);
 
 private :
-    std::list<symbol::Symbol>*  m_inputArgs;
-    std::list<symbol::Symbol>*  m_outputArgs;
-    ast::SeqExp*                m_body;
-    bool                        bAutoAlloc;
-    symbol::Symbol              m_ArgInSymb;
-    symbol::Symbol              m_ArgOutSymb;
-    Double*                     m_pDblArgIn;
-    Double*                     m_pDblArgOut;
+    std::list<symbol::Variable*>*   m_inputArgs;
+    std::list<symbol::Variable*>*   m_outputArgs;
+    ast::SeqExp*                    m_body;
+    bool                            bAutoAlloc;
+    symbol::Variable*               m_Nargin;
+    symbol::Variable*               m_Nargout;
+    symbol::Variable*               m_Varargin;
+    symbol::Variable*               m_Varargout;
+    Double*                         m_pDblArgIn;
+    Double*                         m_pDblArgOut;
 
 };
 }
index 5c4ccf1..7aadd73 100644 (file)
@@ -14,6 +14,7 @@
 #ifndef __MACROFILE_HXX__
 #define __MACROFILE_HXX__
 
+#include <string>
 #include "callable.hxx"
 #include "macro.hxx"
 
@@ -23,7 +24,7 @@ class MacroFile : public Callable
 {
 public :
     MacroFile(): Callable() {};
-    MacroFile(wstring _stName, wstring _stPath, wstring _stModule);
+    MacroFile(std::wstring _stName, std::wstring _stPath, std::wstring _stModule);
     virtual                 ~MacroFile();
 
     //FIXME : Should not return NULL
@@ -47,12 +48,12 @@ public :
     void                    setFirstLine(int _iLine);
 
     /* return type as string ( double, int, cell, list, ... )*/
-    virtual wstring         getTypeStr()
+    virtual std::wstring    getTypeStr()
     {
         return L"function";
     }
     /* return type as short string ( s, i, ce, l, ... )*/
-    virtual wstring         getShortTypeStr()
+    virtual std::wstring    getShortTypeStr()
     {
         return L"function";
     }
@@ -62,9 +63,9 @@ public :
 
 private :
     Macro*                  m_pMacro;
-    wstring                 m_stPath;
+    std::wstring            m_stPath;
 };
 }
 
 
-#endif /* !__MACRO_HXX__ */
+#endif /* !__MACROFILE_HXX__ */
diff --git a/scilab/modules/types/includes/typesdecl.hxx b/scilab/modules/types/includes/typesdecl.hxx
new file mode 100644 (file)
index 0000000..ca7b206
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ *  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
+ *
+ */
+
+namespace types
+{
+class MacroFile;
+class Macro;
+}
+
index 6ca847a..74f82e2 100644 (file)
@@ -13,6 +13,7 @@
 #include "types_gw.hxx"
 #include "function.hxx"
 #include "string.hxx"
+#include "macrofile.hxx"
 #include "inspector.hxx"
 #include "context.hxx"
 
@@ -41,7 +42,7 @@ Function::ReturnValue sci_inspectorGetFunctionList(typed_list &in, int _iRetCoun
     std::list<symbol::Symbol>::iterator it = FuncName->begin();
     for (int i = 0; it != FuncName->end() ; ++it, i++)
     {
-        Callable* pCall = pC->get(*it)->getAs<Callable>();
+        types::Callable* pCall = pC->get(*it)->getAs<types::Callable>();
         //Function name
         pOut->set(i, 0, pCall->getName().c_str());
         pOut->set(i, 1, pCall->getModule().c_str());
@@ -49,7 +50,7 @@ Function::ReturnValue sci_inspectorGetFunctionList(typed_list &in, int _iRetCoun
 
         if (pCall->isMacroFile())
         {
-            pOut->set(i, 3, pCall->getAs<MacroFile>()->getMacro() == NULL ? L"false" : L"true");
+            pOut->set(i, 3, pCall->getAs<types::MacroFile>()->getMacro() == NULL ? L"false" : L"true");
         }
         else
         {
index 9233567..4422f10 100644 (file)
  *
  */
 
+#include <sstream>
+#include "macrofile.hxx"
 #include "library.hxx"
+
 extern "C"
 {
 #include <wchar.h>
 #include "os_swprintf.h"
 #include "formatmode.h"
+#include "localization.h"
 }
 
 namespace types
index cfae104..e0ad43f 100644 (file)
@@ -17,7 +17,6 @@
 #include "list.hxx"
 #include "context.hxx"
 #include "symbol.hxx"
-#include "localization.h"
 #include "scilabWrite.hxx"
 #include "scilabexception.hxx"
 #include "configvariable.hxx"
@@ -25,6 +24,7 @@
 
 extern "C"
 {
+#include "localization.h"
 #include "Scierror.h"
 #include "sciprint.h"
 #include "MALLOC.h"
@@ -33,9 +33,13 @@ extern "C"
 
 namespace types
 {
-Macro::Macro(const std::wstring& _stName, std::list<symbol::Symbol> &_inputArgs, std::list<symbol::Symbol> &_outputArgs, ast::SeqExp &_body, const wstring& _stModule):
-    Callable(), m_inputArgs(&_inputArgs), m_outputArgs(&_outputArgs), m_body(&_body),
-    m_ArgInSymb(symbol::Symbol(L"nargin")), m_ArgOutSymb(symbol::Symbol(L"nargout"))
+Macro::Macro(const std::wstring& _stName, std::list<symbol::Variable*>& _inputArgs, std::list<symbol::Variable*>& _outputArgs, ast::SeqExp &_body, const std::wstring& _stModule):
+    Callable(),
+    m_inputArgs(&_inputArgs), m_outputArgs(&_outputArgs), m_body(&_body),
+    m_Nargin(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"nargin"))),
+    m_Nargout(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"nargout"))),
+    m_Varargin(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"varargin"))),
+    m_Varargout(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"varargout")))
 {
     setName(_stName);
     setModule(_stModule);
@@ -44,6 +48,7 @@ Macro::Macro(const std::wstring& _stName, std::list<symbol::Symbol> &_inputArgs,
     m_pDblArgIn->IncreaseRef(); //never delete
     m_pDblArgOut = new Double(1);
     m_pDblArgOut->IncreaseRef(); //never delete
+
 }
 
 Macro::~Macro()
@@ -93,14 +98,14 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
     optional_list::const_iterator it;
     for (it = opt.begin() ; it != opt.end() ; it++)
     {
-        pContext->put(symbol::Symbol(it->first), *it->second);
+        pContext->put(symbol::Symbol(it->first), it->second);
     }
     //check excepted and input/output parameters numbers
     // Scilab Macro can be called with less than prototyped arguments,
     // but not more execpts with varargin
 
     // varargin management
-    if (m_inputArgs->size() > 0 && m_inputArgs->back().name_get() == L"varargin")
+    if (m_inputArgs->size() > 0 && m_inputArgs->back()->name_get().name_get() == L"varargin")
     {
         int iVarPos = static_cast<int>(in.size());
         if (iVarPos > static_cast<int>(m_inputArgs->size()) - 1)
@@ -109,14 +114,14 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
         }
 
         //add all standard variable in function context but not varargin
-        std::list<symbol::Symbol>::const_iterator itName = m_inputArgs->begin();
+        std::list<symbol::Variable*>::iterator itName = m_inputArgs->begin();
         typed_list::const_iterator itValue = in.begin();
         while (iVarPos > 0)
         {
-            pContext->put((*itName), **itValue);
+            pContext->put(*itName, *itValue);
             iVarPos--;
-            itName++;
-            itValue++;
+            ++itName;
+            ++itValue;
         }
 
         //create varargin only if previous variable are assigned
@@ -129,7 +134,7 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
                 pL->append(*itValue);
                 itValue++;
             }
-            pContext->put(symbol::Symbol(L"varargin"), *pL);
+            pContext->put(m_Varargin, pL);
         }
     }
     else if (in.size() > m_inputArgs->size())
@@ -140,9 +145,9 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
         {
             ostr << _W("Arguments are:") << std::endl << std::endl;
             ostr << " ";
-            for (std::list<symbol::Symbol>::iterator it =  m_inputArgs->begin() ; it != m_inputArgs->end() ; ++it)
+            for (std::list<symbol::Variable*>::iterator it =  m_inputArgs->begin() ; it != m_inputArgs->end() ; ++it)
             {
-                ostr << (*it).name_get() << L"    ";
+                ostr << (*it)->name_get() << L"    ";
             }
             ostr << std::endl;
         }
@@ -157,7 +162,7 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
     else
     {
         //assign value to variable in the new context
-        std::list<symbol::Symbol>::const_iterator i;
+        std::list<symbol::Variable*>::iterator i;
         typed_list::const_iterator j;
 
         for (i = m_inputArgs->begin(), j = in.begin(); j != in.end (); ++j, ++i)
@@ -165,7 +170,7 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
             if (*j)
             {
                 //prevent assignation of NULL value
-                pContext->put((*i), **j);
+                pContext->put(*i, *j);
             }
         }
     }
@@ -176,11 +181,11 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
     // varargout is a list
     // varargout can containt more items than caller need
     // varargout must containt at leat caller needs
-    if (m_outputArgs->size() == 1 && m_outputArgs->back().name_get() == L"varargout")
+    if (m_outputArgs->size() == 1 && m_outputArgs->back()->name_get().name_get() == L"varargout")
     {
         bVarargout = true;
         List* pL = new List();
-        pContext->put(symbol::Symbol(L"varargout"), *pL);
+        pContext->put(m_Varargout, pL);
     }
 
     //common part with or without varargin/varargout
@@ -188,8 +193,8 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
     // Declare nargin & nargout in function context.
     m_pDblArgIn->set(0, static_cast<double>(in.size()));
     m_pDblArgOut->set(0, _iRetCount);
-    pContext->put(m_ArgInSymb, *m_pDblArgIn);
-    pContext->put(m_ArgOutSymb, *m_pDblArgOut);
+    pContext->put(m_Nargin, m_pDblArgIn);
+    pContext->put(m_Nargout, m_pDblArgOut);
 
     //save current prompt mode
     int oldVal = ConfigVariable::getPromptMode();
@@ -212,7 +217,7 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
         //varargout management
         if (bVarargout)
         {
-            InternalType* pOut = pContext->get(symbol::Symbol(L"varargout"));
+            InternalType* pOut = pContext->get(m_Varargout);
             if (pOut == NULL)
             {
                 Scierror(999, _("Invalid index.\n"));
@@ -241,7 +246,7 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
         else
         {
             //normal output management
-            std::list<symbol::Symbol>::const_iterator i;
+            std::list<symbol::Variable*>::iterator i;
             for (i = m_outputArgs->begin(); i != m_outputArgs->end() && _iRetCount; ++i, --_iRetCount)
             {
                 InternalType *pIT = pContext->get((*i));
@@ -252,7 +257,7 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
                 }
                 else
                 {
-                    char* pst = wide_string_to_UTF8((*i).name_get().c_str());
+                    char* pst = wide_string_to_UTF8((*i)->name_get().name_get().c_str());
                     Scierror(999, _("Undefined variable %s.\n"), pst);
                     FREE(pst);
                     return Callable::Error;
@@ -298,12 +303,12 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
     return RetVal;
 }
 
-std::list<symbol::Symbol>* Macro::inputs_get()
+std::list<symbol::Variable*>* Macro::inputs_get()
 {
     return m_inputArgs;
 }
 
-std::list<symbol::Symbol>* Macro::outputs_get()
+std::list<symbol::Variable*>* Macro::outputs_get()
 {
     return m_outputArgs;
 }
@@ -315,7 +320,7 @@ int Macro::getNbInputArgument(void)
 
 int Macro::getNbOutputArgument(void)
 {
-    if (m_outputArgs->size() == 1 && m_outputArgs->back().name_get() == L"varargout")
+    if (m_outputArgs->size() == 1 && m_outputArgs->back()->name_get().name_get() == L"varargout")
     {
         return -1;
     }
index fccb61c..08afc3f 100644 (file)
 #include "configvariable.hxx"
 #include "deserializervisitor.hxx"
 
-using namespace ast;
 namespace types
 {
-MacroFile::MacroFile(wstring _stName, wstring _stPath, wstring _stModule) : Callable(), m_stPath(_stPath), m_pMacro(NULL)
+MacroFile::MacroFile(std::wstring _stName, std::wstring _stPath, std::wstring _stModule) :
+    Callable(), m_stPath(_stPath), m_pMacro(NULL)
 {
     setName(_stName);
     setModule(_stModule);
@@ -94,14 +94,14 @@ bool MacroFile::parse(void)
         ast::Exp* tree = d->deserialize();
 
         //find FunctionDec
-        FunctionDec* pFD = NULL;
+        ast::FunctionDec* pFD = NULL;
 
         std::list<ast::Exp *>::iterator j;
         std::list<ast::Exp *>LExp = ((ast::SeqExp*)tree)->exps_get();
 
         for (j = LExp.begin() ; j != LExp.end() ; j++)
         {
-            pFD = dynamic_cast<FunctionDec*>(*j);
+            pFD = dynamic_cast<ast::FunctionDec*>(*j);
             if (pFD) // &&     pFD->name_get() == m_stName
             {
                 symbol::Context* pContext = symbol::Context::getInstance();
@@ -111,28 +111,25 @@ bool MacroFile::parse(void)
                     MacroFile* pMacro = pContext->getFunction(pFD->name_get())->getAs<MacroFile>();
                     if (pMacro->m_pMacro == NULL)
                     {
-                        std::list<Var *>::const_iterator       i;
+                        std::list<ast::Var *>::const_iterator i;
 
                         //get input parameters list
-                        std::list<symbol::Symbol> *pVarList = new std::list<symbol::Symbol>();
-                        ArrayListVar *pListVar = (ArrayListVar *)&pFD->args_get();
+                        std::list<symbol::Variable*> *pVarList = new std::list<symbol::Variable*>();
+                        ast::ArrayListVar *pListVar = (ast::ArrayListVar *)&pFD->args_get();
                         for (i = pListVar->vars_get().begin() ; i != pListVar->vars_get().end() ; i++)
                         {
-                            pVarList->push_back(((SimpleVar*)(*i))->name_get());
+                            pVarList->push_back(((ast::SimpleVar*)(*i))->stack_get());
                         }
 
                         //get output parameters list
-                        std::list<symbol::Symbol> *pRetList = new std::list<symbol::Symbol>();
-                        ArrayListVar *pListRet = (ArrayListVar *)&pFD->returns_get();
+                        std::list<symbol::Variable*> *pRetList = new std::list<symbol::Variable*>();
+                        ast::ArrayListVar *pListRet = (ast::ArrayListVar *)&pFD->returns_get();
                         for (i = pListRet->vars_get().begin() ; i != pListRet->vars_get().end() ; i++)
                         {
-                            pRetList->push_back(((SimpleVar*)(*i))->name_get());
+                            pRetList->push_back(((ast::SimpleVar*)(*i))->stack_get());
                         }
 
-                        //types::Macro macro(VarList, RetList, (SeqExp&)e.body_get());
-                        //types::Macro *pMacro = new types::Macro(m_stName, *pVarList, *pRetList, (SeqExp&)e.body_get());
-
-                        pMacro->m_pMacro = new Macro(m_wstName, *pVarList, *pRetList, (SeqExp&)pFD->body_get(), m_wstModule);
+                        pMacro->m_pMacro = new Macro(m_wstName, *pVarList, *pRetList, (ast::SeqExp&)pFD->body_get(), m_wstModule);
                         pMacro->setFirstLine(pFD->location_get().first_line);
                     }
                 }
index f97ebea..1c5424c 100644 (file)
@@ -276,6 +276,7 @@ lib /DEF:"$(ProjectDir)operations_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Plat
     <ClInclude Include="includes\tlist.hxx" />
     <ClInclude Include="includes\tostring_common.hxx" />
     <ClInclude Include="includes\types.hxx" />
+    <ClInclude Include="includes\typesdecl.hxx" />
     <ClInclude Include="includes\types_tools.hxx" />
     <ClInclude Include="includes\uint16.hxx" />
     <ClInclude Include="includes\uint32.hxx" />
index 88755d5..3d7131a 100644 (file)
     <ClInclude Include="includes\library.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="includes\typesdecl.hxx">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Library Include="..\..\bin\blasplus.lib" />