Added Scilab function runVMKit to be used to change how the AST is visited.
Peter Senna Tschudin [Tue, 28 May 2013 13:31:59 +0000 (15:31 +0200)]
scilab/modules/core/Makefile.am
scilab/modules/core/includes/core_gw.hxx
scilab/modules/core/includes/tasks.hxx
scilab/modules/core/includes/vmkit_core.h [moved from scilab/modules/core/includes/vmkit.h with 95% similarity]
scilab/modules/core/sci_gateway/cpp/core_gw.cpp
scilab/modules/core/sci_gateway/cpp/sci_runASTwithVMKit.cpp [new file with mode: 0644]
scilab/modules/core/src/cpp/scilab.cpp
scilab/modules/core/src/cpp/tasks.cpp

index 8e6bed9..c563800 100644 (file)
@@ -199,7 +199,7 @@ GATEWAY_C_SOURCES = \
        sci_gateway/c/gw_user2.c \
        sci_gateway/c/sci_getvariablesonstack.c \
        sci_gateway/c/sci_readgateway.c \
-       sci_gateway/c/sci_comp.c
+       sci_gateway/c/sci_comp.c 
 
 GATEWAY_FORTRAN_SOURCES =  \
 sci_gateway/fortran/sci_f_mtlb_mode.f \
@@ -239,7 +239,8 @@ GATEWAY_CPP_SOURCES =       \
        sci_gateway/cpp/sci_format.cpp \
        sci_gateway/cpp/sci_sciargs.cpp \
        sci_gateway/cpp/sci_ieee.cpp \
-       sci_gateway/cpp/sci_funcprot.cpp
+       sci_gateway/cpp/sci_funcprot.cpp \
+       sci_gateway/cpp/sci_runASTwithVMKit.cpp 
 
 
 libscicore_la_CPPFLAGS = \
index fbd81e9..dc3ff6f 100644 (file)
@@ -53,5 +53,6 @@ CPP_GATEWAY_PROTOTYPE(sci_sciargs);
 CPP_GATEWAY_PROTOTYPE(sci_format);
 CPP_GATEWAY_PROTOTYPE(sci_ieee);
 CPP_GATEWAY_PROTOTYPE(sci_funcprot);
+CPP_GATEWAY_PROTOTYPE(sci_runVMKit);
 
 #endif /* __CORE_GW_HXX__ */
index 5e752ac..5ac5ec8 100644 (file)
@@ -48,7 +48,7 @@ void printAstTask(ast::Exp *tree, bool timed);
 **
 ** Execute the stored AST.
 */
-void execAstTask(ast::Exp *tree, bool timed, bool ASTtimed, bool execVerbose);
+void execAstTask(ast::Exp *tree, bool timed, bool ASTtimed, bool execVerbose, bool ASTrunVMKit);
 
 /*
 ** Exec Tree with original visitor ( without template )
similarity index 95%
rename from scilab/modules/core/includes/vmkit.h
rename to scilab/modules/core/includes/vmkit_core.h
index ac1b819..689f355 100644 (file)
@@ -60,7 +60,7 @@ namespace VMKitScilab {
 
                virtual void runApplication(int argc, char** argv){}
 
-               virtual void runApplication(int argc, char** argv, int iFileIndex, int iLangIndex);
+               virtual void runApplication(int argc, char**  argv, int iFileIndex, int iLangIndex);
 
                virtual void nullPointerException(){}
                virtual void stackOverflowError(){}
index 75ea4d3..0adf11d 100644 (file)
@@ -53,5 +53,6 @@ int CoreModule::Load()
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"ieee", &sci_ieee, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"typename", &sci_typename, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"funcprot", &sci_funcprot, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(Function::createFunction(L"runVMKit", &sci_runVMKit, MODULE_NAME));
     return 1;
 }
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_runASTwithVMKit.cpp b/scilab/modules/core/sci_gateway/cpp/sci_runASTwithVMKit.cpp
new file mode 100644 (file)
index 0000000..75fd251
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007 - INRIA - Allan CORNET
+ *
+ * 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 "funcmanager.hxx"
+#include "context.hxx"
+#include "core_gw.hxx"
+#include "string.hxx"
+
+extern "C"
+{
+#include "sci_mode.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sci_mode.h"
+#include "os_strdup.h"
+}
+
+// Defined at modules/core/src/cpp/scilab.cpp
+extern bool ASTrunVMKit;
+
+/*--------------------------------------------------------------------------*/
+
+using namespace types;
+
+Function::ReturnValue sci_runVMKit(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    Scierror(999, _("Comming soon...\n"));
+
+    ASTrunVMKit = true;
+
+    return Function::OK;
+}
+/*--------------------------------------------------------------------------*/
index 81aeacf..0fc0362 100644 (file)
@@ -95,7 +95,7 @@ extern "C"
 #include "runner.hxx"
 
 #if defined(VMKIT_ENABLED)
-#include <vmkit.h>
+#include <vmkit_core.h>
 #endif
 
 #define INTERACTIVE     -1
@@ -119,6 +119,8 @@ bool execCommand = false;
 bool execFile = false;
 bool parseFile = false;
 
+bool ASTrunVMKit = false;
+
 using symbol::Context;
 using std::string;
 
@@ -590,7 +592,7 @@ static Parser::ControlStatus processCommand(char *_pstCommand)
             {
                 //before calling YaspReader, try to call %onprompt function
                 callOnPrompt();
-                execAstTask(parser->getTree(), timed, ASTtimed, execVerbose);
+                execAstTask(parser->getTree(), timed, ASTtimed, execVerbose, ASTrunVMKit);
             }
 
             /*
index 82cd1da..7a7af5c 100644 (file)
@@ -29,6 +29,9 @@
 
 Timer _timer;
 
+// Defined at modules/core/src/cpp/scilab.cpp
+extern bool ASTrunVMKit;
+
 //#define DEBUG
 
 /*
@@ -133,7 +136,7 @@ void printAstTask(ast::Exp *tree, bool timed)
 **
 ** Execute the stored AST.
 */
-void execAstTask(ast::Exp* tree, bool timed, bool ASTtimed, bool execVerbose)
+void execAstTask(ast::Exp* tree, bool timed, bool ASTtimed, bool execVerbose, bool ASTrunVMKit)
 {
     if(tree == NULL)
     {
@@ -153,7 +156,7 @@ void execAstTask(ast::Exp* tree, bool timed, bool ASTtimed, bool execVerbose)
 
     if(execVerbose)
     {
-        exec = (ast::ExecVisitor*)new ast::StepVisitor();
+       exec = (ast::ExecVisitor*)new ast::StepVisitor();
     }
 
     if(!execVerbose && !ASTtimed)
@@ -161,8 +164,13 @@ void execAstTask(ast::Exp* tree, bool timed, bool ASTtimed, bool execVerbose)
         exec = new ast::ExecVisitor();
     }
 
-    Runner::execAndWait(tree, exec);
-    //delete exec;
+    if (ASTrunVMKit) {
+        printf("VMKit implementation goes here\n");
+        exit(1);
+    } else {
+        Runner::execAndWait(tree, exec);
+        //delete exec;
+    }
 
     if(timed)
     {
@@ -209,7 +217,7 @@ void execScilabStartTask(void)
         return;
     }
 
-    execAstTask(parse.getTree(), false, false, false);
+    execAstTask(parse.getTree(), false, false, false, ASTrunVMKit);
 }
 
 /*
@@ -231,7 +239,7 @@ void execScilabQuitTask(void)
         return;
     }
 
-    execAstTask(parse.getTree(), false, false, false);
+    execAstTask(parse.getTree(), false, false, false, ASTrunVMKit);
 }