summaryrefslogtreecommitdiffstats
path: root/scilab
diff options
context:
space:
mode:
authorCedric Delamarre <cdl@esi-group.com>2020-11-20 12:39:59 +0100
committerAntoine ELIAS <antoine.elias@esi-group.com>2020-11-23 15:24:34 +0100
commitbb5564fa32682509748445e555580c85e795cc25 (patch)
tree24cb7b9a79df4ce34104ae625e4c478eb6552057 /scilab
parent032909d24d16f00eab44148184aefdab8a987acb (diff)
downloadscilab-bb5564fa32682509748445e555580c85e795cc25.zip
scilab-bb5564fa32682509748445e555580c85e795cc25.tar.gz
callstack fixed, wrong file listed
Change-Id: I833d19cbfcee9db7dc25254120f92a2d905cd0d3
Diffstat (limited to 'scilab')
-rw-r--r--scilab/modules/ast/includes/system_env/configvariable.hxx6
-rw-r--r--scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp25
-rw-r--r--scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp38
-rw-r--r--scilab/modules/ast/src/cpp/system_env/configvariable.cpp10
-rw-r--r--scilab/modules/ast/src/cpp/types/macro.cpp6
-rw-r--r--scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp4
6 files changed, 47 insertions, 42 deletions
diff --git a/scilab/modules/ast/includes/system_env/configvariable.hxx b/scilab/modules/ast/includes/system_env/configvariable.hxx
index 0380faf..4a20992 100644
--- a/scilab/modules/ast/includes/system_env/configvariable.hxx
+++ b/scilab/modules/ast/includes/system_env/configvariable.hxx
@@ -485,10 +485,10 @@ public:
485 485
486 // executed file with exec 486 // executed file with exec
487private: 487private:
488 static int m_iFileID; 488 static std::wstring m_strFile;
489public: 489public:
490 static void setExecutedFileID(int _iFileID); 490 static void setExecutedFile(const std::wstring& _strFile);
491 static int getExecutedFileID(); 491 static const std::wstring& getExecutedFile();
492 492
493 // string read from console by scilabRead 493 // string read from console by scilabRead
494private: 494private:
diff --git a/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp b/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp
index 38438b1..fffeef8 100644
--- a/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp
+++ b/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp
@@ -25,7 +25,6 @@
25 25
26extern "C" 26extern "C"
27{ 27{
28#include "filemanager_interface.h"
29#include "FileExist.h" 28#include "FileExist.h"
30} 29}
31 30
@@ -252,20 +251,22 @@ void DebuggerVisitor::visit(const SeqExp &e)
252 setExpectedSize(iExpectedSize); 251 setExpectedSize(iExpectedSize);
253 types::InternalType * pIT = getResult(); 252 types::InternalType * pIT = getResult();
254 253
255 // In case of exec file, set the file name in the Macro to store where it is defined. 254 if(exp->isFunctionDec())
256 int iFileID = ConfigVariable::getExecutedFileID();
257 if (iFileID && exp->isFunctionDec())
258 { 255 {
259 types::InternalType* pITMacro = symbol::Context::getInstance()->get(exp->getAs<ast::FunctionDec>()->getSymbol()); 256 // In case of exec file, set the file name in the Macro to store where it is defined.
260 if (pITMacro) 257 std::wstring strFile = ConfigVariable::getExecutedFile();
258 const std::vector<ConfigVariable::WhereEntry>& lWhereAmI = ConfigVariable::getWhere();
259
260 if (strFile != L"" && // check if we are executing a script or a macro
261 lWhereAmI.empty() == false &&
262 lWhereAmI.back().m_file_name != nullptr && // check the last function execution is a macro
263 *(lWhereAmI.back().m_file_name) == strFile) // check the last execution is the same macro as the executed one
261 { 264 {
262 types::Macro* pMacro = pITMacro->getAs<types::Macro>(); 265 types::InternalType* pITMacro = symbol::Context::getInstance()->get(exp->getAs<FunctionDec>()->getSymbol());
263 const wchar_t* filename = getfile_filename(iFileID); 266 if (pITMacro)
264 // scilab.quit is not open with mopen
265 // in this case filename is NULL because FileManager have not been filled.
266 if (filename)
267 { 267 {
268 pMacro->setFileName(filename); 268 types::Macro* pMacro = pITMacro->getAs<types::Macro>();
269 pMacro->setFileName(strFile);
269 } 270 }
270 } 271 }
271 } 272 }
diff --git a/scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp b/scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp
index d650ecb..03dade1 100644
--- a/scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp
+++ b/scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp
@@ -36,16 +36,12 @@ void RunVisitorT<T>::visitprivate(const SeqExp &e)
36 if (e.getExecFrom() == SeqExp::EXEC) 36 if (e.getExecFrom() == SeqExp::EXEC)
37 { 37 {
38 //open input file to print exp from it 38 //open input file to print exp from it
39 int iFileID = ConfigVariable::getExecutedFileID(); 39 std::wstring strFile = ConfigVariable::getExecutedFile();
40 if (iFileID) 40 if (strFile != L"")
41 { 41 {
42 const wchar_t* filename = getfile_filename(iFileID); 42 char* cfilename = wide_string_to_UTF8(strFile.data());
43 if (filename) 43 file = new std::ifstream(cfilename);
44 { 44 FREE(cfilename);
45 char* cfilename = wide_string_to_UTF8(filename);
46 file = new std::ifstream(cfilename);
47 FREE(cfilename);
48 }
49 } 45 }
50 } 46 }
51 47
@@ -139,20 +135,22 @@ void RunVisitorT<T>::visitprivate(const SeqExp &e)
139 setExpectedSize(iExpectedSize); 135 setExpectedSize(iExpectedSize);
140 types::InternalType * pIT = getResult(); 136 types::InternalType * pIT = getResult();
141 137
142 // In case of exec file, set the file name in the Macro to store where it is defined. 138 if((*it)->isFunctionDec())
143 int iFileID = ConfigVariable::getExecutedFileID();
144 if (iFileID && (*it)->isFunctionDec())
145 { 139 {
146 types::InternalType* pITMacro = symbol::Context::getInstance()->get((*it)->getAs<FunctionDec>()->getSymbol()); 140 // In case of exec file, set the file name in the Macro to store where it is defined.
147 if (pITMacro) 141 std::wstring strFile = ConfigVariable::getExecutedFile();
142 const std::vector<ConfigVariable::WhereEntry>& lWhereAmI = ConfigVariable::getWhere();
143
144 if (strFile != L"" && // check if we are executing a script or a macro
145 lWhereAmI.empty() == false &&
146 lWhereAmI.back().m_file_name != nullptr && // check the last function execution is a macro
147 *(lWhereAmI.back().m_file_name) == strFile) // check the last execution is the same macro as the executed one
148 { 148 {
149 types::Macro* pMacro = pITMacro->getAs<types::Macro>(); 149 types::InternalType* pITMacro = symbol::Context::getInstance()->get((*it)->getAs<FunctionDec>()->getSymbol());
150 const wchar_t* filename = getfile_filename(iFileID); 150 if (pITMacro)
151 // scilab.quit is not open with mopen
152 // in this case filename is NULL because FileManager have not been filled.
153 if (filename)
154 { 151 {
155 pMacro->setFileName(filename); 152 types::Macro* pMacro = pITMacro->getAs<types::Macro>();
153 pMacro->setFileName(strFile);
156 } 154 }
157 } 155 }
158 } 156 }
diff --git a/scilab/modules/ast/src/cpp/system_env/configvariable.cpp b/scilab/modules/ast/src/cpp/system_env/configvariable.cpp
index 7845243..bf83d4f 100644
--- a/scilab/modules/ast/src/cpp/system_env/configvariable.cpp
+++ b/scilab/modules/ast/src/cpp/system_env/configvariable.cpp
@@ -1475,15 +1475,15 @@ std::string& ConfigVariable::getMexFunctionName()
1475** \} 1475** \}
1476*/ 1476*/
1477// executed file with exec 1477// executed file with exec
1478int ConfigVariable::m_iFileID = 0; 1478std::wstring ConfigVariable::m_strFile = L"";
1479void ConfigVariable::setExecutedFileID(int _iFileID) 1479void ConfigVariable::setExecutedFile(const std::wstring& _strFile)
1480{ 1480{
1481 m_iFileID = _iFileID; 1481 m_strFile = _strFile;
1482} 1482}
1483 1483
1484int ConfigVariable::getExecutedFileID() 1484const std::wstring& ConfigVariable::getExecutedFile()
1485{ 1485{
1486 return m_iFileID; 1486 return m_strFile;
1487} 1487}
1488 1488
1489/* 1489/*
diff --git a/scilab/modules/ast/src/cpp/types/macro.cpp b/scilab/modules/ast/src/cpp/types/macro.cpp
index 9b6599e..f845a3d 100644
--- a/scilab/modules/ast/src/cpp/types/macro.cpp
+++ b/scilab/modules/ast/src/cpp/types/macro.cpp
@@ -27,6 +27,7 @@
27#include "scilabWrite.hxx" 27#include "scilabWrite.hxx"
28#include "configvariable.hxx" 28#include "configvariable.hxx"
29#include "serializervisitor.hxx" 29#include "serializervisitor.hxx"
30#include "filemanager.hxx"
30 31
31extern "C" 32extern "C"
32{ 33{
@@ -331,21 +332,26 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
331 332
332 //save current prompt mode 333 //save current prompt mode
333 int oldVal = ConfigVariable::getPromptMode(); 334 int oldVal = ConfigVariable::getPromptMode();
335 std::wstring iExecFile = ConfigVariable::getExecutedFile();
334 std::unique_ptr<ast::ConstVisitor> exec (ConfigVariable::getDefaultVisitor()); 336 std::unique_ptr<ast::ConstVisitor> exec (ConfigVariable::getDefaultVisitor());
335 try 337 try
336 { 338 {
339 ConfigVariable::setExecutedFile(m_stPath);
337 ConfigVariable::setPromptMode(-1); 340 ConfigVariable::setPromptMode(-1);
338 m_body->accept(*exec); 341 m_body->accept(*exec);
339 //restore previous prompt mode 342 //restore previous prompt mode
340 ConfigVariable::setPromptMode(oldVal); 343 ConfigVariable::setPromptMode(oldVal);
344 ConfigVariable::setExecutedFile(iExecFile);
341 } 345 }
342 catch (const ast::InternalError& ie) 346 catch (const ast::InternalError& ie)
343 { 347 {
348 ConfigVariable::setExecutedFile(iExecFile);
344 cleanCall(pContext, oldVal); 349 cleanCall(pContext, oldVal);
345 throw ie; 350 throw ie;
346 } 351 }
347 catch (const ast::InternalAbort& ia) 352 catch (const ast::InternalAbort& ia)
348 { 353 {
354 ConfigVariable::setExecutedFile(iExecFile);
349 cleanCall(pContext, oldVal); 355 cleanCall(pContext, oldVal);
350 throw ia; 356 throw ia;
351 } 357 }
diff --git a/scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp b/scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp
index 15f9c6e..7d16abf 100644
--- a/scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp
+++ b/scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp
@@ -233,7 +233,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
233 233
234 ThreadManagement::UnlockParser(); 234 ThreadManagement::UnlockParser();
235 235
236 ConfigVariable::setExecutedFileID(iID); 236 ConfigVariable::setExecutedFile(wstFile);
237 } 237 }
238 else if (in[0]->isMacro() || in[0]->isMacroFile()) 238 else if (in[0]->isMacro() || in[0]->isMacroFile())
239 { 239 {
@@ -341,7 +341,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
341 { 341 {
342 closeFile(file, iID, wstFile, pExp); 342 closeFile(file, iID, wstFile, pExp);
343 ConfigVariable::setPromptMode(oldVal); 343 ConfigVariable::setPromptMode(oldVal);
344 ConfigVariable::setExecutedFileID(0); 344 ConfigVariable::setExecutedFile(L"");
345 throw ie; 345 throw ie;
346 } 346 }
347 347