macro print fixed. 49/15649/2
Cedric Delamarre [Thu, 4 Dec 2014 09:48:15 +0000 (10:48 +0100)]
function test()
end

myfunc = test

test_run("core","bug_10677",["no_check_error_output" ]);

Change-Id: Ie71b6eb8aee828710dd234f9a538061c4a0e5577

scilab/modules/ast/src/cpp/ast/run_AssignExp.cpp
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/types/list.cpp
scilab/modules/ast/src/cpp/types/macro.cpp
scilab/modules/ast/src/cpp/types/types_tools.cpp

index f447149..37931b6 100644 (file)
@@ -88,7 +88,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 ostr << wstrName << L"  = " << std::endl << std::endl;
                 scilabWriteW(ostr.str().c_str());
                 std::wostringstream ostrName;
-                ostrName << SPACES_LIST << wstrName;
+                ostrName << wstrName;
                 VariableToString(pIT, ostrName.str().c_str());
             }
             return;
@@ -165,15 +165,9 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 if (e.isVerbose() && ConfigVariable::isPromptShow())
                 {
                     std::wostringstream ostr;
-                    if (pCell)
-                    {
-                        const wstring *pstName = getStructNameFromExp(pCell);
-                        ostr << SPACES_LIST << pstName;
-                    }
-                    else
-                    {
-                        ostr << SPACES_LIST << L"???";
-                    }
+                    ostr << *getStructNameFromExp(pCell) << L"  = " << std::endl;
+                    ostr << std::endl;
+                    scilabWriteW(ostr.str().c_str());
 
                     VariableToString(pOut, ostr.str().c_str());
                 }
@@ -271,7 +265,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 scilabWriteW(ostr.str().c_str());
 
                 std::wostringstream ostrName;
-                ostrName << SPACES_LIST << *getStructNameFromExp(&pCall->getName());
+                ostrName << *getStructNameFromExp(&pCall->getName());
                 VariableToString(pOut, ostrName.str().c_str());
             }
 
@@ -380,7 +374,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 scilabWriteW(ostr.str().c_str());
 
                 std::wostringstream ostrName;
-                ostrName << SPACES_LIST << *pstName;
+                ostrName << *pstName;
                 VariableToString(pPrint, ostrName.str().c_str());
             }
 
index 65ee037..4e20b6b 100644 (file)
@@ -780,7 +780,7 @@ void RunVisitorT<T>::visitprivate(const SeqExp  &e)
                         //TODO manage multiple returns
                         scilabWriteW(L" ans  =\n\n");
                         std::wostringstream ostrName;
-                        ostrName << SPACES_LIST << L"ans";
+                        ostrName << L"ans";
                         VariableToString(pITAns, ostrName.str().c_str());
                     }
                 }
index 7c7cc76..eb16308 100644 (file)
@@ -133,7 +133,7 @@ bool List::toString(std::wostringstream& ostr)
         {
             std::wostringstream nextVarName;
             ostr.str(L"");
-            nextVarName << " " << wcsVarName << L"(" << iPosition << L")";
+            nextVarName << " " << SPACES_LIST << wcsVarName << L"(" << iPosition << L")";
             ostr << std::endl << nextVarName.str() << std::endl << std::endl;
             scilabWriteW(ostr.str().c_str());
             if (VariableToString(*itValues, nextVarName.str().c_str()) == types::Function::Error)
index b28943b..f433b2f 100644 (file)
@@ -98,6 +98,10 @@ ast::SeqExp* Macro::getBody(void)
 
 bool Macro::toString(std::wostringstream& ostr)
 {
+    // get macro name
+    wchar_t* wcsVarName = os_wcsdup(ostr.str().c_str());
+    ostr.str(L"");
+
     ostr << L"[";
 
     // output arguments [a,b,c] = ....
@@ -120,7 +124,7 @@ bool Macro::toString(std::wostringstream& ostr)
     ostr << L"]";
 
     // function name
-    ostr << L"=" << getName() << L"(";
+    ostr << L"=" << wcsVarName << L"(";
 
     // input arguments function(a,b,c)
     if (m_inputArgs->empty() == false)
@@ -140,6 +144,8 @@ bool Macro::toString(std::wostringstream& ostr)
     }
 
     ostr << L")" << std::endl;
+
+    FREE(wcsVarName);
     return true;
 }
 
index d08727a..ffc12af 100644 (file)
@@ -349,7 +349,7 @@ types::Function::ReturnValue VariableToString(types::InternalType* pIT, const wc
     else
     {
         std::wostringstream ostr;
-        if (pIT->isList())
+        if (pIT->isList() || pIT->isCallable())
         {
             ostr << wcsVarName;
         }