returnExp fixed. 19/15219/4
Cedric Delamarre [Fri, 12 Sep 2014 16:27:04 +0000 (18:27 +0200)]
function test()
return
endfunction

pause
return

pause
// must stay in pause lvl 1
test
return

Change-Id: Iba7d8fb4075660797761d4c822e64fde1a7fb0fa

scilab/modules/ast/includes/symbol/context.hxx
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/symbol/context.cpp

index 80b04ed..b0f5bcf 100644 (file)
@@ -118,6 +118,8 @@ public :
     bool addMacro(types::Macro *_info);
     bool addMacroFile(types::MacroFile *_info);
     void print(std::wostream& ostr) const;
+    int getScopeLevel();
+
 private :
 
     types::InternalType* get(const Symbol& key, int _iLevel);
index 16a6c6c..5ce4121 100644 (file)
@@ -471,9 +471,9 @@ void RunVisitorT<T>::visitprivate(const ReturnExp &e)
 {
     if (e.isGlobal())
     {
-        //return or resume
-        if (ConfigVariable::getPauseLevel() != 0)
+        if (ConfigVariable::getPauseLevel() != 0 && symbol::Context::getInstance()->getScopeLevel() == 1)
         {
+            //return or resume
             ThreadId* pThreadId = ConfigVariable::getLastPausedThread();
             if (pThreadId == NULL)
             {
@@ -504,35 +504,6 @@ void RunVisitorT<T>::visitprivate(const ReturnExp &e)
         setExpectedSize(1);
         e.getExp().accept(*this);
         setExpectedSize(iSaveExpectedSize);
-
-        if (getResultSize() == 1)
-        {
-            //protect variable
-            getResult()->IncreaseRef();
-        }
-        else
-        {
-            for (int i = 0 ; i < getResultSize() ; i++)
-            {
-                //protect variable
-                getResult(i)->IncreaseRef();
-            }
-        }
-
-        if (getResultSize() == 1)
-        {
-            //unprotect variable
-            getResult()->DecreaseRef();
-        }
-        else
-        {
-            for (int i = 0 ; i < getResultSize() ; i++)
-            {
-                //unprotect variable
-                getResult(i)->DecreaseRef();
-            }
-        }
-
         const_cast<ReturnExp*>(&e)->setReturn();
     }
 }
index 09c17e1..5f70ba1 100644 (file)
@@ -340,4 +340,8 @@ void Context::print(std::wostream& ostr) const
     ostr << L"==========================" << std::endl;
 }
 
+int Context::getScopeLevel()
+{
+    return m_iLevel;
+}
 }