Analysis: move code 81/17181/3
Calixte DENIZET [Wed, 9 Sep 2015 08:47:08 +0000 (10:47 +0200)]
Change-Id: I61bdcf24633f4a30c5245ed5286f35c4cb6c4042

16 files changed:
scilab/modules/ast/Makefile.am
scilab/modules/ast/Makefile.in
scilab/modules/ast/ast.vcxproj
scilab/modules/ast/ast.vcxproj.filters
scilab/modules/ast/includes/analysis/AnalysisVisitor.hxx
scilab/modules/ast/includes/exps/vardec.hxx
scilab/modules/ast/src/cpp/analysis/AnalysisVisitor.cpp
scilab/modules/ast/src/cpp/analysis/SizeAnalyzer.cpp
scilab/modules/ast/src/cpp/analysis/TypeofAnalyzer.cpp
scilab/modules/ast/src/cpp/analysis/VisitCallExp.cpp [new file with mode: 0644]
scilab/modules/ast/src/cpp/analysis/VisitDollarVar.cpp [new file with mode: 0644]
scilab/modules/ast/src/cpp/analysis/VisitForExp.cpp [new file with mode: 0644]
scilab/modules/ast/src/cpp/analysis/VisitSeqExp.cpp [new file with mode: 0644]
scilab/modules/ast/src/cpp/analysis/VisitSimpleVar.cpp [new file with mode: 0644]
scilab/modules/ast/src/cpp/analysis/VisitTypeExps.cpp [new file with mode: 0644]
scilab/modules/ast/src/cpp/analysis/VisitVarDec.cpp [new file with mode: 0644]

index 9358afd..c454b02 100644 (file)
@@ -155,87 +155,94 @@ src/cpp/analysis/VisitOpExp.cpp \
 src/cpp/analysis/VisitSelectExp.cpp \
 src/cpp/analysis/VisitAssignExp.cpp \
 src/cpp/analysis/VisitIfExp.cpp \
+src/cpp/analysis/VisitForExp.cpp \
+src/cpp/analysis/VisitCallExp.cpp \
+src/cpp/analysis/VisitSeqExp.cpp \
+src/cpp/analysis/VisitTypeExps.cpp \
+src/cpp/analysis/VisitSimpleVar.cpp \
+src/cpp/analysis/VisitDollarVar.cpp \
+src/cpp/analysis/VisitVarDec.cpp \
 src/cpp/analysis/XBlock.cpp \
-src/cpp/analysis/check_____dotpower____.cpp\
-src/cpp/analysis/check_rand.cpp\
-src/cpp/analysis/check_____ge____.cpp\
-src/cpp/analysis/check_____or____.cpp\
-src/cpp/analysis/check_____power____.cpp\
-src/cpp/analysis/check_____not____.cpp\
-src/cpp/analysis/check_isreal.cpp\
-src/cpp/analysis/check_____transp____.cpp\
-src/cpp/analysis/check_abs.cpp\
-src/cpp/analysis/check_cosh.cpp\
-src/cpp/analysis/check_typeof.cpp\
-src/cpp/analysis/check_int16.cpp\
-src/cpp/analysis/check_iconvert.cpp\
-src/cpp/analysis/check_gettext.cpp\
-src/cpp/analysis/check_____neq____.cpp\
-src/cpp/analysis/check_____and____.cpp\
-src/cpp/analysis/check_tan.cpp\
-src/cpp/analysis/check_cumsum.cpp\
-src/cpp/analysis/check_size.cpp\
-src/cpp/analysis/check_____andand____.cpp\
-src/cpp/analysis/check_asin.cpp\
-src/cpp/analysis/check_____dottransp____.cpp\
-src/cpp/analysis/check_or.cpp\
-src/cpp/analysis/check_____eq____.cpp\
-src/cpp/analysis/check_log.cpp\
-src/cpp/analysis/check_floor.cpp\
-src/cpp/analysis/check_int.cpp\
-src/cpp/analysis/check_fix.cpp\
-src/cpp/analysis/check_sqrt.cpp\
-src/cpp/analysis/check_uint16.cpp\
-src/cpp/analysis/check_____le____.cpp\
-src/cpp/analysis/check_zeros.cpp\
-src/cpp/analysis/check_ls.cpp\
-src/cpp/analysis/check_max.cpp\
-src/cpp/analysis/check_uint32.cpp\
-src/cpp/analysis/check_int64.cpp\
-src/cpp/analysis/check_prod.cpp\
-src/cpp/analysis/check_type.cpp\
-src/cpp/analysis/check_sin.cpp\
-src/cpp/analysis/check_round.cpp\
-src/cpp/analysis/check_____krontimes____.cpp\
-src/cpp/analysis/check_int32.cpp\
-src/cpp/analysis/check_____gt____.cpp\
-src/cpp/analysis/check_inttype.cpp\
-src/cpp/analysis/check_exp.cpp\
-src/cpp/analysis/check_atan.cpp\
-src/cpp/analysis/check_____dotrdiv____.cpp\
-src/cpp/analysis/check_imag.cpp\
-src/cpp/analysis/check_uint8.cpp\
-src/cpp/analysis/check_ceil.cpp\
-src/cpp/analysis/check_uint64.cpp\
-src/cpp/analysis/check_____lt____.cpp\
-src/cpp/analysis/check_sinm.cpp\
-src/cpp/analysis/check_isinf.cpp\
-src/cpp/analysis/check_____sub____.cpp\
-src/cpp/analysis/check_sinh.cpp\
-src/cpp/analysis/check_toc.cpp\
-src/cpp/analysis/check_isscalar.cpp\
-src/cpp/analysis/check_sign.cpp\
-src/cpp/analysis/check_int8.cpp\
-src/cpp/analysis/check_____rdivide____.cpp\
-src/cpp/analysis/check_matrix.cpp\
-src/cpp/analysis/check_____oror____.cpp\
-src/cpp/analysis/check_cos.cpp\
-src/cpp/analysis/check_and.cpp\
-src/cpp/analysis/check_____unaryminus____.cpp\
-src/cpp/analysis/check_tanh.cpp\
-src/cpp/analysis/check_____add____.cpp\
-src/cpp/analysis/check_isnan.cpp\
-src/cpp/analysis/check_imult.cpp\
-src/cpp/analysis/check_____times____.cpp\
-src/cpp/analysis/check_argn.cpp\
-src/cpp/analysis/check_cumprod.cpp\
-src/cpp/analysis/check_erf.cpp\
-src/cpp/analysis/check_ones.cpp\
-src/cpp/analysis/check_erfc.cpp\
-src/cpp/analysis/check_min.cpp\
-src/cpp/analysis/check_sum.cpp\
-src/cpp/analysis/check_____ldivide____.cpp\
-src/cpp/analysis/check_acos.cpp\
+src/cpp/analysis/check_____dotpower____.cpp \
+src/cpp/analysis/check_rand.cpp \
+src/cpp/analysis/check_____ge____.cpp \
+src/cpp/analysis/check_____or____.cpp \
+src/cpp/analysis/check_____power____.cpp \
+src/cpp/analysis/check_____not____.cpp \
+src/cpp/analysis/check_isreal.cpp \
+src/cpp/analysis/check_____transp____.cpp \
+src/cpp/analysis/check_abs.cpp \
+src/cpp/analysis/check_cosh.cpp \
+src/cpp/analysis/check_typeof.cpp \
+src/cpp/analysis/check_int16.cpp \
+src/cpp/analysis/check_iconvert.cpp \
+src/cpp/analysis/check_gettext.cpp \
+src/cpp/analysis/check_____neq____.cpp \
+src/cpp/analysis/check_____and____.cpp \
+src/cpp/analysis/check_tan.cpp \
+src/cpp/analysis/check_cumsum.cpp \
+src/cpp/analysis/check_size.cpp \
+src/cpp/analysis/check_____andand____.cpp \
+src/cpp/analysis/check_asin.cpp \
+src/cpp/analysis/check_____dottransp____.cpp \
+src/cpp/analysis/check_or.cpp \
+src/cpp/analysis/check_____eq____.cpp \
+src/cpp/analysis/check_log.cpp \
+src/cpp/analysis/check_floor.cpp \
+src/cpp/analysis/check_int.cpp \
+src/cpp/analysis/check_fix.cpp \
+src/cpp/analysis/check_sqrt.cpp \
+src/cpp/analysis/check_uint16.cpp \
+src/cpp/analysis/check_____le____.cpp \
+src/cpp/analysis/check_zeros.cpp \
+src/cpp/analysis/check_ls.cpp \
+src/cpp/analysis/check_max.cpp \
+src/cpp/analysis/check_uint32.cpp \
+src/cpp/analysis/check_int64.cpp \
+src/cpp/analysis/check_prod.cpp \
+src/cpp/analysis/check_type.cpp \
+src/cpp/analysis/check_sin.cpp \
+src/cpp/analysis/check_round.cpp \
+src/cpp/analysis/check_____krontimes____.cpp \
+src/cpp/analysis/check_int32.cpp \
+src/cpp/analysis/check_____gt____.cpp \
+src/cpp/analysis/check_inttype.cpp \
+src/cpp/analysis/check_exp.cpp \
+src/cpp/analysis/check_atan.cpp \
+src/cpp/analysis/check_____dotrdiv____.cpp \
+src/cpp/analysis/check_imag.cpp \
+src/cpp/analysis/check_uint8.cpp \
+src/cpp/analysis/check_ceil.cpp \
+src/cpp/analysis/check_uint64.cpp \
+src/cpp/analysis/check_____lt____.cpp \
+src/cpp/analysis/check_sinm.cpp \
+src/cpp/analysis/check_isinf.cpp \
+src/cpp/analysis/check_____sub____.cpp \
+src/cpp/analysis/check_sinh.cpp \
+src/cpp/analysis/check_toc.cpp \
+src/cpp/analysis/check_isscalar.cpp \
+src/cpp/analysis/check_sign.cpp \
+src/cpp/analysis/check_int8.cpp \
+src/cpp/analysis/check_____rdivide____.cpp \
+src/cpp/analysis/check_matrix.cpp \
+src/cpp/analysis/check_____oror____.cpp \
+src/cpp/analysis/check_cos.cpp \
+src/cpp/analysis/check_and.cpp \
+src/cpp/analysis/check_____unaryminus____.cpp \
+src/cpp/analysis/check_tanh.cpp \
+src/cpp/analysis/check_____add____.cpp \
+src/cpp/analysis/check_isnan.cpp \
+src/cpp/analysis/check_imult.cpp \
+src/cpp/analysis/check_____times____.cpp \
+src/cpp/analysis/check_argn.cpp \
+src/cpp/analysis/check_cumprod.cpp \
+src/cpp/analysis/check_erf.cpp \
+src/cpp/analysis/check_ones.cpp \
+src/cpp/analysis/check_erfc.cpp \
+src/cpp/analysis/check_min.cpp \
+src/cpp/analysis/check_sum.cpp \
+src/cpp/analysis/check_____ldivide____.cpp \
+src/cpp/analysis/check_acos.cpp \
 src/cpp/analysis/check_____dottimes____.cpp
 
 if ENABLE_DEBUG
index bc8700b..989bd6c 100644 (file)
@@ -281,7 +281,14 @@ am__libsciast_la_SOURCES_DIST = src/c/operations/doublecomplex.c \
        src/cpp/analysis/VisitOpExp.cpp \
        src/cpp/analysis/VisitSelectExp.cpp \
        src/cpp/analysis/VisitAssignExp.cpp \
-       src/cpp/analysis/VisitIfExp.cpp src/cpp/analysis/XBlock.cpp \
+       src/cpp/analysis/VisitIfExp.cpp \
+       src/cpp/analysis/VisitForExp.cpp \
+       src/cpp/analysis/VisitCallExp.cpp \
+       src/cpp/analysis/VisitSeqExp.cpp \
+       src/cpp/analysis/VisitTypeExps.cpp \
+       src/cpp/analysis/VisitSimpleVar.cpp \
+       src/cpp/analysis/VisitDollarVar.cpp \
+       src/cpp/analysis/VisitVarDec.cpp src/cpp/analysis/XBlock.cpp \
        src/cpp/analysis/check_____dotpower____.cpp \
        src/cpp/analysis/check_rand.cpp \
        src/cpp/analysis/check_____ge____.cpp \
@@ -500,6 +507,13 @@ am_libsciast_la_OBJECTS =  \
        src/cpp/analysis/libsciast_la-VisitSelectExp.lo \
        src/cpp/analysis/libsciast_la-VisitAssignExp.lo \
        src/cpp/analysis/libsciast_la-VisitIfExp.lo \
+       src/cpp/analysis/libsciast_la-VisitForExp.lo \
+       src/cpp/analysis/libsciast_la-VisitCallExp.lo \
+       src/cpp/analysis/libsciast_la-VisitSeqExp.lo \
+       src/cpp/analysis/libsciast_la-VisitTypeExps.lo \
+       src/cpp/analysis/libsciast_la-VisitSimpleVar.lo \
+       src/cpp/analysis/libsciast_la-VisitDollarVar.lo \
+       src/cpp/analysis/libsciast_la-VisitVarDec.lo \
        src/cpp/analysis/libsciast_la-XBlock.lo \
        src/cpp/analysis/libsciast_la-check_____dotpower____.lo \
        src/cpp/analysis/libsciast_la-check_rand.lo \
@@ -1068,7 +1082,14 @@ libsciast_la_SOURCES = src/c/operations/doublecomplex.c \
        src/cpp/analysis/VisitOpExp.cpp \
        src/cpp/analysis/VisitSelectExp.cpp \
        src/cpp/analysis/VisitAssignExp.cpp \
-       src/cpp/analysis/VisitIfExp.cpp src/cpp/analysis/XBlock.cpp \
+       src/cpp/analysis/VisitIfExp.cpp \
+       src/cpp/analysis/VisitForExp.cpp \
+       src/cpp/analysis/VisitCallExp.cpp \
+       src/cpp/analysis/VisitSeqExp.cpp \
+       src/cpp/analysis/VisitTypeExps.cpp \
+       src/cpp/analysis/VisitSimpleVar.cpp \
+       src/cpp/analysis/VisitDollarVar.cpp \
+       src/cpp/analysis/VisitVarDec.cpp src/cpp/analysis/XBlock.cpp \
        src/cpp/analysis/check_____dotpower____.cpp \
        src/cpp/analysis/check_rand.cpp \
        src/cpp/analysis/check_____ge____.cpp \
@@ -1974,6 +1995,27 @@ src/cpp/analysis/libsciast_la-VisitAssignExp.lo:  \
 src/cpp/analysis/libsciast_la-VisitIfExp.lo:  \
        src/cpp/analysis/$(am__dirstamp) \
        src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
+src/cpp/analysis/libsciast_la-VisitForExp.lo:  \
+       src/cpp/analysis/$(am__dirstamp) \
+       src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
+src/cpp/analysis/libsciast_la-VisitCallExp.lo:  \
+       src/cpp/analysis/$(am__dirstamp) \
+       src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
+src/cpp/analysis/libsciast_la-VisitSeqExp.lo:  \
+       src/cpp/analysis/$(am__dirstamp) \
+       src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
+src/cpp/analysis/libsciast_la-VisitTypeExps.lo:  \
+       src/cpp/analysis/$(am__dirstamp) \
+       src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
+src/cpp/analysis/libsciast_la-VisitSimpleVar.lo:  \
+       src/cpp/analysis/$(am__dirstamp) \
+       src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
+src/cpp/analysis/libsciast_la-VisitDollarVar.lo:  \
+       src/cpp/analysis/$(am__dirstamp) \
+       src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
+src/cpp/analysis/libsciast_la-VisitVarDec.lo:  \
+       src/cpp/analysis/$(am__dirstamp) \
+       src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
 src/cpp/analysis/libsciast_la-XBlock.lo:  \
        src/cpp/analysis/$(am__dirstamp) \
        src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
@@ -2302,11 +2344,18 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-TypeofAnalyzer.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VarExp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitAssignExp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitCallExp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitDollarVar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitForExp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitIfExp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitListExp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitMatrixExp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitOpExp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitSelectExp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitSeqExp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitSimpleVar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitTypeExps.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitVarDec.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-XBlock.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-check_____add____.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-check_____and____.Plo@am__quote@
@@ -3509,6 +3558,55 @@ src/cpp/analysis/libsciast_la-VisitIfExp.lo: src/cpp/analysis/VisitIfExp.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-VisitIfExp.lo `test -f 'src/cpp/analysis/VisitIfExp.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitIfExp.cpp
 
+src/cpp/analysis/libsciast_la-VisitForExp.lo: src/cpp/analysis/VisitForExp.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-VisitForExp.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitForExp.Tpo -c -o src/cpp/analysis/libsciast_la-VisitForExp.lo `test -f 'src/cpp/analysis/VisitForExp.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitForExp.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitForExp.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitForExp.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/analysis/VisitForExp.cpp' object='src/cpp/analysis/libsciast_la-VisitForExp.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-VisitForExp.lo `test -f 'src/cpp/analysis/VisitForExp.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitForExp.cpp
+
+src/cpp/analysis/libsciast_la-VisitCallExp.lo: src/cpp/analysis/VisitCallExp.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-VisitCallExp.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitCallExp.Tpo -c -o src/cpp/analysis/libsciast_la-VisitCallExp.lo `test -f 'src/cpp/analysis/VisitCallExp.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitCallExp.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitCallExp.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitCallExp.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/analysis/VisitCallExp.cpp' object='src/cpp/analysis/libsciast_la-VisitCallExp.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-VisitCallExp.lo `test -f 'src/cpp/analysis/VisitCallExp.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitCallExp.cpp
+
+src/cpp/analysis/libsciast_la-VisitSeqExp.lo: src/cpp/analysis/VisitSeqExp.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-VisitSeqExp.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitSeqExp.Tpo -c -o src/cpp/analysis/libsciast_la-VisitSeqExp.lo `test -f 'src/cpp/analysis/VisitSeqExp.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitSeqExp.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitSeqExp.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitSeqExp.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/analysis/VisitSeqExp.cpp' object='src/cpp/analysis/libsciast_la-VisitSeqExp.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-VisitSeqExp.lo `test -f 'src/cpp/analysis/VisitSeqExp.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitSeqExp.cpp
+
+src/cpp/analysis/libsciast_la-VisitTypeExps.lo: src/cpp/analysis/VisitTypeExps.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-VisitTypeExps.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitTypeExps.Tpo -c -o src/cpp/analysis/libsciast_la-VisitTypeExps.lo `test -f 'src/cpp/analysis/VisitTypeExps.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitTypeExps.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitTypeExps.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitTypeExps.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/analysis/VisitTypeExps.cpp' object='src/cpp/analysis/libsciast_la-VisitTypeExps.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-VisitTypeExps.lo `test -f 'src/cpp/analysis/VisitTypeExps.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitTypeExps.cpp
+
+src/cpp/analysis/libsciast_la-VisitSimpleVar.lo: src/cpp/analysis/VisitSimpleVar.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-VisitSimpleVar.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitSimpleVar.Tpo -c -o src/cpp/analysis/libsciast_la-VisitSimpleVar.lo `test -f 'src/cpp/analysis/VisitSimpleVar.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitSimpleVar.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitSimpleVar.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitSimpleVar.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/analysis/VisitSimpleVar.cpp' object='src/cpp/analysis/libsciast_la-VisitSimpleVar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-VisitSimpleVar.lo `test -f 'src/cpp/analysis/VisitSimpleVar.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitSimpleVar.cpp
+
+src/cpp/analysis/libsciast_la-VisitDollarVar.lo: src/cpp/analysis/VisitDollarVar.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-VisitDollarVar.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitDollarVar.Tpo -c -o src/cpp/analysis/libsciast_la-VisitDollarVar.lo `test -f 'src/cpp/analysis/VisitDollarVar.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitDollarVar.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitDollarVar.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitDollarVar.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/analysis/VisitDollarVar.cpp' object='src/cpp/analysis/libsciast_la-VisitDollarVar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-VisitDollarVar.lo `test -f 'src/cpp/analysis/VisitDollarVar.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitDollarVar.cpp
+
+src/cpp/analysis/libsciast_la-VisitVarDec.lo: src/cpp/analysis/VisitVarDec.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-VisitVarDec.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitVarDec.Tpo -c -o src/cpp/analysis/libsciast_la-VisitVarDec.lo `test -f 'src/cpp/analysis/VisitVarDec.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitVarDec.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitVarDec.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-VisitVarDec.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/analysis/VisitVarDec.cpp' object='src/cpp/analysis/libsciast_la-VisitVarDec.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-VisitVarDec.lo `test -f 'src/cpp/analysis/VisitVarDec.cpp' || echo '$(srcdir)/'`src/cpp/analysis/VisitVarDec.cpp
+
 src/cpp/analysis/libsciast_la-XBlock.lo: src/cpp/analysis/XBlock.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-XBlock.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-XBlock.Tpo -c -o src/cpp/analysis/libsciast_la-XBlock.lo `test -f 'src/cpp/analysis/XBlock.cpp' || echo '$(srcdir)/'`src/cpp/analysis/XBlock.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-XBlock.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-XBlock.Plo
index f12d04a..e80e6cc 100644 (file)
@@ -622,11 +622,18 @@ lib /DEF:"$(ProjectDir)string_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClCompile Include="src\cpp\analysis\TypeofAnalyzer.cpp" />
     <ClCompile Include="src\cpp\analysis\VarExp.cpp" />
     <ClCompile Include="src\cpp\analysis\VisitAssignExp.cpp" />
+    <ClCompile Include="src\cpp\analysis\VisitCallExp.cpp" />
+    <ClCompile Include="src\cpp\analysis\VisitDollarVar.cpp" />
+    <ClCompile Include="src\cpp\analysis\VisitForExp.cpp" />
     <ClCompile Include="src\cpp\analysis\VisitIfExp.cpp" />
     <ClCompile Include="src\cpp\analysis\VisitListExp.cpp" />
     <ClCompile Include="src\cpp\analysis\VisitMatrixExp.cpp" />
     <ClCompile Include="src\cpp\analysis\VisitOpExp.cpp" />
     <ClCompile Include="src\cpp\analysis\VisitSelectExp.cpp" />
+    <ClCompile Include="src\cpp\analysis\VisitSeqExp.cpp" />
+    <ClCompile Include="src\cpp\analysis\VisitSimpleVar.cpp" />
+    <ClCompile Include="src\cpp\analysis\VisitTypeExps.cpp" />
+    <ClCompile Include="src\cpp\analysis\VisitVarDec.cpp" />
     <ClCompile Include="src\cpp\analysis\XBlock.cpp" />
     <ClCompile Include="src\cpp\ast\debugvisitor.cpp" />
     <ClCompile Include="src\cpp\ast\expHistory.cpp" />
index bdd9bca..d87d176 100644 (file)
     <ClCompile Include="src\cpp\types\internal.cpp">
       <Filter>Source Files\types</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\analysis\VisitCallExp.cpp">
+      <Filter>Source Files\analysis</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\analysis\VisitDollarVar.cpp">
+      <Filter>Source Files\analysis</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\analysis\VisitForExp.cpp">
+      <Filter>Source Files\analysis</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\analysis\VisitSeqExp.cpp">
+      <Filter>Source Files\analysis</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\analysis\VisitSimpleVar.cpp">
+      <Filter>Source Files\analysis</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\analysis\VisitTypeExps.cpp">
+      <Filter>Source Files\analysis</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\analysis\VisitVarDec.cpp">
+      <Filter>Source Files\analysis</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>
\ No newline at end of file
index 06c7b56..9cc319f 100644 (file)
@@ -136,20 +136,6 @@ public:
         return cv.getExec();
     }
 
-    // Only for debug use
-    inline void print_info()
-    {
-        stop_chrono();
-
-        //std::wcout << getGVN() << std::endl << std::endl; function z=foo(x,y);z=argn(2);endfunction;jit("x=123;y=456;t=foo(x,y)")
-        std::wcerr << L"Analysis: " << *static_cast<Chrono *>(this) << std::endl;
-        //std::wcout << temp << std::endl;
-
-        std::wcerr << dm << std::endl;
-
-        std::wcerr << std::endl;
-    }
-
     inline void finalize()
     {
         //dm.finalize(nullptr);
@@ -223,13 +209,12 @@ public:
         return dm.getInfo(sym);
     }
 
-    inline logging::Logger & getLogger()
-    {
-        return logger;
-    }
-
     bool analyzeIndices(TIType & type, ast::CallExp & ce);
 
+    // Only for debug use
+    void print_info();
+    logging::Logger & getLogger();
+
 private:
 
     bool getDimension(SymbolicDimension & dim, ast::Exp & arg, bool & safe, SymbolicDimension & out);
@@ -353,7 +338,6 @@ private:
         return resT;
     }
 
-
     bool operGVNValues(ast::OpExp & oe);
     bool operSymbolicRange(ast::OpExp & oe);
 
@@ -362,8 +346,6 @@ private:
     int getTmpIdForEWOp(const TIType & resT, const Result & LR, const Result & RR);
     void visitArguments(const std::wstring & name, const unsigned int lhs, const TIType & calltype, ast::CallExp & e, const ast::exps_t & args);
 
-
-
     void visit(ast::SelectExp & e);
     void visit(ast::ListExp & e);
     void visit(ast::MatrixExp & e);
@@ -372,6 +354,16 @@ private:
     void visit(ast::TransposeExp & e);
     void visit(ast::AssignExp & e);
     void visit(ast::IfExp & e);
+    void visit(ast::ForExp & e);
+    void visit(ast::CallExp & e);
+    void visit(ast::CallExp & e, const unsigned int lhs);
+    void visit(ast::SeqExp & e);
+    void visit(ast::DoubleExp & e);
+    void visit(ast::BoolExp & e);
+    void visit(ast::StringExp & e);
+    void visit(ast::SimpleVar & e);
+    void visit(ast::DollarVar & e);
+    void visit(ast::VarDec & e);
 
     void visit(ast::MatrixLineExp & e)
     {
@@ -386,26 +378,6 @@ private:
     void visit(ast::NilExp & e) { }
     void visit(ast::ColonVar & e) { }
 
-    void visit(ast::SimpleVar & e)
-    {
-        logger.log(L"SimpleVar", e.getSymbol().getName(), e.getLocation());
-        symbol::Symbol & sym = e.getSymbol();
-        Info & info = dm.read(sym, &e);
-        Result & res = e.getDecorator().setResult(info.type);
-        res.setConstant(info.getConstant());
-        res.setRange(info.getRange());
-        res.setMaxIndex(info.getMaxIndex());
-        setResult(res);
-    }
-
-    void visit(ast::DollarVar & e)
-    {
-        logger.log(L"DollarVar", e.getLocation());
-        Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::POLYNOMIAL, 1, 1));
-        res.getConstant() = getGVN().getValue(symbol::Symbol(L"$"));
-        setResult(res);
-    }
-
     void visit(ast::ArrayListVar & e)
     {
         logger.log(L"ArrayListVar", e.getLocation());
@@ -416,106 +388,6 @@ private:
         }
     }
 
-    void visit(ast::DoubleExp & e)
-    {
-        logger.log(L"DoubleExp", e.getLocation());
-        if (!e.getConstant())
-        {
-            e.accept(cv.getExec());
-            cv.getExec().setResult(nullptr);
-        }
-        types::Double * pDbl = static_cast<types::Double *>(e.getConstant());
-        if (pDbl->isComplex())
-        {
-            Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::COMPLEX, pDbl->getRows(), pDbl->getCols()));
-            res.getConstant() = e.getConstant();
-            setResult(res);
-        }
-        else
-        {
-            Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::DOUBLE, pDbl->getRows(), pDbl->getCols()));
-            res.getConstant() = e.getConstant();
-            setResult(res);
-        }
-    }
-
-    void visit(ast::BoolExp & e)
-    {
-        logger.log(L"BoolExp", e.getLocation());
-        if (!e.getConstant())
-        {
-            e.accept(cv.getExec());
-            cv.getExec().setResult(nullptr);
-        }
-        types::Bool * pBool = static_cast<types::Bool *>(e.getConstant());
-        Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::BOOLEAN, pBool->getRows(), pBool->getCols()));
-        res.getConstant() = e.getConstant();
-        setResult(res);
-    }
-
-    void visit(ast::StringExp & e)
-    {
-        logger.log(L"StringExp", e.getLocation());
-        if (!e.getConstant())
-        {
-            e.accept(cv.getExec());
-            cv.getExec().setResult(nullptr);
-        }
-        types::String * pStr = static_cast<types::String *>(e.getConstant());
-        Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::STRING, pStr->getRows(), pStr->getCols()));
-        res.getConstant() = e.getConstant();
-        setResult(res);
-    }
-
-    void visit(ast::CallExp & e, const unsigned int lhs)
-    {
-        // TODO: e.getName() is not always a simple var: foo(a)(b)
-        if (e.getName().isSimpleVar())
-        {
-            const ast::SimpleVar & var = static_cast<ast::SimpleVar &>(e.getName());
-            const symbol::Symbol & sym = var.getSymbol();
-            const std::wstring & name = sym.getName();
-            Info & info = getSymInfo(sym); // that put the sym in the current block !
-            Result & res = e.getName().getDecorator().setResult(info.type);
-            res.setConstant(info.getConstant());
-            res.setRange(info.getRange());
-            res.setMaxIndex(info.getMaxIndex());
-
-            logger.log(L"CallExp", e.getLocation(), name);
-
-            if (info.type.type == TIType::MACRO || info.type.type == TIType::MACROFILE || info.type.type == TIType::FUNCTION)
-            {
-                if (name == L"error")
-                {
-                    getDM().getCurrent()->setReturn(true);
-                }
-
-                // Special analysis cases: size, zeros, ones, ...
-                MapSymCall::iterator it = symscall.find(name);
-                if (it != symscall.end())
-                {
-                    if (getCM().checkGlobalConstant(sym) && it->second.get()->analyze(*this, lhs, e))
-                    {
-                        pushCall(e.getDecorator().getCall());
-                        return;
-                    }
-                }
-
-                visitArguments(name, lhs, info.type, e, e.getArgs());
-                pushCall(e.getDecorator().getCall());
-            }
-            else
-            {
-                analyzeIndices(info.type, e);
-            }
-        }
-    }
-
-    void visit(ast::CallExp & e)
-    {
-        visit(e, 1);
-    }
-
     void visit(ast::CellCallExp & e)
     {
         logger.log(L"CellCallExp", e.getLocation());
@@ -538,36 +410,6 @@ private:
         loops.pop();
     }
 
-    void visit(ast::ForExp & e)
-    {
-        logger.log(L"ForExp", e.getLocation());
-        loops.push(&e);
-
-        dm.addBlock(Block::LOOP, &e);
-        e.getVardec().accept(*this);
-        dm.addBlock(Block::NORMAL, &e.getBody());
-        e.getBody().accept(*this);
-
-        if (dm.requiresAnotherTrip())
-        {
-            std::wcerr << "Invalid forexp: types or refcount are not the same before and after the loop" << std::endl;
-
-            dm.finalizeBlock();
-            dm.addBlock(Block::NORMAL, &e.getBody());
-            e.getBody().accept(*this);
-
-            if (dm.requiresAnotherTrip())
-            {
-                std::wcerr << "Invalid forexp: types or refcount are not the same before and after the loop" << std::endl;
-            }
-        }
-
-        dm.finalizeBlock();
-        dm.finalizeBlock();
-
-        loops.pop();
-    }
-
     void visit(ast::BreakExp & e)
     {
         logger.log(L"BreakExp", e.getLocation());
@@ -618,48 +460,6 @@ private:
         visit(static_cast<ast::MatrixExp &>(e));
     }
 
-    void visit(ast::SeqExp & e)
-    {
-        logger.log(L"SeqExp", e.getLocation());
-        ast::exps_t::iterator i = e.getExps().begin();
-        ast::exps_t::iterator itEnd = e.getExps().end();
-        for (; i != itEnd; ++i)
-        {
-            ast::Exp* exp = *i;
-            if (exp->isCallExp())
-            {
-                visit(*static_cast<ast::CallExp *>(exp), /* LHS */ 0);
-            }
-            else if (exp->isBreakExp() || exp->isContinueExp())
-            {
-                exp->accept(*this);
-                if (loops.empty())
-                {
-                    // We are not in a loop so this break is useless.
-                    exp->replace(new ast::CommentExp(exp->getLocation(), new std::wstring(L"useless break or continue")));
-                }
-                else
-                {
-                    // We are in a loop: all the code after the break in this SeqExp is useless
-                    break;
-                }
-            }
-            else
-            {
-                exp->accept(*this);
-            }
-        }
-
-        if (i != itEnd)
-        {
-            ++i;
-            if (i != itEnd)
-            {
-                e.getExps().erase(i, itEnd);
-            }
-        }
-    }
-
     void visit(ast::ArrayListExp & e)
     {
         logger.log(L"ArrayListExp", e.getLocation());
@@ -676,22 +476,6 @@ private:
         visit(static_cast<ast::ArrayListExp &>(e));
     }
 
-    void visit(ast::VarDec & e)
-    {
-        // VarDec is only used in For loop for iterator declaration
-        logger.log(L"VarDec", e.getLocation());
-        const symbol::Symbol & sym = e.getSymbol();
-        if (e.getInit().isListExp())
-        {
-            ast::ListExp & le = static_cast<ast::ListExp &>(e.getInit());
-            //e.setListInfo(ForList64());
-            le.accept(*this);
-            Result & res = getResult();
-            Info & info = dm.define(sym, res.getType(), res.isAnInt(), &e);
-            info.setRange(res.getRange());
-        }
-    }
-
     void visit(ast::FunctionDec & e)
     {
         /*e.args_get().accept(*this);
index 2e8d74a..2119ca7 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "dec.hxx"
 #include "context.hxx"
-//#include "ForList.hxx"
+#include "ForList.hxx"
 
 namespace ast
 {
@@ -123,25 +123,25 @@ public:
         return *_exps[0];
     }
 
-    //analysis::ForList64 getListInfo() const
-    //{
-    //    return list_info;
-    //}
+    analysis::ForList64 getListInfo() const
+    {
+        return list_info;
+    }
 
-    //analysis::ForList64 & getListInfo()
-    //{
-    //    return list_info;
-    //}
+    analysis::ForList64 & getListInfo()
+    {
+        return list_info;
+    }
 
-    //void setListInfo(analysis::ForList64 & _list_info)
-    //{
-    //    list_info = _list_info;
-    //}
+    void setListInfo(analysis::ForList64 & _list_info)
+    {
+        list_info = _list_info;
+    }
 
-    //void setListInfo(analysis::ForList64 && _list_info)
-    //{
-    //    list_info = _list_info;
-    //}
+    void setListInfo(analysis::ForList64 && _list_info)
+    {
+        list_info = _list_info;
+    }
 
     virtual ExpType getType() const
     {
@@ -152,7 +152,7 @@ public:
         return true;
     }
 protected:
-    //analysis::ForList64 list_info;
+    analysis::ForList64 list_info;
     /** \brief Name of the declared variable. */
     symbol::Symbol _name;
     symbol::Variable* _stack;
index 41156dc..0ef36d2 100644 (file)
 
 namespace analysis
 {
-    AnalysisVisitor::MapSymCall AnalysisVisitor::symscall = AnalysisVisitor::initCalls();//a=1:3;b=2;c=3;testAnalysis("repmat","a","b","c")
+AnalysisVisitor::MapSymCall AnalysisVisitor::symscall = AnalysisVisitor::initCalls();//a=1:3;b=2;c=3;testAnalysis("repmat","a","b","c")
 
-    AnalysisVisitor::MapSymCall AnalysisVisitor::initCalls()
-    {
-        MapSymCall msc;
-
-        msc.emplace(L"zeros", std::shared_ptr<CallAnalyzer>(new ZerosAnalyzer()));
-        msc.emplace(L"ones", std::shared_ptr<CallAnalyzer>(new OnesAnalyzer()));
-        msc.emplace(L"rand", std::shared_ptr<CallAnalyzer>(new RandAnalyzer()));
-        msc.emplace(L"matrix", std::shared_ptr<CallAnalyzer>(new MatrixAnalyzer()));
-        msc.emplace(L"eye", std::shared_ptr<CallAnalyzer>(new EyeAnalyzer()));
-
-        std::shared_ptr<CallAnalyzer> ca(new CeilAnalyzer());
-        msc.emplace(L"ceil", ca);
-        msc.emplace(L"floor", ca);
-        msc.emplace(L"round", ca);
-        msc.emplace(L"fix", ca);
-        msc.emplace(L"int", ca);
-
-        //msc.emplace(L"sqrt", std::shared_ptr<CallAnalyzer>(new SqrtAnalyzer()));
-        msc.emplace(L"argn", std::shared_ptr<CallAnalyzer>(new ArgnAnalyzer()));
-        msc.emplace(L"size", std::shared_ptr<CallAnalyzer>(new SizeAnalyzer()));
-        msc.emplace(L"length", std::shared_ptr<CallAnalyzer>(new LengthAnalyzer()));
-        msc.emplace(L"diag", std::shared_ptr<CallAnalyzer>(new DiagAnalyzer()));
-        msc.emplace(L"type", std::shared_ptr<CallAnalyzer>(new TypeAnalyzer()));
-        msc.emplace(L"typeof", std::shared_ptr<CallAnalyzer>(new TypeofAnalyzer()));
-        msc.emplace(L"inttype", std::shared_ptr<CallAnalyzer>(new InttypeAnalyzer()));
-        msc.emplace(L"iconvert", std::shared_ptr<CallAnalyzer>(new IconvertAnalyzer()));
-        msc.emplace(L"isreal", std::shared_ptr<CallAnalyzer>(new IsrealAnalyzer()));
-        msc.emplace(L"isscalar", std::shared_ptr<CallAnalyzer>(new IsscalarAnalyzer()));
-        msc.emplace(L"find", std::shared_ptr<CallAnalyzer>(new FindAnalyzer()));
-
-        return msc;
-    }
+AnalysisVisitor::MapSymCall AnalysisVisitor::initCalls()
+{
+    MapSymCall msc;
 
-    bool AnalysisVisitor::asDouble(types::InternalType * pIT, double & out)
-    {
-        if (pIT && pIT->isDouble())
-        {
-            types::Double * pDbl = static_cast<types::Double *>(pIT);
-            if (!pDbl->isComplex() && pDbl->getSize() == 1)
-            {
-                out = pDbl->get()[0];
-                return true;
-            }
-        }
+    msc.emplace(L"zeros", std::shared_ptr<CallAnalyzer>(new ZerosAnalyzer()));
+    msc.emplace(L"ones", std::shared_ptr<CallAnalyzer>(new OnesAnalyzer()));
+    msc.emplace(L"rand", std::shared_ptr<CallAnalyzer>(new RandAnalyzer()));
+    msc.emplace(L"matrix", std::shared_ptr<CallAnalyzer>(new MatrixAnalyzer()));
+    msc.emplace(L"eye", std::shared_ptr<CallAnalyzer>(new EyeAnalyzer()));
 
-        return false;
-    }
+    std::shared_ptr<CallAnalyzer> ca(new CeilAnalyzer());
+    msc.emplace(L"ceil", ca);
+    msc.emplace(L"floor", ca);
+    msc.emplace(L"round", ca);
+    msc.emplace(L"fix", ca);
+    msc.emplace(L"int", ca);
 
-    bool AnalysisVisitor::asDouble(ast::Exp & e, double & out)
+    //msc.emplace(L"sqrt", std::shared_ptr<CallAnalyzer>(new SqrtAnalyzer()));
+    msc.emplace(L"argn", std::shared_ptr<CallAnalyzer>(new ArgnAnalyzer()));
+    msc.emplace(L"size", std::shared_ptr<CallAnalyzer>(new SizeAnalyzer()));
+    msc.emplace(L"length", std::shared_ptr<CallAnalyzer>(new LengthAnalyzer()));
+    msc.emplace(L"diag", std::shared_ptr<CallAnalyzer>(new DiagAnalyzer()));
+    msc.emplace(L"type", std::shared_ptr<CallAnalyzer>(new TypeAnalyzer()));
+    msc.emplace(L"typeof", std::shared_ptr<CallAnalyzer>(new TypeofAnalyzer()));
+    msc.emplace(L"inttype", std::shared_ptr<CallAnalyzer>(new InttypeAnalyzer()));
+    msc.emplace(L"iconvert", std::shared_ptr<CallAnalyzer>(new IconvertAnalyzer()));
+    msc.emplace(L"isreal", std::shared_ptr<CallAnalyzer>(new IsrealAnalyzer()));
+    msc.emplace(L"isscalar", std::shared_ptr<CallAnalyzer>(new IsscalarAnalyzer()));
+    msc.emplace(L"find", std::shared_ptr<CallAnalyzer>(new FindAnalyzer()));
+
+    return msc;
+}
+
+void AnalysisVisitor::print_info()
+{
+    stop_chrono();
+
+    //std::wcout << getGVN() << std::endl << std::endl; function z=foo(x,y);z=argn(2);endfunction;jit("x=123;y=456;t=foo(x,y)")
+    std::wcerr << L"Analysis: " << *static_cast<Chrono *>(this) << std::endl;
+    //std::wcout << temp << std::endl;
+
+    std::wcerr << dm << std::endl;
+
+    std::wcerr << std::endl;
+}
+
+logging::Logger & AnalysisVisitor::getLogger()
+{
+    return logger;
+}
+
+bool AnalysisVisitor::asDouble(types::InternalType * pIT, double & out)
+{
+    if (pIT && pIT->isDouble())
     {
-        if (e.isDoubleExp())
+        types::Double * pDbl = static_cast<types::Double *>(pIT);
+        if (!pDbl->isComplex() && pDbl->getSize() == 1)
         {
-            out = static_cast<ast::DoubleExp &>(e).getValue();
+            out = pDbl->get()[0];
             return true;
         }
-        else if (e.isOpExp())
+    }
+
+    return false;
+}
+
+bool AnalysisVisitor::asDouble(ast::Exp & e, double & out)
+{
+    if (e.isDoubleExp())
+    {
+        out = static_cast<ast::DoubleExp &>(e).getValue();
+        return true;
+    }
+    else if (e.isOpExp())
+    {
+        ast::OpExp & op = static_cast<ast::OpExp &>(e);
+        if (op.getOper() == ast::OpExp::unaryMinus)
         {
-            ast::OpExp & op = static_cast<ast::OpExp &>(e);
-            if (op.getOper() == ast::OpExp::unaryMinus)
+            if (op.getRight().isDoubleExp())
             {
-                if (op.getRight().isDoubleExp())
-                {
-                    out = -static_cast<ast::DoubleExp &>(op.getRight()).getValue();
-                    return true;
-                }
+                out = -static_cast<ast::DoubleExp &>(op.getRight()).getValue();
+                return true;
             }
-            else if (op.getLeft().isDoubleExp() && op.getRight().isDoubleExp())
-            {
-                const double L = static_cast<ast::DoubleExp &>(op.getLeft()).getValue();
-                const double R = static_cast<ast::DoubleExp &>(op.getRight()).getValue();
+        }
+        else if (op.getLeft().isDoubleExp() && op.getRight().isDoubleExp())
+        {
+            const double L = static_cast<ast::DoubleExp &>(op.getLeft()).getValue();
+            const double R = static_cast<ast::DoubleExp &>(op.getRight()).getValue();
 
-                switch (op.getOper())
-                {
+            switch (op.getOper())
+            {
                 case ast::OpExp::minus:
                     out = L - R;
                     return true;
@@ -134,70 +152,70 @@ namespace analysis
                     return true;
                 default:
                     return false;
-                }
             }
         }
-
-        return false;
     }
 
-    bool AnalysisVisitor::isDoubleConstant(const ast::Exp & e)
+    return false;
+}
+
+bool AnalysisVisitor::isDoubleConstant(const ast::Exp & e)
+{
+    if (e.isDoubleExp())
     {
-        if (e.isDoubleExp())
-        {
-            return true;
-        }
-        else if (e.isOpExp())
+        return true;
+    }
+    else if (e.isOpExp())
+    {
+        const ast::OpExp & oe = static_cast<const ast::OpExp &>(e);
+        if (!oe.isBooleanOp())
         {
-            const ast::OpExp & oe = static_cast<const ast::OpExp &>(e);
-            if (!oe.isBooleanOp())
-            {
-                return isDoubleConstant(oe.getLeft()) && isDoubleConstant(oe.getRight());
-            }
-            return false;
+            return isDoubleConstant(oe.getLeft()) && isDoubleConstant(oe.getRight());
         }
-        else if (e.isMatrixExp())
+        return false;
+    }
+    else if (e.isMatrixExp())
+    {
+        const ast::MatrixExp & me = static_cast<const ast::MatrixExp &>(e);
+        const ast::exps_t & lines = me.getLines();
+        for (const auto line : lines)
         {
-            const ast::MatrixExp & me = static_cast<const ast::MatrixExp &>(e);
-            const ast::exps_t & lines = me.getLines();
-            for (const auto line : lines)
+            const ast::exps_t & columns = static_cast<ast::MatrixLineExp *>(line)->getColumns();
+            for (const auto column : columns)
             {
-                const ast::exps_t & columns = static_cast<ast::MatrixLineExp *>(line)->getColumns();
-                for (const auto column : columns)
+                if (column && !isDoubleConstant(*column))
                 {
-                    if (column && !isDoubleConstant(*column))
-                    {
-                        return false;
-                    }
+                    return false;
                 }
             }
-            return true;
         }
-        else if (e.isListExp())
-        {
-            const ast::ListExp & le = static_cast<const ast::ListExp &>(e);
-            return isDoubleConstant(le.getStart()) && isDoubleConstant(le.getStep()) && isDoubleConstant(le.getEnd());
-        }
-        else if (e.isSimpleVar())
-        {
-            const ast::SimpleVar & var = static_cast<const ast::SimpleVar &>(e);
-            const symbol::Symbol & sym = var.getSymbol();
-            const std::wstring & name = sym.getName();
-            return name == L"%i" || name == L"%inf" || name == L"%nan" || name == L"%eps" || name == L"%pi" || name == L"%e";
-        }
-        else if (e.isCallExp())
-        {
-            const ast::CallExp & ce = static_cast<const ast::CallExp &>(e);
-            const ast::SimpleVar & var = static_cast<const ast::SimpleVar &>(ce.getName());
-            const std::wstring & name = var.getSymbol().getName();
+        return true;
+    }
+    else if (e.isListExp())
+    {
+        const ast::ListExp & le = static_cast<const ast::ListExp &>(e);
+        return isDoubleConstant(le.getStart()) && isDoubleConstant(le.getStep()) && isDoubleConstant(le.getEnd());
+    }
+    else if (e.isSimpleVar())
+    {
+        const ast::SimpleVar & var = static_cast<const ast::SimpleVar &>(e);
+        const symbol::Symbol & sym = var.getSymbol();
+        const std::wstring & name = sym.getName();
+        return name == L"%i" || name == L"%inf" || name == L"%nan" || name == L"%eps" || name == L"%pi" || name == L"%e";
+    }
+    else if (e.isCallExp())
+    {
+        const ast::CallExp & ce = static_cast<const ast::CallExp &>(e);
+        const ast::SimpleVar & var = static_cast<const ast::SimpleVar &>(ce.getName());
+        const std::wstring & name = var.getSymbol().getName();
 
-            // TODO: check if 'ones' and 'zeros' are the expected functions
-            // ie: ones="abc"; ones(1) !!!
-            if (name == L"ones" || name == L"zeros")
+        // TODO: check if 'ones' and 'zeros' are the expected functions
+        // ie: ones="abc"; ones(1) !!!
+        if (name == L"ones" || name == L"zeros")
+        {
+            const ast::exps_t args = ce.getArgs();
+            switch (args.size())
             {
-                const ast::exps_t args = ce.getArgs();
-                switch (args.size())
-                {
                 case 0:
                     return true;
                 case 1:
@@ -206,231 +224,231 @@ namespace analysis
                     return isDoubleConstant(*args.front()) && isDoubleConstant(**std::next(args.cbegin()));
                 default:
                     return false;
-                }
             }
         }
-
-        return false;
     }
 
-    bool AnalysisVisitor::asDoubleMatrix(ast::Exp & e, types::Double *& data)
+    return false;
+}
+
+bool AnalysisVisitor::asDoubleMatrix(ast::Exp & e, types::Double *& data)
+{
+    if (isDoubleConstant(e))
     {
-        if (isDoubleConstant(e))
+        ast::ExecVisitor exec;
+        e.accept(exec);
+        types::InternalType * pIT = exec.getResult();
+        // TODO : handle complex case
+        if (pIT && pIT->isDouble() && !pIT->getAs<types::Double>()->isComplex())
         {
-            ast::ExecVisitor exec;
-            e.accept(exec);
-            types::InternalType * pIT = exec.getResult();
-            // TODO : handle complex case
-            if (pIT && pIT->isDouble() && !pIT->getAs<types::Double>()->isComplex())
-            {
-                pIT->IncreaseRef();
-                data = static_cast<types::Double *>(pIT);
+            pIT->IncreaseRef();
+            data = static_cast<types::Double *>(pIT);
 
-                return true;
-            }
+            return true;
         }
-
-        return false;
     }
 
-    void AnalysisVisitor::visitArguments(const std::wstring & name, const unsigned int lhs, const TIType & calltype, ast::CallExp & e, const ast::exps_t & args)
+    return false;
+}
+
+void AnalysisVisitor::visitArguments(const std::wstring & name, const unsigned int lhs, const TIType & calltype, ast::CallExp & e, const ast::exps_t & args)
+{
+    std::vector<Result> resargs;
+    std::vector<TIType> vargs;
+    vargs.reserve(args.size());
+    resargs.reserve(args.size());
+
+    for (auto arg : args)
     {
-        std::vector<Result> resargs;
-        std::vector<TIType> vargs;
-        vargs.reserve(args.size());
-        resargs.reserve(args.size());
+        arg->accept(*this);
+        resargs.push_back(getResult());
+        vargs.push_back(getResult().getType());
+    }
 
-        for (auto arg : args)
+    const symbol::Symbol & sym = static_cast<ast::SimpleVar &>(e.getName()).getSymbol();
+    std::vector<TIType> out = getDM().call(*this, lhs, sym, vargs, &e);
+    if (lhs > 1)
+    {
+        multipleLHS.clear();
+        multipleLHS.reserve(out.size());
+        for (const auto & type : out)
         {
-            arg->accept(*this);
-            resargs.push_back(getResult());
-            vargs.push_back(getResult().getType());
+            const int tempId = getDM().getTmpId(type, false);
+            multipleLHS.emplace_back(type, tempId);
         }
 
-        const symbol::Symbol & sym = static_cast<ast::SimpleVar &>(e.getName()).getSymbol();
-       std::vector<TIType> out = getDM().call(*this, lhs, sym, vargs, &e);
-        if (lhs > 1)
+        for (const auto & resarg : resargs)
         {
-            multipleLHS.clear();
-            multipleLHS.reserve(out.size());
-            for (const auto & type : out)
+            getDM().releaseTmp(resarg.getTempId());
+        }
+    }
+    else if (lhs == 1)
+    {
+        int tempId = -1;
+        if (resargs.size() == 1)
+        {
+            const int id = resargs.back().getTempId();
+            if (id != -1 && Checkers::isElementWise(name) && out[0] == resargs.back().getType())
             {
-               const int tempId = getDM().getTmpId(type, false);
-                multipleLHS.emplace_back(type, tempId);
+                tempId = id;
+            }
+        }
+        if (tempId == -1)
+        {
+            tempId = getDM().getTmpId(out[0], false);
+            for (const auto & resarg : resargs)
+            {
+                getDM().releaseTmp(resarg.getTempId());
             }
-
-           for (const auto & resarg : resargs)
-           {
-               getDM().releaseTmp(resarg.getTempId());
-           }
         }
-        else if (lhs == 1)
-       {
-           int tempId = -1;
-           if (resargs.size() == 1)
-           {
-               const int id = resargs.back().getTempId();
-               if (id != -1 && Checkers::isElementWise(name) && out[0] == resargs.back().getType())
-               {
-                   tempId = id;
-               }
-           }
-           if (tempId == -1)
-           {
-               tempId = getDM().getTmpId(out[0], false);
-               for (const auto & resarg : resargs)
-               {
-                   getDM().releaseTmp(resarg.getTempId());
-               }
-           }
-           
-           e.getDecorator().res = Result(out[0], tempId);
-           e.getDecorator().setCall(name, vargs);
-           setResult(e.getDecorator().res);
-       }
+
+        e.getDecorator().res = Result(out[0], tempId);
+        e.getDecorator().setCall(name, vargs);
+        setResult(e.getDecorator().res);
     }
+}
 
-    int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, const Result & RR)
+int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, const Result & RR)
+{
+    int tempId = -1;
+    if (resT.isknown() && resT.ismatrix())
     {
-        int tempId = -1;
-        if (resT.isknown() && resT.ismatrix())
+        if (LR.isTemp() || RR.isTemp())
         {
-            if (LR.isTemp() || RR.isTemp())
-            {
-                const int Lid = LR.getTempId();
-                const int Rid = RR.getTempId();
-                const TIType & LT = LR.getType();
-                const TIType & RT = RR.getType();
+            const int Lid = LR.getTempId();
+            const int Rid = RR.getTempId();
+            const TIType & LT = LR.getType();
+            const TIType & RT = RR.getType();
 
-                if (LT.isscalar())
+            if (LT.isscalar())
+            {
+                if (RT.isscalar())
                 {
-                    if (RT.isscalar())
+                    if (Lid == -1)
                     {
-                        if (Lid == -1)
+                        if (resT == LT)
                         {
-                            if (resT == LT)
-                            {
-                                tempId = Rid;
-                            }
-                            else
-                            {
-                                tempId = getDM().getTmpId(resT, false);
-                                getDM().releaseTmp(Rid);
-                            }
+                            tempId = Rid;
                         }
                         else
                         {
-                            if (resT == LT)
-                            {
-                                tempId = Lid;
-                                getDM().releaseTmp(Rid);
-                            }
-                           else if (Rid != -1 && resT == RT)
-                           {
-                                tempId = Rid;
-                                getDM().releaseTmp(Lid);
-                           }
-                            else
-                            {
-                                tempId = getDM().getTmpId(resT, false);
-                                getDM().releaseTmp(Lid);
-                            }
+                            tempId = getDM().getTmpId(resT, false);
+                            getDM().releaseTmp(Rid);
                         }
                     }
                     else
                     {
-                        if (Rid == -1)
+                        if (resT == LT)
                         {
-                            tempId = getDM().getTmpId(resT, false);
+                            tempId = Lid;
+                            getDM().releaseTmp(Rid);
+                        }
+                        else if (Rid != -1 && resT == RT)
+                        {
+                            tempId = Rid;
+                            getDM().releaseTmp(Lid);
                         }
                         else
                         {
-                            if (resT == RT)
-                            {
-                                tempId = Rid;
-                            }
-                           else if (Lid != -1 && resT == LT)
-                           {
-                               tempId = Lid;
-                               getDM().releaseTmp(Rid);
-                           }
-                            else
-                            {
-                                tempId = getDM().getTmpId(resT, false);
-                                getDM().releaseTmp(Rid);
-                            }
+                            tempId = getDM().getTmpId(resT, false);
+                            getDM().releaseTmp(Lid);
                         }
-                        getDM().releaseTmp(Lid);
                     }
                 }
                 else
                 {
-                    if (RT.isscalar())
+                    if (Rid == -1)
+                    {
+                        tempId = getDM().getTmpId(resT, false);
+                    }
+                    else
                     {
-                        if (Lid == -1)
+                        if (resT == RT)
                         {
-                            tempId = getDM().getTmpId(resT, false);
+                            tempId = Rid;
+                        }
+                        else if (Lid != -1 && resT == LT)
+                        {
+                            tempId = Lid;
+                            getDM().releaseTmp(Rid);
                         }
                         else
                         {
-                            if (resT == LT)
-                            {
-                                tempId = Lid;
-                            }
-                           else if (Rid != -1 && resT == RT)
-                           {
-                               tempId = Rid;
-                               getDM().releaseTmp(Lid);
-                           }
-                            else
-                            {
-                                tempId = getDM().getTmpId(resT, false);
-                                getDM().releaseTmp(Lid);
-                            }
+                            tempId = getDM().getTmpId(resT, false);
+                            getDM().releaseTmp(Rid);
                         }
-                        getDM().releaseTmp(Rid);
+                    }
+                    getDM().releaseTmp(Lid);
+                }
+            }
+            else
+            {
+                if (RT.isscalar())
+                {
+                    if (Lid == -1)
+                    {
+                        tempId = getDM().getTmpId(resT, false);
                     }
                     else
                     {
-                        if (Rid == -1)
+                        if (resT == LT)
+                        {
+                            tempId = Lid;
+                        }
+                        else if (Rid != -1 && resT == RT)
+                        {
+                            tempId = Rid;
+                            getDM().releaseTmp(Lid);
+                        }
+                        else
+                        {
+                            tempId = getDM().getTmpId(resT, false);
+                            getDM().releaseTmp(Lid);
+                        }
+                    }
+                    getDM().releaseTmp(Rid);
+                }
+                else
+                {
+                    if (Rid == -1)
+                    {
+                        if (resT == LT)
                         {
-                            if (resT == LT)
-                            {
-                                tempId = Lid;
-                            }
-                            else
-                            {
-                                tempId = getDM().getTmpId(resT, false);
-                                getDM().releaseTmp(Lid);
-                            }
+                            tempId = Lid;
                         }
                         else
                         {
-                            if (resT == RT)
-                            {
-                                tempId = Rid;
-                            }
-                           else if (Lid != -1 && resT == LT)
-                           {
-                               tempId = Lid;
-                               getDM().releaseTmp(Rid);
-                           }
-                            else
-                            {
-                                tempId = getDM().getTmpId(resT, false);
-                                getDM().releaseTmp(Rid);
-                            }
+                            tempId = getDM().getTmpId(resT, false);
                             getDM().releaseTmp(Lid);
                         }
                     }
+                    else
+                    {
+                        if (resT == RT)
+                        {
+                            tempId = Rid;
+                        }
+                        else if (Lid != -1 && resT == LT)
+                        {
+                            tempId = Lid;
+                            getDM().releaseTmp(Rid);
+                        }
+                        else
+                        {
+                            tempId = getDM().getTmpId(resT, false);
+                            getDM().releaseTmp(Rid);
+                        }
+                        getDM().releaseTmp(Lid);
+                    }
                 }
             }
-           else
-           {
-               tempId = getDM().getTmpId(resT, false);
-           }
         }
-
-        return tempId;
+        else
+        {
+            tempId = getDM().getTmpId(resT, false);
+        }
     }
+
+    return tempId;
+}
 }
index c672400..a4cf353 100644 (file)
 
 namespace analysis
 {
-    bool SizeAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+bool SizeAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+{
+    if (lhs > 2)
     {
-        if (lhs > 2)
-        {
-            return false;
-        }
+        return false;
+    }
 
-        const ast::exps_t args = e.getArgs();
-        enum Kind
-        {
-            ROWS, COLS, ROWSTIMESCOLS, ROWSCOLS, ONE, BOTH
-        } kind;
-        const std::size_t size = args.size();
-        if (size == 0 || size >= 3)
-        {
-            return false;
-        }
+    const ast::exps_t args = e.getArgs();
+    enum Kind
+    {
+        ROWS, COLS, ROWSTIMESCOLS, ROWSCOLS, ONE, BOTH
+    } kind;
+    const std::size_t size = args.size();
+    if (size == 0 || size >= 3)
+    {
+        return false;
+    }
 
-        ast::Exp * first = *args.begin();
-        if (!first)
-        {
-            return false;
-        }
-        first->accept(visitor);
-        Result & res = visitor.getResult();
-        if (!res.getType().ismatrix())
-        {
-            return false;
-        }
+    ast::Exp * first = *args.begin();
+    if (!first)
+    {
+        return false;
+    }
+    first->accept(visitor);
+    Result & res = visitor.getResult();
+    if (!res.getType().ismatrix())
+    {
+        visitor.getDM().releaseTmp(res.getTempId());
+        return false;
+    }
 
-        switch (size)
-        {
+    switch (size)
+    {
         case 1:
             if (lhs == 1)
             {
@@ -82,6 +83,7 @@ namespace analysis
                     }
                     else
                     {
+                        visitor.getDM().releaseTmp(res.getTempId());
                         return false;
                     }
                 }
@@ -103,24 +105,27 @@ namespace analysis
                     }
                     else
                     {
+                        visitor.getDM().releaseTmp(res.getTempId());
                         return false;
                     }
                 }
             }
             else
             {
+                visitor.getDM().releaseTmp(res.getTempId());
                 return false;
             }
             break;
         }
         default:
+            visitor.getDM().releaseTmp(res.getTempId());
             return false;
-        }
+    }
 
-        TIType type(visitor.getGVN(), TIType::DOUBLE);
+    TIType type(visitor.getGVN(), TIType::DOUBLE);
 
-        switch (kind)
-        {
+    switch (kind)
+    {
         case ROWS:
         {
             SymbolicDimension & rows = res.getType().rows;
@@ -173,16 +178,16 @@ namespace analysis
             visitor.setResult(_res);
             break;
         }
-       case BOTH:
+        case BOTH:
         {
-           TIType _type(visitor.getGVN(), TIType::DOUBLE, 1, 2);
+            TIType _type(visitor.getGVN(), TIType::DOUBLE, 1, 2);
             Result & _res = e.getDecorator().setResult(_type);
             e.getDecorator().setCall(new SizeCall(SizeCall::BOTH));
             visitor.setResult(_res);
             break;
         }
-        }
-
-        return true;
     }
+
+    return true;
+}
 }
index 57cb77b..baa4d92 100644 (file)
 
 namespace analysis
 {
-    bool TypeofAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+bool TypeofAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+{
+    if (lhs != 1)
     {
-        if (lhs != 1)
-        {
-            return false;
-        }
+        return false;
+    }
+
+    const ast::exps_t args = e.getArgs();
+    if (args.size() != 1)
+    {
+        return false;
+    }
 
-        const ast::exps_t args = e.getArgs();
-        if (args.size() != 1)
-        {
-            return false;
-        }
-       
-        ast::Exp * arg = args.back();
-        arg->accept(visitor);
-       const std::wstring & str = visitor.getResult().getType().getScilabString();
+    ast::Exp * arg = args.back();
+    arg->accept(visitor);
+    const std::wstring & str = visitor.getResult().getType().getScilabString();
 
-        if (!str.empty())
-        {
-           TIType type(visitor.getGVN(), TIType::STRING);
-           Result & res = e.getDecorator().setResult(type);
-            res.getConstant() = new types::String(str.c_str());
-            e.getDecorator().setCall(L"typeof");
-            visitor.setResult(res);
-            return true;
-        }
-        else
-        {
-            return false;
-        }
+    if (!str.empty())
+    {
+        TIType type(visitor.getGVN(), TIType::STRING);
+        Result & res = e.getDecorator().setResult(type);
+        res.getConstant() = new types::String(str.c_str());
+        e.getDecorator().setCall(L"typeof");
+        visitor.setResult(res);
+        return true;
+    }
+    else
+    {
+        visitor.getDM().releaseTmp(visitor.getResult().getTempId());
+        return false;
     }
 }
+}
diff --git a/scilab/modules/ast/src/cpp/analysis/VisitCallExp.cpp b/scilab/modules/ast/src/cpp/analysis/VisitCallExp.cpp
new file mode 100644 (file)
index 0000000..e5b9707
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ *  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 "AnalysisVisitor.hxx"
+
+namespace analysis
+{
+
+void AnalysisVisitor::visit(ast::CallExp & e)
+{
+    visit(e, 1);
+}
+
+void AnalysisVisitor::visit(ast::CallExp & e, const unsigned int lhs)
+{
+    // TODO: e.getName() is not always a simple var: foo(a)(b)
+    if (e.getName().isSimpleVar())
+    {
+        const ast::SimpleVar & var = static_cast<ast::SimpleVar &>(e.getName());
+        const symbol::Symbol & sym = var.getSymbol();
+        const std::wstring & name = sym.getName();
+        Info & info = getSymInfo(sym); // that put the sym in the current block !
+        Result & res = e.getName().getDecorator().setResult(info.type);
+        res.setConstant(info.getConstant());
+        res.setRange(info.getRange());
+        res.setMaxIndex(info.getMaxIndex());
+
+        logger.log(L"CallExp", e.getLocation(), name);
+
+        if (info.type.type == TIType::MACRO || info.type.type == TIType::MACROFILE || info.type.type == TIType::FUNCTION)
+        {
+            if (name == L"error")
+            {
+                getDM().getCurrent()->setReturn(true);
+            }
+
+            // Special analysis cases: size, zeros, ones, ...
+            MapSymCall::iterator it = symscall.find(name);
+            if (it != symscall.end())
+            {
+                if (getCM().checkGlobalConstant(sym) && it->second.get()->analyze(*this, lhs, e))
+                {
+                    pushCall(e.getDecorator().getCall());
+                    return;
+                }
+            }
+
+            visitArguments(name, lhs, info.type, e, e.getArgs());
+            pushCall(e.getDecorator().getCall());
+        }
+        else
+        {
+            analyzeIndices(info.type, e);
+        }
+    }
+}
+
+} // namespace analysis
diff --git a/scilab/modules/ast/src/cpp/analysis/VisitDollarVar.cpp b/scilab/modules/ast/src/cpp/analysis/VisitDollarVar.cpp
new file mode 100644 (file)
index 0000000..6ecb646
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ *  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 "AnalysisVisitor.hxx"
+
+namespace analysis
+{
+
+void AnalysisVisitor::visit(ast::DollarVar & e)
+{
+    logger.log(L"DollarVar", e.getLocation());
+    Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::POLYNOMIAL, 1, 1));
+    res.getConstant() = getGVN().getValue(symbol::Symbol(L"$"));
+    setResult(res);
+}
+
+} // namespace analysis
diff --git a/scilab/modules/ast/src/cpp/analysis/VisitForExp.cpp b/scilab/modules/ast/src/cpp/analysis/VisitForExp.cpp
new file mode 100644 (file)
index 0000000..74820ac
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ *  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 "AnalysisVisitor.hxx"
+
+namespace analysis
+{
+
+void AnalysisVisitor::visit(ast::ForExp & e)
+{
+    logger.log(L"ForExp", e.getLocation());
+    loops.push(&e);
+
+    dm.addBlock(Block::LOOP, &e);
+    e.getVardec().accept(*this);
+    dm.addBlock(Block::NORMAL, &e.getBody());
+    e.getBody().accept(*this);
+
+    if (dm.requiresAnotherTrip())
+    {
+        std::wcerr << "Invalid forexp: types or refcount are not the same before and after the loop" << std::endl;
+
+        dm.finalizeBlock();
+        dm.addBlock(Block::NORMAL, &e.getBody());
+        e.getBody().accept(*this);
+
+        if (dm.requiresAnotherTrip())
+        {
+            std::wcerr << "Invalid forexp: types or refcount are not the same before and after the loop" << std::endl;
+        }
+    }
+
+    dm.finalizeBlock();
+    dm.finalizeBlock();
+
+    loops.pop();
+}
+
+} // namespace analysis
diff --git a/scilab/modules/ast/src/cpp/analysis/VisitSeqExp.cpp b/scilab/modules/ast/src/cpp/analysis/VisitSeqExp.cpp
new file mode 100644 (file)
index 0000000..ed1c226
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ *  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 "AnalysisVisitor.hxx"
+
+namespace analysis
+{
+
+void AnalysisVisitor::visit(ast::SeqExp & e)
+{
+    logger.log(L"SeqExp", e.getLocation());
+    ast::exps_t::iterator i = e.getExps().begin();
+    ast::exps_t::iterator itEnd = e.getExps().end();
+    for (; i != itEnd; ++i)
+    {
+        ast::Exp* exp = *i;
+        if (exp->isCallExp())
+        {
+            visit(*static_cast<ast::CallExp *>(exp), /* LHS */ 0);
+        }
+        else if (exp->isBreakExp() || exp->isContinueExp())
+        {
+            exp->accept(*this);
+            if (loops.empty())
+            {
+                // We are not in a loop so this break is useless.
+                exp->replace(new ast::CommentExp(exp->getLocation(), new std::wstring(L"useless break or continue")));
+            }
+            else
+            {
+                // We are in a loop: all the code after the break in this SeqExp is useless
+                break;
+            }
+        }
+        else
+        {
+            exp->accept(*this);
+        }
+    }
+
+    if (i != itEnd)
+    {
+        ++i;
+        if (i != itEnd)
+        {
+            e.getExps().erase(i, itEnd);
+        }
+    }
+}
+
+} // namespace analysis
diff --git a/scilab/modules/ast/src/cpp/analysis/VisitSimpleVar.cpp b/scilab/modules/ast/src/cpp/analysis/VisitSimpleVar.cpp
new file mode 100644 (file)
index 0000000..12824e7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ *  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 "AnalysisVisitor.hxx"
+
+namespace analysis
+{
+
+void AnalysisVisitor::visit(ast::SimpleVar & e)
+{
+    logger.log(L"SimpleVar", e.getSymbol().getName(), e.getLocation());
+    symbol::Symbol & sym = e.getSymbol();
+    Info & info = dm.read(sym, &e);
+    Result & res = e.getDecorator().setResult(info.type);
+    res.setConstant(info.getConstant());
+    res.setRange(info.getRange());
+    res.setMaxIndex(info.getMaxIndex());
+    setResult(res);
+}
+
+} // namespace analysis
diff --git a/scilab/modules/ast/src/cpp/analysis/VisitTypeExps.cpp b/scilab/modules/ast/src/cpp/analysis/VisitTypeExps.cpp
new file mode 100644 (file)
index 0000000..44915e6
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ *  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 "AnalysisVisitor.hxx"
+
+namespace analysis
+{
+
+void AnalysisVisitor::visit(ast::DoubleExp & e)
+{
+    logger.log(L"DoubleExp", e.getLocation());
+    if (!e.getConstant())
+    {
+        e.accept(cv.getExec());
+        cv.getExec().setResult(nullptr);
+    }
+    types::Double * pDbl = static_cast<types::Double *>(e.getConstant());
+    if (pDbl->isComplex())
+    {
+        Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::COMPLEX, pDbl->getRows(), pDbl->getCols()));
+        res.getConstant() = e.getConstant();
+        setResult(res);
+    }
+    else
+    {
+        Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::DOUBLE, pDbl->getRows(), pDbl->getCols()));
+        res.getConstant() = e.getConstant();
+        setResult(res);
+    }
+}
+
+void AnalysisVisitor::visit(ast::BoolExp & e)
+{
+    logger.log(L"BoolExp", e.getLocation());
+    if (!e.getConstant())
+    {
+        e.accept(cv.getExec());
+        cv.getExec().setResult(nullptr);
+    }
+    types::Bool * pBool = static_cast<types::Bool *>(e.getConstant());
+    Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::BOOLEAN, pBool->getRows(), pBool->getCols()));
+    res.getConstant() = e.getConstant();
+    setResult(res);
+}
+
+void AnalysisVisitor::visit(ast::StringExp & e)
+{
+    logger.log(L"StringExp", e.getLocation());
+    if (!e.getConstant())
+    {
+        e.accept(cv.getExec());
+        cv.getExec().setResult(nullptr);
+    }
+    types::String * pStr = static_cast<types::String *>(e.getConstant());
+    Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::STRING, pStr->getRows(), pStr->getCols()));
+    res.getConstant() = e.getConstant();
+    setResult(res);
+}
+
+
+} // namespace analysis
diff --git a/scilab/modules/ast/src/cpp/analysis/VisitVarDec.cpp b/scilab/modules/ast/src/cpp/analysis/VisitVarDec.cpp
new file mode 100644 (file)
index 0000000..e8dd04b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ *  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 "AnalysisVisitor.hxx"
+
+namespace analysis
+{
+
+void AnalysisVisitor::visit(ast::VarDec & e)
+{
+    // VarDec is only used in For loop for iterator declaration
+    logger.log(L"VarDec", e.getLocation());
+    const symbol::Symbol & sym = e.getSymbol();
+    if (e.getInit().isListExp())
+    {
+        ast::ListExp & le = static_cast<ast::ListExp &>(e.getInit());
+        //e.setListInfo(ForList64());
+        le.accept(*this);
+        Result & res = getResult();
+        Info & info = dm.define(sym, res.getType(), res.isAnInt(), &e);
+        info.setRange(res.getRange());
+    }
+}
+
+} // namespace analysis