reforge symbol/context management 52/11652/8
Antoine ELIAS [Wed, 5 Jun 2013 11:13:43 +0000 (13:13 +0200)]
Thanks to Fabrice Le fassant for concept

Change-Id: I3df307fe2d30c3e65e8a3f73f5e85cd7d2926cb9

40 files changed:
scilab/modules/api_scilab/includes/api_scilab.h
scilab/modules/api_scilab/src/cpp/overload.cpp
scilab/modules/ast/includes/run_OpExp.hxx
scilab/modules/ast/includes/runvisitor.hxx
scilab/modules/core/sci_gateway/cpp/sci_exists.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/tests/unit_tests/global.tst
scilab/modules/io/sci_gateway/cpp/sci_load.cpp
scilab/modules/string/sci_gateway/cpp/sci_regexp.cpp
scilab/modules/string/sci_gateway/cpp/sci_stripblanks.cpp
scilab/modules/symbol/Makefile.am
scilab/modules/symbol/Makefile.in
scilab/modules/symbol/includes/context.hxx
scilab/modules/symbol/includes/heap.hxx [deleted file]
scilab/modules/symbol/includes/scope.hxx
scilab/modules/symbol/includes/stack.hxx [deleted file]
scilab/modules/symbol/includes/table.hxx [deleted file]
scilab/modules/symbol/includes/variables.hxx [new file with mode: 0644]
scilab/modules/symbol/src/cpp/_context.hh [deleted file]
scilab/modules/symbol/src/cpp/_heap.hh [deleted file]
scilab/modules/symbol/src/cpp/_scope.hh [deleted file]
scilab/modules/symbol/src/cpp/_stack.hh [deleted file]
scilab/modules/symbol/src/cpp/_table.hh [deleted file]
scilab/modules/symbol/src/cpp/context.cpp
scilab/modules/symbol/src/cpp/scope.cpp [new file with mode: 0644]
scilab/modules/symbol/src/cpp/table.cpp [deleted file]
scilab/modules/symbol/src/cpp/test-context.cpp [deleted file]
scilab/modules/symbol/src/cpp/test-heap.cpp [deleted file]
scilab/modules/symbol/src/cpp/test-scope.cpp [deleted file]
scilab/modules/symbol/src/cpp/test-stack.cpp [deleted file]
scilab/modules/symbol/src/cpp/test-symbol.cpp [deleted file]
scilab/modules/symbol/src/cpp/variables.cpp [new file with mode: 0644]
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

index fbc5027..8ec90c7 100644 (file)
@@ -53,6 +53,7 @@
 #include "core_math.h"
 #include "sci_types.h"
 #include "BOOL.h"
+#include "MALLOC.h"
 
 /*Constants*/
 #define ROW_LETTER             'r'
index dcc882e..499141c 100644 (file)
@@ -15,6 +15,7 @@ extern "C"
 #include "stdarg.h"
 #include "localization.h"
 #include "os_swprintf.h"
+#include "MALLOC.h"
 }
 
 #include "callable.hxx"
index 217d05e..e758973 100644 (file)
@@ -232,6 +232,8 @@ void visitprivate(const LogicalOpExp &e)
             throw ScilabError(os.str(), 999, e.right_get().location_get());
         }
 
+        result_set(NULL);
+
         if (pITL->getType() == GenericType::RealImplicitList)
         {
             ImplicitList* pIL = pITL->getAs<ImplicitList>();
index 33b7e36..59ce5df 100644 (file)
@@ -44,7 +44,7 @@ extern "C" {
 #include "os_swprintf.h"
 #include "more.h"
 #include "sciprint.h"
-    //#include "HandleManagement.h"
+#include "MALLOC.h"
 }
 
 #include "timer.hxx"
index 8c1259f..a81227e 100644 (file)
@@ -14,6 +14,7 @@
 #include "function.hxx"
 #include "context.hxx"
 #include "string.hxx"
+#include "bool.hxx"
 
 extern "C"
 {
index 2b8dc54..c19cc3b 100644 (file)
@@ -61,23 +61,32 @@ types::Function::ReturnValue sci_global(types::typed_list &in, int _iRetCount, t
             if (pCtx->isGlobalExists(pstVar) == false)
             {
                 InternalType* pIT = pCtx->get(pstVar);
+                //create global variable with default value []
                 if (pIT)
                 {
-                    //variable have already a value in current local scope
-
-                    //set global at local value
-                    pCtx->setGlobalValue(pstVar, *pIT);
-                    pCtx->remove(pstVar);
+                    //protect var againt setGlobalVisible
+                    pIT->IncreaseRef();
                 }
-                else
+
+                //create a empty global variable => []
+                pCtx->createEmptyGlobalValue(pstVar);
+
+                //set visible in current global scope
+                pCtx->setGlobalVisible(pstVar);
+
+                if (pIT)
                 {
-                    //create global variable with default value []
-                    pCtx->createEmptyGlobalValue(pstVar);
+                    //assign old local value
+                    pCtx->put(pstVar, *pIT);
+                    //unprotect var againt setGlobalVisible
+                    pIT->DecreaseRef();
                 }
             }
-
-            //set visible in current global scope
-            pCtx->setGlobalVisible(pstVar);
+            else
+            {
+                //set visible in current global scope
+                pCtx->setGlobalVisible(pstVar);
+            }
         }
     }
     return types::Function::OK;
index 6bfefdb..c4d15cb 100644 (file)
@@ -15,6 +15,7 @@
 #include "callable.hxx"
 #include "context.hxx"
 #include "string.hxx"
+#include "bool.hxx"
 
 extern "C"
 {
@@ -51,11 +52,11 @@ Function::ReturnValue sci_isglobal(types::typed_list &in, int _iRetCount, types:
 
         if (symbol::Context::getInstance()->isGlobalExists(symbol::Symbol(pS->get(0))))
         {
-            out.push_back(new Bool(1));
+            out.push_back(new types::Bool(1));
         }
         else
         {
-            out.push_back(new Bool(0));
+            out.push_back(new types::Bool(0));
         }
     }
     return Function::OK;
index 66086f4..f73c439 100644 (file)
@@ -23,7 +23,7 @@ Function::ReturnValue sci_who(typed_list& in, int iRetCount, typed_list& out)
     std::wstringstream wstream;
     wstream << *(symbol::Context::getInstance()) << std::endl;
 
-    scilabWriteW(wstream.str().c_str());
+    scilabForcedWriteW(wstream.str().c_str());
 
     return Function::OK;
 }
index 0aafe32..b2caf79 100644 (file)
@@ -27,7 +27,7 @@ try
 catch
  [str,n]=lasterror(%t);
 end
-if n <>228 then pause,end
+if n == 0 then pause,end
 
 global a b c 
 a=1;b=2;c=3;
@@ -38,7 +38,7 @@ try
 catch
  [str,n]=lasterror(%t);
 end
-if n <>228 then pause,end
+if n == 0 then pause,end
 
 if a<>1|c<>3 then pause,end
 
@@ -49,7 +49,7 @@ try
 catch
  [str,n]=lasterror(%t);
 end
-if n <>228 then pause,end
+if n == 0 then pause,end
 if a<>1 then pause,end
 
 clearglobal a
@@ -59,7 +59,7 @@ try
 catch
  [str,n]=lasterror(%t);
 end
-if n <>228 then pause,end
+if n == 0 then pause,end
 
 clearglobal()
 
@@ -106,15 +106,15 @@ if or(a<>(1:5)) then pause,end
 deff('y=foo()','global a;y=a(1:2:$)')
 if or(foo()<>(1:2:5)) then pause,end
 
-if ~isglobal(a) then pause,end
+if ~isglobal("a") then pause,end
 clearglobal a
-a=1
-if isglobal(a) then pause,end
-if isglobal(1) then pause,end
+a=1;
+if isglobal("a") then pause,end
+if isglobal("1") then pause,end
 
 clearglobal()
 
-gsz=gstacksize();
+gsz=int(rand() * 1000);
 
 global a b c
 n=int(sqrt(gsz(1)))-3;
index d5475d3..99bb780 100644 (file)
@@ -27,6 +27,7 @@
 
 extern "C"
 {
+#include "MALLOC.h"
 #include "os_strdup.h"
 #ifndef _MSC_VER
 #include "stricmp.h"
index db2f6c3..f679887 100644 (file)
@@ -21,6 +21,7 @@ using regular expression .                                      */
 
 extern "C"
 {
+#include "MALLOC.h"
 #include "localization.h"
 #include "pcre.h"
 #include "pcre_private.h"
index 2dbe877..66d1d31 100644 (file)
@@ -14,6 +14,7 @@
 #include "function.hxx"
 #include "context.hxx"
 #include "types.hxx"
+#include "bool.hxx"
 #include "stripblanks.hxx"
 /*--------------------------------------------------------------------------*/
 extern "C"
index e7ea2a9..e7de995 100644 (file)
 ##
 ##
 
-SYMBOL_CXX_SOURCES             = src/cpp/symbol.cpp \
-                               src/cpp/context.cpp \
-                               src/cpp/table.cpp
+SYMBOL_CXX_SOURCES = \
+    src/cpp/symbol.cpp \
+    src/cpp/context.cpp \
+    src/cpp/scope.cpp \
+    src/cpp/variables.cpp
+    
 
 pkglib_LTLIBRARIES             = libscisymbol.la
 
@@ -40,40 +43,4 @@ libscisymbol_la_include_HEADERS = includes/symbol.hxx
 # For the code check (splint)
 INCLUDE_FLAGS = $(libscisymbol_la_CPPFLAGS)
 
-####################
-## Automated test ##
-####################
-check_INCLUDES                 = -Iincludes/ \
-                       -I $(top_builddir)/modules/types/includes \
-                       -Isrc/cpp
-
-check_LDADD            = $(top_builddir)/modules/symbol/libscisymbol.la \
-                       $(top_builddir)/modules/types/libsciTypes.la
-
-check_PROGRAMS                 =       testSymbol \
-                               testScope \
-                               testStack \
-                               testHeap
-
-TESTS                  =       testSymbol \
-                               testScope \
-                               testStack \
-                               testHeap
-
-testSymbol_SOURCES     = src/cpp/test-symbol.cpp
-testSymbol_CXXFLAGS    = $(check_INCLUDES)
-testSymbol_LDADD       = $(check_LDADD)
-
-testScope_SOURCES      = src/cpp/test-scope.cpp
-testScope_CXXFLAGS     = $(check_INCLUDES)
-testScope_LDADD                = $(check_LDADD)
-
-testStack_SOURCES      = src/cpp/test-stack.cpp
-testStack_CXXFLAGS     = $(check_INCLUDES)
-testStack_LDADD                = $(check_LDADD)
-
-testHeap_SOURCES       = src/cpp/test-heap.cpp
-testHeap_CXXFLAGS      = $(check_INCLUDES)
-testHeap_LDADD         = $(check_LDADD)
-
 include $(top_srcdir)/Makefile.incl.am
index 1b98910..b749781 100644 (file)
@@ -68,10 +68,6 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-check_PROGRAMS = testSymbol$(EXEEXT) testScope$(EXEEXT) \
-       testStack$(EXEEXT) testHeap$(EXEEXT)
-TESTS = testSymbol$(EXEEXT) testScope$(EXEEXT) testStack$(EXEEXT) \
-       testHeap$(EXEEXT)
 DIST_COMMON = $(libscisymbol_la_include_HEADERS) $(srcdir)/Makefile.am \
        $(srcdir)/Makefile.in $(top_srcdir)/Makefile.incl.am
 @NEED_JAVA_TRUE@am__append_1 = java
@@ -132,33 +128,9 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)" \
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
 libscisymbol_la_DEPENDENCIES =
 am__objects_1 = libscisymbol_la-symbol.lo libscisymbol_la-context.lo \
-       libscisymbol_la-table.lo
+       libscisymbol_la-scope.lo libscisymbol_la-variables.lo
 am_libscisymbol_la_OBJECTS = $(am__objects_1)
 libscisymbol_la_OBJECTS = $(am_libscisymbol_la_OBJECTS)
-am_testHeap_OBJECTS = testHeap-test-heap.$(OBJEXT)
-testHeap_OBJECTS = $(am_testHeap_OBJECTS)
-testHeap_DEPENDENCIES = $(check_LDADD)
-testHeap_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(testHeap_CXXFLAGS) \
-       $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-am_testScope_OBJECTS = testScope-test-scope.$(OBJEXT)
-testScope_OBJECTS = $(am_testScope_OBJECTS)
-testScope_DEPENDENCIES = $(check_LDADD)
-testScope_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(testScope_CXXFLAGS) \
-       $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-am_testStack_OBJECTS = testStack-test-stack.$(OBJEXT)
-testStack_OBJECTS = $(am_testStack_OBJECTS)
-testStack_DEPENDENCIES = $(check_LDADD)
-testStack_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(testStack_CXXFLAGS) \
-       $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-am_testSymbol_OBJECTS = testSymbol-test-symbol.$(OBJEXT)
-testSymbol_OBJECTS = $(am_testSymbol_OBJECTS)
-testSymbol_DEPENDENCIES = $(check_LDADD)
-testSymbol_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(testSymbol_CXXFLAGS) \
-       $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/modules/core/includes
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
 am__depfiles_maybe = depfiles
@@ -172,12 +144,8 @@ CXXLD = $(CXX)
 CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
        --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
        $(LDFLAGS) -o $@
-SOURCES = $(libscisymbol_la_SOURCES) $(testHeap_SOURCES) \
-       $(testScope_SOURCES) $(testStack_SOURCES) \
-       $(testSymbol_SOURCES)
-DIST_SOURCES = $(libscisymbol_la_SOURCES) $(testHeap_SOURCES) \
-       $(testScope_SOURCES) $(testStack_SOURCES) \
-       $(testSymbol_SOURCES)
+SOURCES = $(libscisymbol_la_SOURCES)
+DIST_SOURCES = $(libscisymbol_la_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -186,8 +154,6 @@ am__can_run_installinfo = \
 HEADERS = $(libscisymbol_la_include_HEADERS)
 ETAGS = etags
 CTAGS = ctags
-am__tty_colors = \
-red=; grn=; lgn=; blu=; std=
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ALL_LINGUAS = @ALL_LINGUAS@
@@ -454,9 +420,11 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 yacc_present = @yacc_present@
-SYMBOL_CXX_SOURCES = src/cpp/symbol.cpp \
-                               src/cpp/context.cpp \
-                               src/cpp/table.cpp
+SYMBOL_CXX_SOURCES = \
+    src/cpp/symbol.cpp \
+    src/cpp/context.cpp \
+    src/cpp/scope.cpp \
+    src/cpp/variables.cpp
 
 pkglib_LTLIBRARIES = libscisymbol.la
 libscisymbol_la_SOURCES = $(SYMBOL_CXX_SOURCES)
@@ -479,28 +447,6 @@ libscisymbol_la_include_HEADERS = includes/symbol.hxx
 # For the code check (splint)
 INCLUDE_FLAGS = $(libscisymbol_la_CPPFLAGS)
 
-####################
-####################
-check_INCLUDES = -Iincludes/ \
-                       -I $(top_builddir)/modules/types/includes \
-                       -Isrc/cpp
-
-check_LDADD = $(top_builddir)/modules/symbol/libscisymbol.la \
-                       $(top_builddir)/modules/types/libsciTypes.la
-
-testSymbol_SOURCES = src/cpp/test-symbol.cpp
-testSymbol_CXXFLAGS = $(check_INCLUDES)
-testSymbol_LDADD = $(check_LDADD)
-testScope_SOURCES = src/cpp/test-scope.cpp
-testScope_CXXFLAGS = $(check_INCLUDES)
-testScope_LDADD = $(check_LDADD)
-testStack_SOURCES = src/cpp/test-stack.cpp
-testStack_CXXFLAGS = $(check_INCLUDES)
-testStack_LDADD = $(check_LDADD)
-testHeap_SOURCES = src/cpp/test-heap.cpp
-testHeap_CXXFLAGS = $(check_INCLUDES)
-testHeap_LDADD = $(check_LDADD)
-
 # Where all the Scilab stuff is installed (macros, help, ...)
 mydatadir = $(pkgdatadir)/modules/$(modulename)
 
@@ -643,27 +589,6 @@ clean-pkglibLTLIBRARIES:
 libscisymbol.la: $(libscisymbol_la_OBJECTS) $(libscisymbol_la_DEPENDENCIES) $(EXTRA_libscisymbol_la_DEPENDENCIES) 
        $(CXXLINK) -rpath $(pkglibdir) $(libscisymbol_la_OBJECTS) $(libscisymbol_la_LIBADD) $(LIBS)
 
-clean-checkPROGRAMS:
-       @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
-       echo " rm -f" $$list; \
-       rm -f $$list || exit $$?; \
-       test -n "$(EXEEXT)" || exit 0; \
-       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
-       echo " rm -f" $$list; \
-       rm -f $$list
-testHeap$(EXEEXT): $(testHeap_OBJECTS) $(testHeap_DEPENDENCIES) $(EXTRA_testHeap_DEPENDENCIES) 
-       @rm -f testHeap$(EXEEXT)
-       $(testHeap_LINK) $(testHeap_OBJECTS) $(testHeap_LDADD) $(LIBS)
-testScope$(EXEEXT): $(testScope_OBJECTS) $(testScope_DEPENDENCIES) $(EXTRA_testScope_DEPENDENCIES) 
-       @rm -f testScope$(EXEEXT)
-       $(testScope_LINK) $(testScope_OBJECTS) $(testScope_LDADD) $(LIBS)
-testStack$(EXEEXT): $(testStack_OBJECTS) $(testStack_DEPENDENCIES) $(EXTRA_testStack_DEPENDENCIES) 
-       @rm -f testStack$(EXEEXT)
-       $(testStack_LINK) $(testStack_OBJECTS) $(testStack_LDADD) $(LIBS)
-testSymbol$(EXEEXT): $(testSymbol_OBJECTS) $(testSymbol_DEPENDENCIES) $(EXTRA_testSymbol_DEPENDENCIES) 
-       @rm -f testSymbol$(EXEEXT)
-       $(testSymbol_LINK) $(testSymbol_OBJECTS) $(testSymbol_LDADD) $(LIBS)
-
 mostlyclean-compile:
        -rm -f *.$(OBJEXT)
 
@@ -671,12 +596,9 @@ distclean-compile:
        -rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisymbol_la-context.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisymbol_la-scope.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisymbol_la-symbol.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisymbol_la-table.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testHeap-test-heap.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testScope-test-scope.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testStack-test-stack.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testSymbol-test-symbol.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisymbol_la-variables.Plo@am__quote@
 
 .cpp.o:
 @am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -713,68 +635,19 @@ libscisymbol_la-context.lo: src/cpp/context.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscisymbol_la-context.lo `test -f 'src/cpp/context.cpp' || echo '$(srcdir)/'`src/cpp/context.cpp
 
-libscisymbol_la-table.lo: src/cpp/table.cpp
-@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscisymbol_la-table.lo -MD -MP -MF $(DEPDIR)/libscisymbol_la-table.Tpo -c -o libscisymbol_la-table.lo `test -f 'src/cpp/table.cpp' || echo '$(srcdir)/'`src/cpp/table.cpp
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscisymbol_la-table.Tpo $(DEPDIR)/libscisymbol_la-table.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/table.cpp' object='libscisymbol_la-table.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscisymbol_la-table.lo `test -f 'src/cpp/table.cpp' || echo '$(srcdir)/'`src/cpp/table.cpp
-
-testHeap-test-heap.o: src/cpp/test-heap.cpp
-@am__fastdepCXX_TRUE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testHeap_CXXFLAGS) $(CXXFLAGS) -MT testHeap-test-heap.o -MD -MP -MF $(DEPDIR)/testHeap-test-heap.Tpo -c -o testHeap-test-heap.o `test -f 'src/cpp/test-heap.cpp' || echo '$(srcdir)/'`src/cpp/test-heap.cpp
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/testHeap-test-heap.Tpo $(DEPDIR)/testHeap-test-heap.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/test-heap.cpp' object='testHeap-test-heap.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testHeap_CXXFLAGS) $(CXXFLAGS) -c -o testHeap-test-heap.o `test -f 'src/cpp/test-heap.cpp' || echo '$(srcdir)/'`src/cpp/test-heap.cpp
-
-testHeap-test-heap.obj: src/cpp/test-heap.cpp
-@am__fastdepCXX_TRUE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testHeap_CXXFLAGS) $(CXXFLAGS) -MT testHeap-test-heap.obj -MD -MP -MF $(DEPDIR)/testHeap-test-heap.Tpo -c -o testHeap-test-heap.obj `if test -f 'src/cpp/test-heap.cpp'; then $(CYGPATH_W) 'src/cpp/test-heap.cpp'; else $(CYGPATH_W) '$(srcdir)/src/cpp/test-heap.cpp'; fi`
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/testHeap-test-heap.Tpo $(DEPDIR)/testHeap-test-heap.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/test-heap.cpp' object='testHeap-test-heap.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testHeap_CXXFLAGS) $(CXXFLAGS) -c -o testHeap-test-heap.obj `if test -f 'src/cpp/test-heap.cpp'; then $(CYGPATH_W) 'src/cpp/test-heap.cpp'; else $(CYGPATH_W) '$(srcdir)/src/cpp/test-heap.cpp'; fi`
-
-testScope-test-scope.o: src/cpp/test-scope.cpp
-@am__fastdepCXX_TRUE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testScope_CXXFLAGS) $(CXXFLAGS) -MT testScope-test-scope.o -MD -MP -MF $(DEPDIR)/testScope-test-scope.Tpo -c -o testScope-test-scope.o `test -f 'src/cpp/test-scope.cpp' || echo '$(srcdir)/'`src/cpp/test-scope.cpp
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/testScope-test-scope.Tpo $(DEPDIR)/testScope-test-scope.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/test-scope.cpp' object='testScope-test-scope.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testScope_CXXFLAGS) $(CXXFLAGS) -c -o testScope-test-scope.o `test -f 'src/cpp/test-scope.cpp' || echo '$(srcdir)/'`src/cpp/test-scope.cpp
-
-testScope-test-scope.obj: src/cpp/test-scope.cpp
-@am__fastdepCXX_TRUE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testScope_CXXFLAGS) $(CXXFLAGS) -MT testScope-test-scope.obj -MD -MP -MF $(DEPDIR)/testScope-test-scope.Tpo -c -o testScope-test-scope.obj `if test -f 'src/cpp/test-scope.cpp'; then $(CYGPATH_W) 'src/cpp/test-scope.cpp'; else $(CYGPATH_W) '$(srcdir)/src/cpp/test-scope.cpp'; fi`
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/testScope-test-scope.Tpo $(DEPDIR)/testScope-test-scope.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/test-scope.cpp' object='testScope-test-scope.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testScope_CXXFLAGS) $(CXXFLAGS) -c -o testScope-test-scope.obj `if test -f 'src/cpp/test-scope.cpp'; then $(CYGPATH_W) 'src/cpp/test-scope.cpp'; else $(CYGPATH_W) '$(srcdir)/src/cpp/test-scope.cpp'; fi`
-
-testStack-test-stack.o: src/cpp/test-stack.cpp
-@am__fastdepCXX_TRUE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testStack_CXXFLAGS) $(CXXFLAGS) -MT testStack-test-stack.o -MD -MP -MF $(DEPDIR)/testStack-test-stack.Tpo -c -o testStack-test-stack.o `test -f 'src/cpp/test-stack.cpp' || echo '$(srcdir)/'`src/cpp/test-stack.cpp
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/testStack-test-stack.Tpo $(DEPDIR)/testStack-test-stack.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/test-stack.cpp' object='testStack-test-stack.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testStack_CXXFLAGS) $(CXXFLAGS) -c -o testStack-test-stack.o `test -f 'src/cpp/test-stack.cpp' || echo '$(srcdir)/'`src/cpp/test-stack.cpp
-
-testStack-test-stack.obj: src/cpp/test-stack.cpp
-@am__fastdepCXX_TRUE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testStack_CXXFLAGS) $(CXXFLAGS) -MT testStack-test-stack.obj -MD -MP -MF $(DEPDIR)/testStack-test-stack.Tpo -c -o testStack-test-stack.obj `if test -f 'src/cpp/test-stack.cpp'; then $(CYGPATH_W) 'src/cpp/test-stack.cpp'; else $(CYGPATH_W) '$(srcdir)/src/cpp/test-stack.cpp'; fi`
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/testStack-test-stack.Tpo $(DEPDIR)/testStack-test-stack.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/test-stack.cpp' object='testStack-test-stack.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testStack_CXXFLAGS) $(CXXFLAGS) -c -o testStack-test-stack.obj `if test -f 'src/cpp/test-stack.cpp'; then $(CYGPATH_W) 'src/cpp/test-stack.cpp'; else $(CYGPATH_W) '$(srcdir)/src/cpp/test-stack.cpp'; fi`
-
-testSymbol-test-symbol.o: src/cpp/test-symbol.cpp
-@am__fastdepCXX_TRUE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testSymbol_CXXFLAGS) $(CXXFLAGS) -MT testSymbol-test-symbol.o -MD -MP -MF $(DEPDIR)/testSymbol-test-symbol.Tpo -c -o testSymbol-test-symbol.o `test -f 'src/cpp/test-symbol.cpp' || echo '$(srcdir)/'`src/cpp/test-symbol.cpp
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/testSymbol-test-symbol.Tpo $(DEPDIR)/testSymbol-test-symbol.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/test-symbol.cpp' object='testSymbol-test-symbol.o' libtool=no @AMDEPBACKSLASH@
+libscisymbol_la-scope.lo: src/cpp/scope.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscisymbol_la-scope.lo -MD -MP -MF $(DEPDIR)/libscisymbol_la-scope.Tpo -c -o libscisymbol_la-scope.lo `test -f 'src/cpp/scope.cpp' || echo '$(srcdir)/'`src/cpp/scope.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscisymbol_la-scope.Tpo $(DEPDIR)/libscisymbol_la-scope.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/scope.cpp' object='libscisymbol_la-scope.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testSymbol_CXXFLAGS) $(CXXFLAGS) -c -o testSymbol-test-symbol.o `test -f 'src/cpp/test-symbol.cpp' || echo '$(srcdir)/'`src/cpp/test-symbol.cpp
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscisymbol_la-scope.lo `test -f 'src/cpp/scope.cpp' || echo '$(srcdir)/'`src/cpp/scope.cpp
 
-testSymbol-test-symbol.obj: src/cpp/test-symbol.cpp
-@am__fastdepCXX_TRUE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testSymbol_CXXFLAGS) $(CXXFLAGS) -MT testSymbol-test-symbol.obj -MD -MP -MF $(DEPDIR)/testSymbol-test-symbol.Tpo -c -o testSymbol-test-symbol.obj `if test -f 'src/cpp/test-symbol.cpp'; then $(CYGPATH_W) 'src/cpp/test-symbol.cpp'; else $(CYGPATH_W) '$(srcdir)/src/cpp/test-symbol.cpp'; fi`
-@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/testSymbol-test-symbol.Tpo $(DEPDIR)/testSymbol-test-symbol.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/test-symbol.cpp' object='testSymbol-test-symbol.obj' libtool=no @AMDEPBACKSLASH@
+libscisymbol_la-variables.lo: src/cpp/variables.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscisymbol_la-variables.lo -MD -MP -MF $(DEPDIR)/libscisymbol_la-variables.Tpo -c -o libscisymbol_la-variables.lo `test -f 'src/cpp/variables.cpp' || echo '$(srcdir)/'`src/cpp/variables.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscisymbol_la-variables.Tpo $(DEPDIR)/libscisymbol_la-variables.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/variables.cpp' object='libscisymbol_la-variables.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testSymbol_CXXFLAGS) $(CXXFLAGS) -c -o testSymbol-test-symbol.obj `if test -f 'src/cpp/test-symbol.cpp'; then $(CYGPATH_W) 'src/cpp/test-symbol.cpp'; else $(CYGPATH_W) '$(srcdir)/src/cpp/test-symbol.cpp'; fi`
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisymbol_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscisymbol_la-variables.lo `test -f 'src/cpp/variables.cpp' || echo '$(srcdir)/'`src/cpp/variables.cpp
 
 mostlyclean-libtool:
        -rm -f *.lo
@@ -855,99 +728,6 @@ GTAGS:
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-check-TESTS: $(TESTS)
-       @failed=0; all=0; xfail=0; xpass=0; skip=0; \
-       srcdir=$(srcdir); export srcdir; \
-       list=' $(TESTS) '; \
-       $(am__tty_colors); \
-       if test -n "$$list"; then \
-         for tst in $$list; do \
-           if test -f ./$$tst; then dir=./; \
-           elif test -f $$tst; then dir=; \
-           else dir="$(srcdir)/"; fi; \
-           if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
-             all=`expr $$all + 1`; \
-             case " $(XFAIL_TESTS) " in \
-             *[\ \     ]$$tst[\ \      ]*) \
-               xpass=`expr $$xpass + 1`; \
-               failed=`expr $$failed + 1`; \
-               col=$$red; res=XPASS; \
-             ;; \
-             *) \
-               col=$$grn; res=PASS; \
-             ;; \
-             esac; \
-           elif test $$? -ne 77; then \
-             all=`expr $$all + 1`; \
-             case " $(XFAIL_TESTS) " in \
-             *[\ \     ]$$tst[\ \      ]*) \
-               xfail=`expr $$xfail + 1`; \
-               col=$$lgn; res=XFAIL; \
-             ;; \
-             *) \
-               failed=`expr $$failed + 1`; \
-               col=$$red; res=FAIL; \
-             ;; \
-             esac; \
-           else \
-             skip=`expr $$skip + 1`; \
-             col=$$blu; res=SKIP; \
-           fi; \
-           echo "$${col}$$res$${std}: $$tst"; \
-         done; \
-         if test "$$all" -eq 1; then \
-           tests="test"; \
-           All=""; \
-         else \
-           tests="tests"; \
-           All="All "; \
-         fi; \
-         if test "$$failed" -eq 0; then \
-           if test "$$xfail" -eq 0; then \
-             banner="$$All$$all $$tests passed"; \
-           else \
-             if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
-             banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
-           fi; \
-         else \
-           if test "$$xpass" -eq 0; then \
-             banner="$$failed of $$all $$tests failed"; \
-           else \
-             if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
-             banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
-           fi; \
-         fi; \
-         dashes="$$banner"; \
-         skipped=""; \
-         if test "$$skip" -ne 0; then \
-           if test "$$skip" -eq 1; then \
-             skipped="($$skip test was not run)"; \
-           else \
-             skipped="($$skip tests were not run)"; \
-           fi; \
-           test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-             dashes="$$skipped"; \
-         fi; \
-         report=""; \
-         if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-           report="Please report to $(PACKAGE_BUGREPORT)"; \
-           test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-             dashes="$$report"; \
-         fi; \
-         dashes=`echo "$$dashes" | sed s/./=/g`; \
-         if test "$$failed" -eq 0; then \
-           col="$$grn"; \
-         else \
-           col="$$red"; \
-         fi; \
-         echo "$${col}$$dashes$${std}"; \
-         echo "$${col}$$banner$${std}"; \
-         test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
-         test -z "$$report" || echo "$${col}$$report$${std}"; \
-         echo "$${col}$$dashes$${std}"; \
-         test "$$failed" -eq 0; \
-       else :; fi
-
 distdir: $(DISTFILES)
        @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
        topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -979,8 +759,7 @@ distdir: $(DISTFILES)
          fi; \
        done
 check-am: all-am
-       $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-       $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local
+       $(MAKE) $(AM_MAKEFLAGS) check-local
 check: check-am
 all-am: Makefile $(LTLIBRARIES) $(HEADERS) all-local
 installdirs:
@@ -1019,7 +798,7 @@ maintainer-clean-generic:
        @echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \
+clean-am: clean-generic clean-libtool clean-local \
        clean-pkglibLTLIBRARIES mostlyclean-am
 
 distclean: distclean-am
@@ -1092,23 +871,22 @@ uninstall-am: uninstall-libscisymbol_la_includeHEADERS \
 
 .MAKE: check-am install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \
-       check-local clean clean-checkPROGRAMS clean-generic \
-       clean-libtool clean-local clean-pkglibLTLIBRARIES ctags \
-       distclean distclean-compile distclean-generic \
-       distclean-libtool distclean-local distclean-tags distdir dvi \
-       dvi-am html html-am info info-am install install-am \
-       install-data install-data-am install-data-local install-dvi \
-       install-dvi-am install-exec install-exec-am install-html \
-       install-html-am install-html-local install-info \
-       install-info-am install-libscisymbol_la_includeHEADERS \
-       install-man install-pdf install-pdf-am \
-       install-pkglibLTLIBRARIES install-ps install-ps-am \
-       install-strip installcheck installcheck-am installdirs \
-       maintainer-clean maintainer-clean-generic mostlyclean \
-       mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-       pdf pdf-am ps ps-am tags uninstall uninstall-am \
-       uninstall-libscisymbol_la_includeHEADERS \
+.PHONY: CTAGS GTAGS all all-am all-local check check-am check-local \
+       clean clean-generic clean-libtool clean-local \
+       clean-pkglibLTLIBRARIES ctags distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-local \
+       distclean-tags distdir dvi dvi-am html html-am info info-am \
+       install install-am install-data install-data-am \
+       install-data-local install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am \
+       install-html-local install-info install-info-am \
+       install-libscisymbol_la_includeHEADERS install-man install-pdf \
+       install-pdf-am install-pkglibLTLIBRARIES install-ps \
+       install-ps-am install-strip installcheck installcheck-am \
+       installdirs maintainer-clean maintainer-clean-generic \
+       mostlyclean mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+       uninstall-am uninstall-libscisymbol_la_includeHEADERS \
        uninstall-pkglibLTLIBRARIES
 
 
index 81f6ba3..b3e6539 100644 (file)
 
 #ifndef __CONTEXT_HXX__
 #define __CONTEXT_HXX__
-#include "stack.hxx"
-#include "heap.hxx"
+//#include "stack.hxx"
+//#include "heap.hxx"
+#include "scope.hxx"
+#include "variables.hxx"
 #include "internal.hxx"
 #include "function.hxx"
 #include "macro.hxx"
@@ -29,38 +31,37 @@ namespace symbol
 {
 
 /** \brief Define class Context.
- */
+*/
 class EXTERN_SYMBOL Context
 {
 public :
-    Context();
     static Context* getInstance(void);
 
     /** Open a context scope i.e
-     ** open the heap table one
-     ** and the env table too. */
+    ** open the heap table one
+    ** and the env table too. */
     void scope_begin();
 
     /** Close a context scope i.e
-     ** close the heap table one
-     ** and the env table too. */
+    ** close the heap table one
+    ** and the env table too. */
     void scope_end();
 
     /** 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;
+    ** most recent insertion. Otherwise return the empty pointer. */
+    types::InternalType* get(const symbol::Symbol& key) const;
 
     /** 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;
+    ** Otherwise return the empty pointer. */
+    types::InternalType* getCurrentLevel(const symbol::Symbol& key) const;
 
     /** 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;
+    ** most recent insertion DESPITE the current/last one. Otherwise return the empty pointer. */
+    types::InternalType* getAllButCurrentLevel(const symbol::Symbol& key) const;
 
     /** 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;
+    ** most recent insertion. Otherwise return the empty pointer. */
+    types::InternalType* getFunction(const symbol::Symbol& key) const;
 
     /*return function list in the module _stModuleName*/
     std::list<symbol::Symbol>& getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd = true);
@@ -95,9 +96,9 @@ public :
     void print();
 
     /*add symbol and value in the stack*/
-    bool put(const symbol::Symbol& key, types::InternalType &type);
+    bool put(const symbol::Symbol& key, types::InternalType& type);
     /*add symbol and value in the previous scope*/
-    bool putInPreviousScope(const symbol::Symbol& key, types::InternalType &type);
+    bool putInPreviousScope(const symbol::Symbol& key, types::InternalType& type);
 
     /* remove symbol/value association */
     bool remove(const symbol::Symbol& key);
@@ -109,13 +110,13 @@ public :
     {
         ostr << L"  Environment Variables:" << std::endl;
         ostr << L"==========================" << std::endl;
-        ostr << EnvVarTable;
+        ostr << *m_scopes;
     };
 private :
-    Stack PrivateVarTable;
-    Heap HeapVarTable;
-    Stack EnvVarTable;
 
+    Scopes* m_scopes;
+
+    Context();
     static Context* me;
 };
 
diff --git a/scilab/modules/symbol/includes/heap.hxx b/scilab/modules/symbol/includes/heap.hxx
deleted file mode 100644 (file)
index 0dd8ffa..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- *  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 SYMBOL_HEAP_HH
-#define SYMBOL_HEAP_HH
-
-#include <iostream>
-#include <list>
-#include <map>
-#include "symbol.hxx"
-#include "table.hxx"
-
-#include "bool.hxx"
-#include "double.hxx"
-
-namespace symbol
-{
-
-/*-----------------------------------------------------------------------.
-| This implements heaps for storing definitions of variables and         |
-| functions as a list of dictionnaries.  Each time a scope is opened, a  |
-| new dictionnary is added on the top of the heap; the dictionary is     |
-| removed when the scope is closed.  Lookup of symbols is donne in the   |
-| last added dictionnary first (LIFO).                                   |
-`-----------------------------------------------------------------------*/
-class EXTERN_SYMBOL Heap
-{
-private :
-    types::Bool *m_True;
-    typedef std::list<Scope*> ListScope;
-    typedef std::map<Symbol, ListScope* > MapScope;
-    MapScope namespaces;
-    ListScope globals;
-public:
-    /**
-
-    */
-    Heap()
-    {
-        scope_begin();
-        m_True = new types::Bool(1);
-        m_True->IncreaseRef();
-    }
-
-    void namespace_add(const symbol::Symbol& name)
-    {
-        namespaces[name] = new ListScope;
-    }
-
-    void scope_begin()
-    {
-        globals.push_front(new Scope());
-        MapScope::iterator it = namespaces.begin();
-        for (; it != namespaces.end() ; it++)
-        {
-            it->second->push_front(new Scope());
-        }
-    }
-
-    void scope_end()
-    {
-        delete globals.front();
-        globals.pop_front();
-        MapScope::iterator it = namespaces.begin();
-        for (; it != namespaces.end() ; it++)
-        {
-            delete it->second->front();
-            it->second->pop_front();
-        }
-    }
-
-    void put(const symbol::Symbol& key, types::InternalType &value)
-    {
-        globals.back()->put(key, value);
-    }
-
-    void put(const symbol::Symbol& name, const symbol::Symbol& key, types::InternalType &value)
-    {
-        MapScope::iterator scope = namespaces.find(name);
-        if (scope == namespaces.end())
-        {
-            //create namespace if does not exist
-            namespace_add(name);
-            scope = namespaces.find(name);
-        }
-
-        scope->second->back()->put(key, value);
-    }
-
-    types::InternalType* get(const symbol::Symbol& key) const
-    {
-        return globals.back()->get(key);
-    }
-
-    types::InternalType* get(const symbol::Symbol& name, const symbol::Symbol& key) const
-    {
-        MapScope::const_iterator scope = namespaces.find(name);
-        if (scope != namespaces.end())
-        {
-            return scope->second->back()->get(key);
-        }
-        return NULL;
-    }
-
-    bool isGlobalVisible(const symbol::Symbol& key) const
-    {
-        if (globals.empty())
-        {
-            return false;
-        }
-
-        ListScope::const_iterator it;
-        if (globals.front()->get(key))
-        {
-            return true;
-        }
-        //for (it = globals.begin() ; it != globals.end() ; it++)
-        //{
-        //    if((*it)->get(key))
-        //    {
-        //        return true;
-        //    }
-        //}
-        return false;
-    }
-
-    bool isGlobalExists(const symbol::Symbol& key) const
-    {
-        if (getGlobalValue(key))
-        {
-            return true;
-        }
-        return false;
-    }
-
-    types::InternalType* getGlobalValue(const symbol::Symbol& key) const
-    {
-        return globals.back()->get(key);
-    }
-
-    void setGlobalValue(const symbol::Symbol& key, types::InternalType &value)
-    {
-        globals.back()->put(key, value);
-    }
-
-    void createEmptyGlobalValue(const symbol::Symbol& key)
-    {
-        setGlobalValue(key, *types::Double::Empty());
-    }
-
-
-    void setGlobalVisible(const symbol::Symbol& key, bool bVisible)
-    {
-        if (bVisible)
-        {
-            globals.front()->put(key, *m_True);
-        }
-        else
-        {
-            globals.front()->remove(key);
-        }
-    }
-
-    void removeGlobal(const symbol::Symbol& key)
-    {
-        ListScope::const_iterator it;
-        for (it = globals.begin() ; it != globals.end() ; it++)
-        {
-            (*it)->remove(key);
-        }
-    }
-
-    void removeGlobalAll()
-    {
-        ListScope::const_iterator it;
-        for (it = globals.begin() ; it != globals.end() ; it++)
-        {
-            std::map<symbol::Symbol, types::InternalType*>::const_iterator it_scope;
-            std::map<symbol::Symbol, types::InternalType*>* pScope = (*it)->getInternalMap();
-
-            it_scope = pScope->begin();
-            while (it_scope != pScope->end())
-            {
-                (*it)->remove(it_scope->first);
-                it_scope = pScope->begin();
-            }
-        }
-    }
-
-    void print(std::wostream& ostr) const
-    {
-        //print globals
-        ListScope::const_iterator it;
-        for (it = globals.begin() ; it != globals.end() ; it++)
-        {
-            (*it)->print(ostr);
-        }
-
-        //print namespace
-        MapScope::const_iterator it_namespace;
-        ListScope::const_iterator it_scope;
-        for (it_namespace = namespaces.begin() ; it_namespace != namespaces.end() ; it_namespace++)
-        {
-            print(it_namespace->first, ostr);
-        }
-
-    }
-
-    void print(const Symbol& name, std::wostream& ostr) const
-    {
-        MapScope::const_iterator scope = namespaces.find(name);
-        if (scope == namespaces.end())
-        {
-            ostr << name.name_get() << L" not found" << std::endl;
-            return;
-        }
-
-        ListScope::const_iterator it;
-
-        ostr << scope->first.name_get() << "L : " << std::endl;
-        for (it = scope->second->begin() ; it != scope->second->end() ; it++)
-        {
-            (*it)->print(ostr);
-        }
-    }
-
-};
-
-inline std::wostream& operator<< (std::wostream& ostr, const Heap &tbl)
-{
-    tbl.print (ostr);
-    return ostr;
-}
-}
-
-
-#endif /* ! SYMBOL_HEAP_HH */
-
index 9dc0558..a4b21a4 100644 (file)
@@ -1,7 +1,6 @@
 /*
 *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-*  Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
-*  Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS
+*  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
 *
 */
 
-#ifndef __SCOPE_HXX__
-#define __SCOPE_HXX__
+#ifndef __NEWSCOPE_HXX__
+#define __NEWSCOPE_HXX__
 
-#include <iostream>
-#include <map>
-#include <list>
-//#include "internal.hxx"
-#include "double.hxx"
-#include "callable.hxx"
-#include "export_symbol.h"
-
-extern "C"
-{
-#include "charEncoding.h"
-#include "MALLOC.h"
-}
+#include "variables.hxx"
 
 namespace symbol
 {
-
-//template< class Entry_T, class Key_T = Symbol >
-class EXTERN_SYMBOL Scope
+class Scope
 {
-private:
-    typedef std::map<symbol::Symbol, types::InternalType*> ScopeMap;
-    ScopeMap* _scope;
-    std::wstring _name;
-
-public:
-    /** Constructor & Destructor */
-    /** \brief Construct a Scope */
-    explicit Scope()
-    {
-        _scope = new ScopeMap();
-        _name = L"";
-    }
-
-    ~Scope()
-    {
-        ScopeMap::iterator i;
-        for (i = _scope->begin() ; i != _scope->end() ; ++i)
-        {
-            //std::cout << i->first << std::endl;
-            i->second->DecreaseRef();
-            if (i->second->isDeletable())
-            {
-                //std::wcout << L"--- DELETE : " << i->first << L" " << i->second << " " << i->second->getRef() << std::endl;
-                delete i->second;
-                i->second = NULL;
-            }
-            else
-            {
-                //std::wcout << L"--- KEEP : " << i->first << L" " << i->second << " " << i->second->getRef() << std::endl;
-            }
-        }
-        delete _scope;
-    }
-
-    bool isUsed(types::InternalType* pIT) const
-    {
-        ScopeMap::const_iterator it_scope;
-        for (it_scope = _scope->begin() ; it_scope != _scope->end() ; ++it_scope)
-        {
-            if ((*it_scope).second == pIT)
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /** Associate value to key in the current scope. */
-    types::InternalType* put(const symbol::Symbol& key, types::InternalType &value)
-    {
-        types::InternalType *pOld = (*_scope)[key];
-
-        if (pOld == &value)
-        {
-            return NULL;
-        }
-
-        value.IncreaseRef();
-
-        if (pOld != NULL)
-        {
-            pOld->DecreaseRef();
-            if (pOld->isDeletable() == true)
-            {
-                delete pOld;
-                pOld = NULL;
-            }
-        }
+public :
+    Scope(Variables* _vars, int _iLevel) : m_vars(_vars), m_iLevel(_iLevel) {}
+    virtual ~Scope();
 
-        (*_scope)[key] = &value;
-        return NULL;
-    }
+    void put(const Symbol& _key, types::InternalType& _iT);
+    void remove(const Symbol& _key);
+    void print(std::wostream& ostr);
+    void addVar(const symbol::Symbol& _key);
+    void removeVar(const symbol::Symbol& _key);
 
-    void remove(const symbol::Symbol& key)
+    int getLevel()
     {
-        if ((*_scope).find(key) != (*_scope).end())
-        {
-            types::InternalType *pOld = (*_scope)[key];
-
-            if (pOld)
-            {
-                _scope->erase(key);
-                pOld->DecreaseRef();
-                if (pOld->isDeletable() == true)
-                {
-                    delete pOld;
-                    pOld = NULL;
-                }
-            }
-        }
-    }
-
-    /** 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
-    {
-        ScopeMap::const_iterator it_scope;
-
-        it_scope = (*_scope).find(key);
-        if (it_scope == (*_scope).end())
-        {
-            return 0;
-        }
-        return (*it_scope).second;
-    }
-
-    /** Return name of current scope, use for namespace. */
-    std::wstring get_name() const
-    {
-        return _name;
+        return m_iLevel;
     }
+private :
+    typedef std::map<Symbol, int> SymbolMap;
+    SymbolMap m_symbol;
+    int m_iLevel;
+    Variables* m_vars;
+};
 
-    /** Return name of current scope, use for namespace. */
-    std::list<symbol::Symbol>& get_names(const std::wstring& _stModuleName) const
+class Scopes
+{
+private :
+    typedef std::list<Scope*> ScopesList;
+    ScopesList m_scopes;
+    int m_iLevel;
+    Variables m_vars;
+
+public :
+
+    Scopes() : m_iLevel(-1) {}
+
+    void scope_begin();
+    void scope_end();
+
+    /*setters*/
+
+private :
+    void put(const Symbol& _key, types::InternalType& _iT, int _iLevel);
+public :
+    void put(const Symbol& _key, types::InternalType& _iT);
+    void putInPreviousScope(const Symbol& _key, types::InternalType& _iT);
+
+    /* getters */
+    types::InternalType* get(const Symbol& _key) const;
+    types::InternalType* getCurrentLevel(const Symbol& _key) const;
+    types::InternalType* getAllButCurrentLevel(const Symbol& _key) const;
+
+    /*remove*/
+    bool remove(const Symbol& _key);
+
+    /*globals*/
+    bool isGlobalVisible(const symbol::Symbol& _key) const;
+    void removeGlobal(const symbol::Symbol& _key);
+    void removeGlobalAll();
+    void setGlobalVisible(const symbol::Symbol& _key, bool bVisible);
+    types::InternalType* getGlobalValue(const symbol::Symbol& _key) const;
+    bool isGlobalExists(const symbol::Symbol& _key) const;
+    void setGlobalValue(const symbol::Symbol& _key, types::InternalType &value);
+    void createEmptyGlobalValue(const symbol::Symbol& _key);
+
+    /*tools*/
+    std::list<symbol::Symbol>& getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd);
+    void print(std::wostream& ostr) const
     {
-        std::list<symbol::Symbol>* pNames = new std::list<symbol::Symbol>;
-        ScopeMap::const_iterator it_scope;
-        for (it_scope = _scope->begin() ; it_scope != _scope->end() ; ++it_scope)
-        {
-            if (it_scope->second->isFunction() || it_scope->second->isMacro() || it_scope->second->isMacroFile())
-            {
-                types::Callable* pC = it_scope->second->getAs<types::Callable>();
-                if (_stModuleName == L""  || pC->getModule() == _stModuleName)
-                {
-                    pNames->push_back(it_scope->first);
-                }
-            }
-        }
+        ScopesList::const_iterator it = m_scopes.begin();
 
-        return *pNames;
-    }
-
-    /** Send the content of this table on ostr in a readable manner, the top
-    ** of the stack being displayed last. */
-    void       print (std::wostream& ostr) const
-    {
-        ScopeMap::const_iterator it_scope;
-        for (it_scope = _scope->begin() ; it_scope != _scope->end() ; ++it_scope)
+        for (; it != m_scopes.end() ; it++)
         {
-            //ostr << it_scope->first.name_get() << " = " << it_scope->second->toString(10,75) << std::endl;
-            if (it_scope->second->isMacroFile() == false && it_scope->second->isFunction() == false)
-            {
-                ostr.width(25);
-                ostr << it_scope->first.name_get();
-                ostr << " (" << it_scope->second->getRef();
-                ostr << ") = " << it_scope->second->getTypeStr() << std::endl;
-            }
+            (*it)->print(ostr);
+            ostr << std::endl << std::endl;
         }
     }
-
-    ScopeMap* getInternalMap()
-    {
-        return _scope;
-    }
 };
 
-inline std::wostream& operator<< (std::wostream& ostr,
-                                  const Scope &scope)
+inline std::wostream& operator<< (std::wostream& ostr, const Scopes& _scopes)
 {
-    scope.print(ostr);
+    _scopes.print(ostr);
     return ostr;
 }
-}
-
 
-#endif /* ! __SCOPE_HX__ */
+}
 
+#endif /* !__NEWSCOPE_HXX__ */
\ No newline at end of file
diff --git a/scilab/modules/symbol/includes/stack.hxx b/scilab/modules/symbol/includes/stack.hxx
deleted file mode 100644 (file)
index 6f2a4ae..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- *  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 SYMBOL_STACK_HH
-#define SYMBOL_STACK_HH
-
-#include <iostream>
-#include <list>
-#include <cassert>
-#include "table.hxx"
-#include "internal.hxx"
-#include "export_symbol.h"
-
-namespace symbol
-{
-
-/*-----------------------------------------------------------------------.
-| This implements stacks for storing definitions of variables and        |
-| functions as a stack of dictionnaries.  Each time a scope is opened, a |
-| new dictionnary is added on the top of the stack; the dictionary is    |
-| removed when the scope is closed.  Lookup of symbols is donne in the   |
-| last added dictionnary first (LIFO).                                   |
-`-----------------------------------------------------------------------*/
-class EXTERN_SYMBOL Stack : public Table
-{
-public:
-    /** Open a new scope */
-    void scope_begin()
-    {
-        this->l_scope.push_front(new Scope());
-    }
-
-    /** Close the last scope, forgetting everything since the latest
-    ** scope_begin (). */
-    void scope_end()
-    {
-        Scope* scope = this->l_scope.front();
-        delete scope;
-        this->l_scope.pop_front();
-    }
-
-    void putInPreviousScope(const symbol::Symbol& key, types::InternalType &value)
-    {
-        if (l_scope.size() > 1)
-        {
-            std::list<Scope*>::iterator i;
-            i = l_scope.begin();
-            i++;
-            (*i)->put(key, value);
-        }
-    }
-
-    /** Associate value to key in the current scope. */
-    void put(const symbol::Symbol& key, types::InternalType &value)
-    {
-        (this->l_scope.front())->put(key, value);
-    }
-
-    /** Remove Association between value and key in the current scope. */
-    void remove(const symbol::Symbol& key)
-    {
-        (this->l_scope.front())->remove(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* get(const symbol::Symbol& key) const
-    {
-        types::InternalType* result = NULL;
-
-        std::list<Scope*>::const_iterator it_list_scope = this->l_scope.begin();
-
-        for (; it_list_scope != this->l_scope.end(); it_list_scope++)
-        {
-            result = (*it_list_scope)->get(key);
-            if (result)
-            {
-                return result;
-            }
-        }
-        return result;
-    }
-
-    /** 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* result = 0;
-
-        /*
-        ** If we are in the top level scope, also look within it
-        */
-        if (l_scope.size() == 1)
-        {
-            return l_scope.front()->get(key);
-        }
-
-        /*
-        ** else look in all previous scopes but not in the current one.
-        */
-        std::list<Scope*>::const_iterator it_list_scope = this->l_scope.begin();
-        ++it_list_scope;
-        for ( ; it_list_scope != this->l_scope.end(); ++it_list_scope)
-        {
-            result = (*it_list_scope)->get(key);
-            if (result == 0)
-            {
-                continue ;
-            }
-            return result;
-        }
-        return result;
-    }
-
-    /** 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
-    {
-        return l_scope.front()->get(key);
-    }
-
-
-    std::list<symbol::Symbol>& getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd)
-    {
-        //get hightest scope
-        std::list<Scope*>::iterator i;
-
-        if (_bFromEnd)
-        {
-            i = l_scope.end();
-            i--;
-        }
-        else
-        {
-            i = l_scope.begin();
-        }
-
-        return (*i)->get_names(_stModuleName);
-    }
-};
-
-inline std::wostream& operator<< (std::wostream& ostr, const Stack &tbl)
-{
-    tbl.print (ostr);
-    return ostr;
-}
-}
-
-
-#endif /* ! SYMBOL_STACK_HH */
-
diff --git a/scilab/modules/symbol/includes/table.hxx b/scilab/modules/symbol/includes/table.hxx
deleted file mode 100644 (file)
index be74b39..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-*  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 __TABLE_HXX__
-#define __TABLE_HXX__
-
-#include <list>
-#include "symbol.hxx"
-#include "scope.hxx"
-#include "internal.hxx"
-#include "export_symbol.h"
-
-namespace symbol
-{
-
-/*-----------------------------------------------------------------------.
-| This implements tables for storing definitions of variables and        |
-| functions as a stack of dictionnaries.  Each time a scope is opened, a |
-| new dictionnary is added on the top of the stack; the dictionary is    |
-| removed when the scope is closed.  Lookup of symbols is donne in the   |
-| last added dictionnary first (LIFO).                                   |
-`-----------------------------------------------------------------------*/
-class EXTERN_SYMBOL Table
-{
-public:
-
-    virtual ~Table()
-    {
-    }
-
-    /** Associate value to key in the current scope. */
-    virtual void put (const symbol::Symbol& key, types::InternalType &value) = 0 ;
-
-    /** If key was associated to some Entry_T in the open scopes, return the
-    ** most recent insertion. Otherwise return the empty pointer. */
-    virtual types::InternalType*       get (const symbol::Symbol& key) const = 0 ;
-
-    /** Send the content of this table on ostr in a readable manner, the top
-    ** of the stack being displayed last. */
-    void       print (std::wostream& ostr) const;
-
-protected:
-    std::list<Scope*> l_scope;
-};
-
-}
-
-
-#endif /* ! __TABLE_HXX__ */
-
diff --git a/scilab/modules/symbol/includes/variables.hxx b/scilab/modules/symbol/includes/variables.hxx
new file mode 100644 (file)
index 0000000..7b6307a
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+*  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
+*
+*/
+
+#ifndef __VARIABLES_HXX__
+#define __VARIABLES_HXX__
+
+#include <map>
+#include <list>
+#include "types.hxx"
+#include "symbol.hxx"
+
+namespace symbol
+{
+struct VarBox
+{
+    VarBox(int _iLevel, types::InternalType* _pIT, bool _bGlobal = false, bool _bGlobalVisible = false);
+
+    int m_iLevel;
+    types::InternalType* m_pIT;
+    bool m_bGlobal;
+    bool m_bGlobalVisible;
+};
+
+class Variables
+{
+private :
+    //current scope level
+    int m_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;
+
+    void removeGlobal(GlobalMap::iterator& _it);
+public :
+    Variables() : m_iLevel(-1) {}
+
+    virtual ~Variables() {}
+
+    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);
+
+    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;
+
+    std::list<symbol::Symbol>& getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd) const;
+
+    /*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);
+
+    bool remove(const Symbol& _key);
+
+    void IncreaseLevel()
+    {
+        m_iLevel++;
+    }
+    void DecreaseLevel()
+    {
+        m_iLevel--;
+    }
+};
+}
+#endif /* !__VARIABLES_HXX__ */
\ No newline at end of file
diff --git a/scilab/modules/symbol/src/cpp/_context.hh b/scilab/modules/symbol/src/cpp/_context.hh
deleted file mode 100644 (file)
index e232344..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *  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
- *
- */
-
-/**
- ** \file symbol/context.hh
- ** \brief Define class Context.
- */
-
-#ifndef CONTEXT_HH
-# define CONTEXT_HH
-
-#include "stack.hh"
-#include "heap.hh"
-
-namespace symbol
-{
-
-  /** \brief Define class Context.
-   */
-  template< class Entry_T, class Key_T = Symbol >
-  class Context
-  {
-  public :
-    Context();/* {
-      PrivateFunTable.scope_begin();
-      PrivateVarTable.scope_begin();
-      HeapFunTable.scope_begin();
-      HeapVarTable.scope_begin();
-      EnvFunTable.scope_begin();
-      EnvVarTable.scope_begin();
-    }
-*/
-  static Context* getInstance(void);
-
-       /** Open a context scope i.e
-     ** open the heap table one
-     ** and the env table too. */
-    void scope_begin();
-
-    /** Close a context scope i.e
-     ** close the heap table one
-     ** and the env table too. */
-               void scope_end();
-
-    /** If key was associated to some Entry_T in the open scopes, return the
-     ** most recent insertion. Otherwise return the empty pointer. */
-    Entry_T*   get(Key_T key) const;
-
-    /** If key was associated to some Entry_T in the open scopes, return the
-     ** most recent insertion. Otherwise return the empty pointer. */
-    Entry_T*   get_fun(Key_T key) const;
-
-       private :
-    static Stack<Entry_T, Key_T> PrivateFunTable;
-    static Stack<Entry_T, Key_T> PrivateVarTable;
-    static Heap<Entry_T, Key_T> HeapFunTable;
-    static Heap<Entry_T, Key_T> HeapVarTable;
-    static Stack<Entry_T, Key_T> EnvFunTable;
-    static Stack<Entry_T, Key_T> EnvVarTable;
-
-               static Context* me;
-  };
-}
-#endif // !CONTEXT_HH
diff --git a/scilab/modules/symbol/src/cpp/_heap.hh b/scilab/modules/symbol/src/cpp/_heap.hh
deleted file mode 100644 (file)
index ecfb174..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- *  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 SYMBOL_HEAP_HH
-# define SYMBOL_HEAP_HH
-
-# include <iostream>
-# include <list>
-# include "table.hh"
-
-#define GLOBAL "global"
-
-namespace symbol
-{
-
-/*-----------------------------------------------------------------------.
-| This implements heaps for storing definitions of variables and         |
-| functions as a list of dictionnaries.  Each time a scope is opened, a  |
-| new dictionnary is added on the top of the heap; the dictionary is     |
-| removed when the scope is closed.  Lookup of symbols is donne in the   |
-| last added dictionnary first (LIFO).                                   |
-`-----------------------------------------------------------------------*/
-  template< class Entry_T, class Key_T = Symbol >
-  class Heap : public Table< Entry_T, Key_T >
-  {
-  public:
-    /**
-
-     */
-    Heap()
-    {
-      scope_begin(GLOBAL);
-    }
-
-    /** Open a new scope */
-    void       scope_begin(std::string name)
-    {
-      this->l_scope.push_front(*new Scope<Entry_T, Key_T>(name));
-    }
-
-    /** Close the last scope, forgetting everything since the latest
-     **        scope_begin (). */
-    void       scope_end(std::string name)
-    {
-      this->l_scope.pop_front();
-    }
-
-    /*
-    ** Global namespace direct access.
-    ** {
-    */
-
-    /** Associate value to key in the global scope. */
-    void       put (Key_T key, Entry_T &value)
-    {
-      (this->l_scope.back()).put(key, value);
-    }
-
-    /** \brief If key was associated to some Entry_T in
-     ** the "global"/last namespace, return the
-     ** most recent insertion. Otherwise return the empty pointer.
-     ** \param key : the key to look for
-     */
-    Entry_T*   get (Key_T key) const
-    {
-      Entry_T* result = 0;
-
-      result = (this->l_scope.back()).get(key);
-      return result;
-    }
-
-    /*
-    ** }
-    ** END Global Namespace
-    */
-
-    /** \brief Associate a value to a key in the given namespace.
-     ** If the Namespace does not exists it will be automatically
-     ** created.
-     ** \param name : the name of the namespace.
-     ** \param key : the key.
-     ** \param value : the value associated to the key.
-    */
-    void       put(std::string name, Key_T key, Entry_T &value)
-    {
-      typename std::list< Scope<Entry_T, Key_T> >::iterator
-       it_list_scope;
-
-      for (it_list_scope = this->l_scope.begin();
-          it_list_scope != this->l_scope.end();
-          ++it_list_scope)
-       {
-         if ((*it_list_scope).get_name() == name)
-           {
-             (*it_list_scope).put(key, value);
-             return ;
-           }
-       }
-      scope_begin(name);
-      (this->l_scope.front()).put(key, value);
-    }
-
-    /** \brief If key was associated to some Entry_T in
-     ** the "global"/last namespace, return the
-     ** most recent insertion. Otherwise return the empty pointer.
-     ** \param key : the key to look for
-     */
-    Entry_T*   get (std::string name, Key_T key) const
-    {
-      typename std::list< Scope<Entry_T, Key_T> >::const_iterator
-       it_list_scope;
-
-      for (it_list_scope = this->l_scope.begin();
-          it_list_scope != this->l_scope.end();
-          ++it_list_scope)
-       {
-         if ((*it_list_scope).get_name() == name)
-           {
-             return (*it_list_scope).get(key);
-           }
-       }
-      return NULL;
-    }
-
-  };
-
-  template< class T, class Key_T >
-  inline std::ostream& operator<< (std::ostream& ostr,
-                                  const Heap<T, Key_T>& tbl)
-  {
-    tbl.print (ostr);
-    return ostr;
-  }
-}
-
-
-#endif /* ! SYMBOL_HEAP_HH */
-
diff --git a/scilab/modules/symbol/src/cpp/_scope.hh b/scilab/modules/symbol/src/cpp/_scope.hh
deleted file mode 100644 (file)
index b0d6821..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-*  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 SYMBOL_SCOPE_HH
-# define SYMBOL_SCOPE_HH
-
-# include <iostream>
-# include <map>
-# include "symbol.hh"
-
-namespace symbol
-{
-
-       template< class Entry_T, class Key_T = Symbol >
-       class Scope
-       {
-       public:
-               /** Constructor & Destructor */
-               /** \brief Construct a Scope */
-               explicit Scope()
-               {
-                       _scope = new std::map< Key_T, Entry_T* >();
-                       _name = "";
-               }
-               /** \brief Construct a named Scope i.e Namespace */
-               explicit Scope(std::string name)
-               {
-                       _scope = new std::map< Key_T, Entry_T* >();
-                       _name = name;
-               }
-
-               ~Scope()
-               {
-                       delete _scope;
-               }
-
-
-
-               /** Associate value to key in the current scope. */
-               void    put (Key_T key, Entry_T &value)
-               {
-                       (*_scope)[key] = &value;
-               }
-
-               /** If key was associated to some Entry_T in the open scopes, return the
-               ** most recent insertion. Otherwise return the empty pointer. */
-               Entry_T*        get (Key_T key) const
-               {
-                       typename std::map< Key_T, Entry_T* >::const_iterator
-                               it_scope;
-
-                       it_scope = (*_scope).find(key);
-                       if (it_scope == (*_scope).end())
-                               return 0;
-                       return (*it_scope).second;
-               }
-
-               /** Return name of current scope, use for namespace. */
-               std::string get_name() const
-               {
-                       return _name;
-               }
-
-               /** Send the content of this table on ostr in a readable manner, the top
-               ** of the stack being displayed last. */
-               void    print (std::ostream& ostr) const
-               {
-                       typename std::map< Key_T, Entry_T* >::const_iterator
-                               it_scope;
-
-                       for(it_scope = _scope->begin() ; it_scope != _scope->end() ; ++it_scope)
-                       {
-                               if (_name != "")
-                               {
-                                       ostr << _name << "::";
-                               }
-                               ostr << (*it_scope).first << " : ";
-                               ostr << *((*it_scope).second) << std::endl;
-                       }
-               }
-
-       private:
-               std::map< Key_T, Entry_T* >*    _scope;
-               std::string                             _name;
-       };
-
-       template< class T, class Key_T >
-       inline std::ostream& operator<< (std::ostream& ostr,
-               const Scope<T, Key_T>& scope)
-       {
-               scope.print(ostr);
-               return ostr;
-       }
-}
-
-
-#endif /* ! SYMBOL_SCOPE_HH */
-
diff --git a/scilab/modules/symbol/src/cpp/_stack.hh b/scilab/modules/symbol/src/cpp/_stack.hh
deleted file mode 100644 (file)
index 82d1003..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- *  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 SYMBOL_STACK_HH
-# define SYMBOL_STACK_HH
-
-# include <iostream>
-# include <list>
-# include <map>
-# include <cassert>
-# include "table.hh"
-
-namespace symbol
-{
-
-/*-----------------------------------------------------------------------.
-| This implements stacks for storing definitions of variables and        |
-| functions as a stack of dictionnaries.  Each time a scope is opened, a |
-| new dictionnary is added on the top of the stack; the dictionary is    |
-| removed when the scope is closed.  Lookup of symbols is donne in the   |
-| last added dictionnary first (LIFO).                                   |
-`-----------------------------------------------------------------------*/
-  template< class Entry_T, class Key_T = Symbol >
-  class Stack : public Table< Entry_T, Key_T >
-  {
-  public:
-    /** Open a new scope */
-    void       scope_begin()
-    {
-      this->l_scope.push_front(*new Scope<Entry_T, Key_T>());
-    }
-
-    /** Close the last scope, forgetting everything since the latest
-     **        scope_begin (). */
-    void       scope_end()
-    {
-      this->l_scope.pop_front();
-    }
-
-    /** Associate value to key in the current scope. */
-    void       put (Key_T key, Entry_T &value)
-    {
-      (this->l_scope.front()).put(key, value);
-    }
-
-    /** If key was associated to some Entry_T in the open scopes, return the
-     ** most recent insertion. Otherwise return the empty pointer. */
-    Entry_T*   get (Key_T key) const
-    {
-      Entry_T* result = 0;
-
-      typename std::list< Scope<Entry_T, Key_T> >::const_iterator
-       it_list_scope;
-
-      for (it_list_scope = this->l_scope.begin();
-          it_list_scope != this->l_scope.end();
-          ++it_list_scope)
-       {
-         result = (*it_list_scope).get(key);
-         if (result == 0)
-           continue ;
-         return result;
-       }
-      return result;
-    }
-
-  };
-
-  template< class T, class Key_T >
-  inline std::ostream& operator<< (std::ostream& ostr,
-                                  const Stack<T, Key_T>& tbl)
-  {
-    tbl.print (ostr);
-    return ostr;
-  }
-}
-
-
-#endif /* ! SYMBOL_STACK_HH */
-
diff --git a/scilab/modules/symbol/src/cpp/_table.hh b/scilab/modules/symbol/src/cpp/_table.hh
deleted file mode 100644 (file)
index f53a8f4..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *  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 SYMBOL_TABLE_HH
-# define SYMBOL_TABLE_HH
-
-# include <iostream>
-# include <list>
-# include "symbol.hh"
-# include "scope.hh"
-
-namespace symbol
-{
-
-/*-----------------------------------------------------------------------.
-| This implements tables for storing definitions of variables and        |
-| functions as a stack of dictionnaries.  Each time a scope is opened, a |
-| new dictionnary is added on the top of the stack; the dictionary is    |
-| removed when the scope is closed.  Lookup of symbols is donne in the   |
-| last added dictionnary first (LIFO).                                   |
-`-----------------------------------------------------------------------*/
-  template< class Entry_T, class Key_T = Symbol >
-  class Table
-  {
-  public:
-
-    virtual ~Table()
-    {
-    }
-
-    /** Associate value to key in the current scope. */
-    virtual void put (Key_T key, Entry_T &value) = 0 ;
-
-    /** If key was associated to some Entry_T in the open scopes, return the
-     ** most recent insertion. Otherwise return the empty pointer. */
-    virtual Entry_T*   get (Key_T key) const = 0 ;
-
-    /** Send the content of this table on ostr in a readable manner, the top
-     ** of the stack being displayed last. */
-    void       print (std::ostream& ostr) const
-    {
-      typename std::list< Scope<Entry_T, Key_T> >::const_iterator
-       it_list_scope;
-      typename std::list< Scope<Entry_T, Key_T> >::size_type   i;
-
-      for (i = (*this).l_scope.size() - 1, it_list_scope = (*this).l_scope.begin();
-          it_list_scope != (*this).l_scope.end();
-          --i, ++it_list_scope)
-       {
-         ostr << "Scope level: " << i << std::endl;
-         ostr << *it_list_scope;
-       }
-    }
-
-  protected:
-    std::list< Scope<Entry_T, Key_T> > l_scope;
-  };
-
-}
-
-
-#endif /* ! SYMBOL_TABLE_HH */
-
index cc6082a..c4f84ba 100644 (file)
@@ -32,9 +32,8 @@ Context* Context::me;
 
 Context::Context()
 {
-    PrivateVarTable.scope_begin();
-    HeapVarTable.scope_begin();
-    EnvVarTable.scope_begin();
+    m_scopes = new Scopes();
+    m_scopes->scope_begin();
 }
 
 Context* Context::getInstance(void)
@@ -48,147 +47,115 @@ Context* Context::getInstance(void)
 
 void Context::scope_begin()
 {
-    HeapVarTable.scope_begin();
-    EnvVarTable.scope_begin();
+    m_scopes->scope_begin();
 }
 
 void Context::scope_end()
 {
-    HeapVarTable.scope_end();
-    EnvVarTable.scope_end();
+    m_scopes->scope_end();
 }
 
-types::InternalType* Context::get(const symbol::Symbol& key) const
+types::InternalType* Context::get(const symbol::Symbol& _key) const
 {
-    types::InternalType* pI = NULL;
-
-    //global scope
-    if (HeapVarTable.isGlobalVisible(key))
-    {
-        return HeapVarTable.getGlobalValue(key);
-    }
-
-    //local scope
-    return EnvVarTable.get(key);
+    return m_scopes->get(_key);
 }
 
-types::InternalType* Context::getCurrentLevel(const symbol::Symbol& key) const
+types::InternalType* Context::getCurrentLevel(const symbol::Symbol& _key) const
 {
-    return EnvVarTable.getCurrentLevel(key);
+    return m_scopes->getCurrentLevel(_key);
 }
 
-types::InternalType* Context::getAllButCurrentLevel(const symbol::Symbol& key) const
+types::InternalType* Context::getAllButCurrentLevel(const symbol::Symbol& _key) const
 {
-    return EnvVarTable.getAllButCurrentLevel(key);
+    return m_scopes->getAllButCurrentLevel(_key);
 }
 
-types::InternalType* Context::getFunction(const symbol::Symbol& key) const
+types::InternalType* Context::getFunction(const symbol::Symbol& _key) const
 {
-    return EnvVarTable.get(key);
+    return m_scopes->get(_key);
 }
 
 std::list<symbol::Symbol>& Context::getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd)
 {
-    return EnvVarTable.getFunctionList(_stModuleName, _bFromEnd);
+    return m_scopes->getFunctionList(_stModuleName, _bFromEnd);
 }
 
-bool Context::put(const symbol::Symbol& key, types::InternalType &type)
+bool Context::put(const symbol::Symbol& _key, types::InternalType &type)
 {
-    if (HeapVarTable.isGlobalVisible(key))
-    {
-        HeapVarTable.setGlobalValue(key, type);
-    }
-    else
-    {
-        //variable is not in current global scope
-        EnvVarTable.put(key, type);
-    }
-
+    m_scopes->put(_key, type);
     return true;
 }
 
-bool Context::remove(const symbol::Symbol& key)
+bool Context::remove(const symbol::Symbol& _key)
 {
-    // look in local global scope
-    if (HeapVarTable.isGlobalVisible(key))
-    {
-        HeapVarTable.setGlobalVisible(key, false);
-        return true;
-    }
-    // look in Variables Environment
-    else if (EnvVarTable.getCurrentLevel(key) == NULL)
-    {
-        return false;
-    }
-
-    EnvVarTable.remove(key);
+    m_scopes->remove(_key);
     return true;
 }
 
-bool Context::putInPreviousScope(const symbol::Symbol& key, types::InternalType &type)
+bool Context::putInPreviousScope(const symbol::Symbol& _key, types::InternalType &type)
 {
-    EnvVarTable.putInPreviousScope(key, type);
+    m_scopes->putInPreviousScope(_key, type);
     return true;
 }
 
 bool Context::addFunction(types::Function *_info)
 {
-    EnvVarTable.put(symbol::Symbol(_info->getName()), *_info);
+    m_scopes->put(symbol::Symbol(_info->getName()), *_info);
     return true;
 }
 
 bool Context::AddMacro(types::Macro *_info)
 {
-    EnvVarTable.put(symbol::Symbol(_info->getName()), *_info);
+    m_scopes->put(symbol::Symbol(_info->getName()), *_info);
     return true;
 }
 
 bool Context::AddMacroFile(types::MacroFile *_info)
 {
-    EnvVarTable.put(symbol::Symbol(_info->getName()), *_info);
+    m_scopes->put(symbol::Symbol(_info->getName()), *_info);
     return true;
 }
 
-bool Context::isGlobalVisible(const symbol::Symbol& key) const
+bool Context::isGlobalVisible(const symbol::Symbol& _key) const
 {
-    return HeapVarTable.isGlobalVisible(key);
+    return m_scopes->isGlobalVisible(_key);
 }
 
 /*return global variable, search in global scope ( highest )*/
-types::InternalType* Context::getGlobalValue(const symbol::Symbol& key) const
+types::InternalType* Context::getGlobalValue(const symbol::Symbol& _key) const
 {
-    return HeapVarTable.getGlobalValue(key);
+    m_scopes->getGlobalValue(_key);
+    return NULL;
 }
 
 /*return global variable existance status*/
-bool Context::isGlobalExists(const symbol::Symbol& key) const
+bool Context::isGlobalExists(const symbol::Symbol& _key) const
 {
-    return HeapVarTable.isGlobalExists(key);
+    return m_scopes->isGlobalExists(_key);
 }
 
-void Context::setGlobalValue(const symbol::Symbol& key, types::InternalType &value)
+void Context::setGlobalValue(const symbol::Symbol& _key, types::InternalType &value)
 {
-    HeapVarTable.setGlobalValue(key, value);
+    m_scopes->setGlobalValue(_key, value);
 }
 
-void Context::createEmptyGlobalValue(const symbol::Symbol& key)
+void Context::createEmptyGlobalValue(const symbol::Symbol& _key)
 {
-    HeapVarTable.createEmptyGlobalValue(key);
+    m_scopes->createEmptyGlobalValue(_key);
 }
 
-void Context::setGlobalVisible(const symbol::Symbol& key, bool bVisible)
+void Context::setGlobalVisible(const symbol::Symbol& _key, bool bVisible)
 {
-    HeapVarTable.setGlobalVisible(key, bVisible);
+    m_scopes->setGlobalVisible(_key, bVisible);
 }
 
-void Context::removeGlobal(const symbol::Symbol& key)
+void Context::removeGlobal(const symbol::Symbol& _key)
 {
-    HeapVarTable.removeGlobal(key);
+    m_scopes->removeGlobal(_key);
 }
 
 void Context::removeGlobalAll()
 {
-    HeapVarTable.removeGlobalAll();
+    m_scopes->removeGlobalAll();
 }
 }
-
diff --git a/scilab/modules/symbol/src/cpp/scope.cpp b/scilab/modules/symbol/src/cpp/scope.cpp
new file mode 100644 (file)
index 0000000..bbe366a
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+*  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 "scope.hxx"
+
+namespace symbol
+{
+
+/*Scope*/
+Scope::~Scope()
+{
+    SymbolMap::iterator it = m_symbol.begin();
+    for (; it != m_symbol.end() ; it++)
+    {
+        m_vars->remove(it->first);
+    }
+}
+
+void Scope::put(const Symbol& _key, types::InternalType& _iT)
+{
+    m_symbol[_key] = 0;
+    m_vars->put(_key, _iT, m_iLevel);
+}
+
+void Scope::remove(const Symbol& _key)
+{
+    m_symbol.erase(_key);
+    m_vars->remove(_key);
+}
+
+void Scope::print(std::wostream& ostr)
+{
+    ostr << L"scope " << m_iLevel << L" : " << std::endl;
+
+    SymbolMap::iterator it = m_symbol.begin();
+    for (; it != m_symbol.end() ; it++)
+    {
+        ostr.width(25);
+        ostr << it->first.name_get();
+        types::InternalType* pIT = m_vars->getInSpecificLevel(it->first, m_iLevel);
+        if (pIT)
+        {
+            ostr << L" (" << pIT->getRef();
+            ostr << L") = " << pIT->getTypeStr() << std::endl;
+        }
+        else
+        {
+            ostr << L"NULL Oo";
+        }
+    }
+}
+
+void Scope::addVar(const symbol::Symbol& _key)
+{
+    m_symbol[_key] = 0;
+}
+
+void Scope::removeVar(const symbol::Symbol& _key)
+{
+    m_symbol.erase(_key);
+}
+
+/*Scopes*/
+void Scopes::scope_begin()
+{
+    m_iLevel++;
+    m_scopes.push_back(new Scope(&m_vars, m_iLevel));
+    m_vars.IncreaseLevel();
+}
+
+void Scopes::scope_end()
+{
+    Scope* scope = m_scopes.back();
+    delete scope;
+    m_scopes.pop_back();
+    m_iLevel--;
+    m_vars.DecreaseLevel();
+}
+
+void Scopes::put(const Symbol& _key, types::InternalType& _iT, int _iLevel)
+{
+    ScopesList::iterator it = m_scopes.begin();
+    for (; it != m_scopes.end() ; it++)
+    {
+        //fond good scope and put variable
+        if ((*it)->getLevel() == _iLevel)
+        {
+            (*it)->put(_key, _iT);
+        }
+    }
+}
+
+void Scopes::put(const Symbol& _key, types::InternalType& _iT)
+{
+    put(_key, _iT, m_iLevel);
+}
+
+void Scopes::putInPreviousScope(const Symbol& _key, types::InternalType& _iT)
+{
+    put(_key, _iT, m_iLevel - 1);
+}
+
+/* getters */
+types::InternalType* Scopes::get(const Symbol& _key) const
+{
+    return m_vars.get(_key);
+}
+
+types::InternalType* Scopes::getCurrentLevel(const Symbol& _key) const
+{
+    return m_vars.getCurrentLevel(_key);
+}
+
+types::InternalType* Scopes::getAllButCurrentLevel(const Symbol& _key) const
+{
+    return m_vars.getAllButCurrentLevel(_key);
+}
+
+/*remove*/
+bool Scopes::remove(const Symbol& _key)
+{
+    m_scopes.back()->remove(_key);
+    return true;
+}
+
+/*globales*/
+bool Scopes::isGlobalVisible(const symbol::Symbol& _key) const
+{
+    return m_vars.isGlobalVisible(_key);
+}
+
+void Scopes::removeGlobal(const symbol::Symbol& _key)
+{
+    m_vars.removeGlobal(_key);
+}
+
+void Scopes::removeGlobalAll()
+{
+    m_vars.removeGlobalAll();
+}
+
+void Scopes::setGlobalVisible(const symbol::Symbol& _key, bool bVisible)
+{
+    Scope* pBack = m_scopes.back();
+    if (bVisible)
+    {
+        pBack->addVar(_key);
+    }
+    else
+    {
+        pBack->removeVar(_key);
+    }
+    m_vars.setGlobalVisible(_key, bVisible);
+}
+
+types::InternalType* Scopes::getGlobalValue(const symbol::Symbol& _key) const
+{
+    return m_vars.getGlobalValue(_key);
+}
+
+bool Scopes::isGlobalExists(const symbol::Symbol& _key) const
+{
+    return m_vars.isGlobalExists(_key);
+}
+
+void Scopes::setGlobalValue(const symbol::Symbol& _key, types::InternalType& _value)
+{
+    m_vars.setGlobalValue(_key, _value);
+}
+
+void Scopes::createEmptyGlobalValue(const symbol::Symbol& _key)
+{
+    return m_vars.createEmptyGlobalValue(_key);
+}
+
+
+/*tools*/
+std::list<symbol::Symbol>& Scopes::getFunctionList(const std::wstring& _stModuleName, bool _bFromEnd)
+{
+    return m_vars.getFunctionList(_stModuleName, _bFromEnd);
+}
+}
diff --git a/scilab/modules/symbol/src/cpp/table.cpp b/scilab/modules/symbol/src/cpp/table.cpp
deleted file mode 100644 (file)
index e99b29d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-*  Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS
-*
-*  This file must be used under the terms of the CeCILL.
-*  This source file is licensed as described in the file COPYING, which
-*  you should have received as part of this distribution.  The terms
-*  are also available at
-*  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#include "table.hxx"
-
-namespace symbol
-{
-void Table::print (std::wostream& ostr) const
-{
-    std::list<Scope*>::const_iterator it_list_scope;
-    std::list<Scope*>::size_type       i;
-
-    for (i = (*this).l_scope.size() - 1, it_list_scope = (*this).l_scope.begin() ; it_list_scope != (*this).l_scope.end(); --i, ++it_list_scope)
-    {
-        ostr << L"Scope level: " << i << std::endl;
-        ostr << *(*it_list_scope);
-    }
-}
-}
-
diff --git a/scilab/modules/symbol/src/cpp/test-context.cpp b/scilab/modules/symbol/src/cpp/test-context.cpp
deleted file mode 100644 (file)
index 5776fa9..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-*  Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS
-*
-*  This file must be used under the terms of the CeCILL.
-*  This source file is licensed as described in the file COPYING, which
-*  you should have received as part of this distribution.  The terms
-*  are also available at
-*  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#include "symbol.hxx"
-#include "heap.hxx"
-
-using symbol::Symbol;
-using symbol::Heap;
-
-static int context_test()
-{
-    return 0;
-}
-
-int main(void)
-{
-    context_test();
-    return 0;
-}
diff --git a/scilab/modules/symbol/src/cpp/test-heap.cpp b/scilab/modules/symbol/src/cpp/test-heap.cpp
deleted file mode 100644 (file)
index 72baf0d..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- *  Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
- *  Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS
- *
- *  This file must be used under the terms of the CeCILL.
- *  This source file is licensed as described in the file COPYING, which
- *  you should have received as part of this distribution.  The terms
- *  are also available at
- *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include <iostream>
-#include <assert.h>
-#include <types.hxx>
-#include <int.hxx>
-#include <string.hxx>
-#include <symbol.hxx>
-#include <heap.hxx>
-
-using namespace types;
-
-using symbol::Symbol;
-using symbol::Heap;
-
-
-int heap_test()
-{
-    int *piVal         = NULL;
-    int *piJaune       = NULL;
-    double *pReal      = NULL;
-    double *pImg       = NULL;
-    bool *pb1                  = NULL;
-    float *pfReal      = NULL;
-    float *pfImg       = NULL;
-
-    Int IntVal(2, 2, &piVal);
-    Double dblI(2, 2, &pReal, &pImg);
-    Int IntJaune(2, 2, &piJaune);
-    Bool Bool1(2, 2, &pb1);
-    Float Float1(2, 2, &pfReal, &pfImg);
-
-    piVal[0]           = 2008;
-    piVal[1]           = 1492;
-    piVal[2]           = 1515;
-    piVal[3]           = 1789;
-
-    pb1[0]                     = true;
-    pb1[1]                     = false;
-    pb1[2]                     = false;
-    pb1[3]                     = true;
-
-    pReal[0]           = +1e-05;
-    pImg[0]                    = +1e20;
-    pReal[1]           = +1e-05;
-    pImg[1]                    = -1e20;
-    pReal[2]           = -1e-05;
-    pImg[2]                    = +1e20;
-    pReal[3]           = -1e-05;
-    pImg[3]                    = -1e20;
-
-    piJaune[0] = 51;
-    piJaune[1] = 1664;
-    piJaune[2] = 1664;
-    piJaune[3] = 51;
-
-    pfReal[0]          = 0.1f;
-    pfReal[1]          = -0.2f;
-    pfReal[2]          = 0.3f;
-    pfReal[3]          = -0.4f;
-
-    pfImg[0]           = -0.9f;
-    pfImg[1]           = 0.8f;
-    pfImg[2]           = -0.7f;
-    pfImg[3]           = 0.6f;
-
-    String szvalue("value");
-
-    String szjaune(2, 2);
-    szjaune.string_set(0, 0, "jaune");
-    szjaune.string_set(0, 1, "bleu");
-    szjaune.string_set(1, 0, "rouge");
-    szjaune.string_set(1, 1, "vert");
-
-    Heap tas;
-    Symbol foo("foo");
-    Symbol pourcentI("%i");
-    Symbol booltest("boobool");
-    Symbol floattest("floattest");
-    Symbol bar("bar");
-    Symbol scicos("scicos");
-
-    // foo = 1664
-    tas.put(foo, IntVal);
-    // bar2 = "value"
-    tas.put(bar, szvalue);
-    // %i = "%i"
-    tas.put(pourcentI, dblI);
-    // floattest = "[x.x]"
-    tas.put(floattest, Float1);
-
-    // scicos::scicos = 51
-    tas.put("scicos", scicos, IntJaune);
-    // scicos::foo = 51
-    tas.put("scicos", foo, szjaune);
-    // scicos::boobool = "t,f,f,t"
-    tas.put("scicos", booltest, Bool1);
-
-    std::cout << "-----------------" << std::endl;
-    std::cout << " Heap Overview :" << std::endl;
-    std::cout << "-----------------" << std::endl;
-    std::cout << tas;
-    std::cout << "-----------------" << std::endl;
-
-    assert(tas.get(foo) == &IntVal);
-    assert(tas.get(bar) == &szvalue);
-    assert(tas.get("scicos", scicos) == &IntJaune);
-    assert(tas.get("scicos", foo) == &szjaune);
-    assert(tas.get("scicos", bar) == NULL);
-
-    return 0;
-}
-
-int main(void)
-{
-    heap_test();
-    return 0;
-}
diff --git a/scilab/modules/symbol/src/cpp/test-scope.cpp b/scilab/modules/symbol/src/cpp/test-scope.cpp
deleted file mode 100644 (file)
index 62562fb..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *  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
- *
- */
-
-#include <iostream>
-#include <assert.h>
-#include "symbol.hxx"
-#include "scope.hxx"
-#include "types.hxx"
-#include "int.hxx"
-
-using namespace types;
-using symbol::Symbol;
-using symbol::Scope;
-
-static int scope_test(void)
-{
-
-    Symbol scilab("scilab");
-    Symbol scicos("scicos");
-
-    Scope env;
-    Scope scicos_ns ("SCICOS");
-
-    int *piVal0                = NULL;
-    int *piJaune               = NULL;
-
-    Int zero(1, 1, &piVal0);
-    piVal0[0] = 0;
-
-    Int jaune(1, 1, &piJaune);
-    piJaune[0] = 51;
-
-    env.put(scicos, zero);
-    env.put(scilab, jaune);
-    scicos_ns.put(scicos, jaune);
-    scicos_ns.put(scilab, zero);
-
-    assert(env.get(scilab) == &jaune);
-    assert(env.get(scicos) == &zero);
-    assert(scicos_ns.get(scilab) == &zero);
-    assert(scicos_ns.get(scicos) == &jaune);
-
-    std::cout << "----------------" << std::endl;
-    std::cout << "Scope ENV Overview :" << std::endl;
-    std::cout << "----------------" << std::endl;
-    std::cout << env;
-    std::cout << "----------------" << std::endl;
-    std::cout << std::endl;
-    std::cout << "----------------" << std::endl;
-    std::cout << "Scope SCICOS Overview :" << std::endl;
-    std::cout << "----------------" << std::endl;
-    std::cout << scicos_ns;
-    std::cout << "----------------" << std::endl;
-
-    return 0;
-}
-
-
-int main(void)
-{
-    scope_test();
-    return 0;
-}
diff --git a/scilab/modules/symbol/src/cpp/test-stack.cpp b/scilab/modules/symbol/src/cpp/test-stack.cpp
deleted file mode 100644 (file)
index 3bf4916..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-*  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
-*
-*/
-
-#include <iostream>
-#include <assert.h>
-#include "symbol.hxx"
-#include "stack.hxx"
-#include "types.hxx"
-#include "int.hxx"
-
-using symbol::Symbol;
-using symbol::Stack;
-using types::Int;
-
-
-void stack_dump(Stack *stack)
-{
-    std::cout << "----------------" << std::endl;
-    std::cout << "  Stack Dump :" << std::endl;
-    std::cout << "----------------" << std::endl;
-    std::cout << *stack;
-    std::cout << "----------------" << std::endl;
-    std::cout << std::endl;
-}
-
-static int stack_test(void)
-{
-    // Add "toto"
-    Symbol toto ("toto");
-    // Add "pouet"
-    Symbol pouet ("pouet");
-
-    Stack stack;
-
-    int *piVal1                = NULL;
-    int *piVal2                = NULL;
-    int *piVal11       = NULL;
-    int *piVal22       = NULL;
-    int *piVal111      = NULL;
-
-    Int i_1(1, 1, &piVal1);
-    piVal1[0] = 1;
-    Int i_2(1, 1, &piVal2);
-    piVal2[0] = 2;
-    Int i_11(1, 1, &piVal11);
-    piVal11[0] = 11;
-    Int i_22(1, 1, &piVal22);
-    piVal22[0] = 22;
-    Int i_111(1, 1, &piVal111);
-    piVal111[0] = 111;
-
-
-    /** /{ SCOPE env */
-    {
-        stack.scope_begin();
-        // toto = 1
-        stack.put(toto, i_1);
-        // pouet = 2
-        stack.put(pouet, i_2);
-
-        stack_dump(&stack);
-        assert(stack.get(toto) == &i_1);
-        assert(stack.get(pouet) == &i_2);
-
-        /** /{ SCOPE env.1 */
-        {
-            stack.scope_begin();
-            // toto = 11
-            stack.put(toto, i_11);
-            // pouet = 22
-            stack.put(pouet, i_22);
-
-            stack_dump(&stack);
-            assert(stack.get(toto) == &i_11);
-            assert(stack.get(pouet) == &i_22);
-
-            /** /{ SCOPE env.1.1 */
-            {
-                stack.scope_begin();
-                // pouet = 111
-                stack.put(pouet, i_111);
-
-                stack_dump(&stack);
-                assert(stack.get(pouet) == &i_111);
-                assert(stack.get(toto) == &i_11);
-                stack.scope_end();
-            }
-            /** /} ! env.1.1 */
-            assert(stack.get(toto) == &i_11);
-            assert(stack.get(pouet) == &i_22);
-            stack.scope_end ();
-        }
-        /** /} ! env.1 */
-        assert(stack.get(toto) == &i_1);
-        assert(stack.get(pouet) == &i_2);
-        stack.scope_end ();
-    }
-    /** /} ! env */
-    return 0;
-}
-
-int main(void)
-{
-    stack_test();
-    return 0;
-}
diff --git a/scilab/modules/symbol/src/cpp/test-symbol.cpp b/scilab/modules/symbol/src/cpp/test-symbol.cpp
deleted file mode 100644 (file)
index 4f9fa5f..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- *  Copyright (C) 2007-2008 - DIGITEO - 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
- *
- */
-
-#include <iostream>
-#include <assert.h>
-#include "export_symbol.h"
-#include "symbol.hxx"
-
-#define __MAX_CLONE_NUMBER__   2
-
-using symbol::Symbol;
-using symbol::symbols_t;
-
-static int symbol_test()
-{
-
-    Symbol foo(L"foo");
-    Symbol foo2(L"foo");
-    Symbol foo3(L"Foo");
-    Symbol *foo4 = new Symbol(L"Foo");
-    Symbol bar(L"bar");
-    Symbol scicos(L"scicos");
-    symbols_t clone;
-    int i = 0;
-    symbols_t::iterator it;
-
-    for (i = 0 ; i < __MAX_CLONE_NUMBER__ ; ++i)
-    {
-        clone.push_front(new Symbol(L"clone"));
-    }
-    for (it = clone.begin() ; it != clone.end() ; ++it)
-    {
-        assert((*it)->name_get() == L"clone");
-    }
-
-    assert(foo.name_get() == L"foo");
-    assert(foo2.name_get() == L"foo");
-    assert(foo3.name_get() == L"Foo");
-    assert(foo4->name_get() == L"Foo");
-    assert(bar.name_get() == L"bar");
-    assert(scicos.name_get() == L"scicos");
-
-    assert(foo == foo2);
-    assert(foo != foo3);
-    assert(*foo4 == foo3);
-
-    /* foo, Foo, bar, scicos, clone */
-    assert(Symbol::map_size() == 5);
-
-
-    std::wcout << L"Symbol Overview :" << std::endl;
-    std::wcout << L"-----------------" <<  std::endl;
-    std::wcout << L"Size : " << Symbol::map_size() << std::endl;
-    std::wcout << L"-----------------" <<  std::endl;
-    std::wcout << foo << std::endl;
-    std::wcout << foo2 << std::endl;
-    std::wcout << foo3 << std::endl;
-    std::wcout << *foo4 << std::endl;
-    std::wcout << bar << std::endl;
-    std::wcout << scicos << std::endl;
-    std::wcout << **(clone.begin()) << std::endl;
-    std::wcout << L"----------------" << std::endl;
-    return 0;
-}
-
-int test()
-{
-    Symbol foo(L"foo");
-    Symbol bar(L"foo");
-    std::wcout << &foo << std::endl;
-    std::wcout << &bar << std::endl;
-}
-
-int main(void)
-{
-    symbol_test();
-    //    test();
-    return 0;
-}
diff --git a/scilab/modules/symbol/src/cpp/variables.cpp b/scilab/modules/symbol/src/cpp/variables.cpp
new file mode 100644 (file)
index 0000000..56d0796
--- /dev/null
@@ -0,0 +1,449 @@
+/*
+*  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;
+                }
+
+                (*itBox)->m_pIT->DecreaseRef();
+                if ((*itBox)->m_pIT->isDeletable())
+                {
+                    delete (*itBox)->m_pIT;
+                }
+
+
+                //increase ref
+                _iT.IncreaseRef();
+                //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())
+        {
+            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<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;
+            //clear existing local var
+            pBox->m_pIT->DecreaseRef();
+            if (pBox->m_pIT->isDeletable())
+            {
+                delete pBox->m_pIT;
+                pBox->m_pIT = NULL;
+            }
+        }
+        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();
+        for (; itBox != pLBox->end() ; itBox++)
+        {
+            VarBox* pBox = (*itBox);
+            if (pBox->m_bGlobal == true && pBox->m_bGlobalVisible == true)
+            {
+                pLBox->erase(itBox);
+                //itBox iterator becomes invalid, reinit it
+                itBox = pLBox->begin();
+                if (itBox == pLBox->end())
+                {
+                    break;
+                }
+            }
+        }
+
+        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 6b2ac72..4fb5c68 100644 (file)
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="src\cpp\context.cpp" />
+    <ClCompile Include="src\cpp\scope.cpp" />
     <ClCompile Include="src\cpp\symbol.cpp" />
-    <ClCompile Include="src\cpp\table.cpp" />
+    <ClCompile Include="src\cpp\variables.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\addGatewayInContext.h" />
     <ClInclude Include="includes\context.hxx" />
     <ClInclude Include="includes\export_symbol.h" />
-    <ClInclude Include="includes\heap.hxx" />
-    <ClInclude Include="includes\scope.hxx" />
-    <ClInclude Include="includes\stack.hxx" />
     <ClInclude Include="includes\symbol.hxx" />
-    <ClInclude Include="includes\table.hxx" />
+    <ClInclude Include="includes\variables.hxx" />
   </ItemGroup>
   <ItemGroup>
     <Library Include="..\..\bin\blasplus.lib" />
index 9d0689b..949c37b 100644 (file)
     <ClCompile Include="src\cpp\symbol.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="src\cpp\table.cpp">
+    <ClCompile Include="src\cpp\variables.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\scope.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
     <ClInclude Include="includes\export_symbol.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="includes\heap.hxx">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="includes\scope.hxx">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="includes\stack.hxx">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="includes\symbol.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="includes\table.hxx">
+    <ClInclude Include="includes\addGatewayInContext.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="includes\addGatewayInContext.h">
+    <ClInclude Include="includes\variables.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
   </ItemGroup>
index 1702f5f..781b4b4 100644 (file)
@@ -19,6 +19,7 @@
 
 extern "C"
 {
+#include "MALLOC.h"
 #include "os_strdup.h"
 #include "os_wcsdup.h"
 #include "charEncoding.h"
index c7d98c5..1ca4e10 100644 (file)
@@ -19,6 +19,7 @@
 
 extern "C"
 {
+#include "MALLOC.h"
 #include "sci_home.h"
 #include "os_strdup.h"
 #include "os_wcsdup.h"
index 4c1a43f..049850b 100644 (file)
@@ -20,6 +20,7 @@
 
 extern "C"
 {
+#include "MALLOC.h"
 #include "sci_path.h"
 #include "os_wcsdup.h"
 #include "charEncoding.h"
index 44b0621..74fed98 100644 (file)
@@ -19,6 +19,7 @@
 
 extern "C"
 {
+#include "MALLOC.h"
 #ifdef _MSC_VER
 #include <process.h>
 #else