* Bug 16191 fixed: now mode(0) and mode(1) are really compact.
[scilab.git] / scilab / modules / ast / src / cpp / ast / runvisitor.cpp
index 46937dd..dc7d63d 100644 (file)
@@ -126,7 +126,10 @@ void RunVisitorT<T>::visitprivate(const SimpleVar & e)
             ostr << L"(" << pI->getRef() << L")";
 #endif
             ostr << std::endl;
-            ostr << std::endl;
+            if (ConfigVariable::isPrintCompact() == false)
+            {
+                ostr << std::endl;                
+            }
             scilabWriteW(ostr.str().c_str());
             std::wostringstream ostrName;
             ostrName << e.getSymbol().getName();
@@ -513,15 +516,7 @@ void RunVisitorT<T>::visitprivate(const IfExp  &e)
         }
         else if (e.hasElse())
         {
-            const ast::Exp & _else = e.getElse();
-            if (_else.isCommentExp())
-            {
-                CoverageInstance::invoke(_else);
-            }
-            else
-            {
-                e.getElse().accept(*this);
-            }
+            e.getElse().accept(*this);
         }
     }
     catch (ScilabException &)
@@ -530,31 +525,37 @@ void RunVisitorT<T>::visitprivate(const IfExp  &e)
         throw;
     }
 
-    if (e.isBreakable()
-            && ((&e.getElse())->isBreak()
-                || (&e.getThen())->isBreak()))
+    bool elseIsBreak = e.hasElse() && (&e.getElse())->isBreak();
+    if (e.isBreakable() && (elseIsBreak || (&e.getThen())->isBreak()))
     {
         const_cast<IfExp*>(&e)->setBreak();
-        const_cast<Exp*>(&e.getElse())->resetBreak();
         const_cast<Exp*>(&e.getThen())->resetBreak();
+        if (e.hasElse())
+        {
+            const_cast<Exp*>(&e.getElse())->resetBreak();
+        }
     }
 
-    if (e.isContinuable()
-            && ((&e.getElse())->isContinue()
-                || (&e.getThen())->isContinue()))
+    bool elseIsContinue = e.hasElse() && (&e.getElse())->isContinue();
+    if (e.isContinuable() && (elseIsContinue || (&e.getThen())->isContinue()))
     {
         const_cast<IfExp*>(&e)->setContinue();
-        const_cast<Exp*>(&e.getElse())->resetContinue();
         const_cast<Exp*>(&e.getThen())->resetContinue();
+        if (e.hasElse())
+        {
+            const_cast<Exp*>(&e.getElse())->resetContinue();
+        }
     }
 
-    if (e.isReturnable()
-            && ((&e.getElse())->isReturn()
-                || (&e.getThen())->isReturn()))
+    bool elseIsReturn = e.hasElse() && (&e.getElse())->isReturn();
+    if (e.isReturnable() && (elseIsReturn || (&e.getThen())->isReturn()))
     {
         const_cast<IfExp*>(&e)->setReturn();
-        const_cast<Exp*>(&e.getElse())->resetReturn();
         const_cast<Exp*>(&e.getThen())->resetReturn();
+        if (e.hasElse())
+        {
+            const_cast<Exp*>(&e.getElse())->resetReturn();
+        }
     }
 
     CoverageInstance::stopChrono((void*)&e);
@@ -904,13 +905,6 @@ void RunVisitorT<T>::visitprivate(const ReturnExp &e)
     {
         if (ConfigVariable::getPauseLevel() != 0 && symbol::Context::getInstance()->getScopeLevel() == ConfigVariable::getActivePauseLevel())
         {
-            if (ConfigVariable::getEnableDebug() == true)
-            {
-                sciprint(_("%s: function is disabled in debug mode.\n"), "resume");
-                CoverageInstance::stopChrono((void*)&e);
-                return;
-            }
-
             //return or resume
             ConfigVariable::DecreasePauseLevel();
             ConfigVariable::macroFirstLine_end();
@@ -1425,6 +1419,10 @@ void RunVisitorT<T>::visitprivate(const FunctionDec & e)
     types::Macro *pMacro = new types::Macro(e.getSymbol().getName(), *pVarList, *pRetList,
                                             const_cast<SeqExp&>(static_cast<const SeqExp&>(e.getBody())), L"script");
     pMacro->setLines(e.getLocation().first_line, e.getLocation().last_line);
+    if (e.getMacro())
+    {
+        pMacro->setFileName(e.getMacro()->getFileName());
+    }
 
     if (ctx->isprotected(symbol::Symbol(pMacro->getName())))
     {
@@ -1469,12 +1467,13 @@ void RunVisitorT<T>::visitprivate(const ListExp &e)
     types::InternalType* pITStart = getResult();
     types::GenericType* pStart = static_cast<types::GenericType*>(pITStart);
     if (pITStart == NULL ||
-        ((pITStart->isGenericType() == false || pStart->getSize() != 1 || (pStart->isDouble() && pStart->getAs<types::Double>()->isComplex())) &&
-        pStart->isList() == false)) // list case => call overload
+            ((pITStart->isGenericType() == false || pStart->getSize() != 1 || (pStart->isDouble() && pStart->getAs<types::Double>()->isComplex())) &&
+             pStart->isList() == false)) // list case => call overload
     {
         setResult(NULL);
         wchar_t szError[bsiz];
-        if (pITStart && pITStart->isImplicitList()) {
+        if (pITStart && pITStart->isImplicitList())
+        {
             os_swprintf(szError, bsiz, _W("%ls: Too many %ls or wrong type for argument %d: Real scalar expected.\n").c_str(), L"':'", L"':'", 1);
         }
         else
@@ -1505,8 +1504,8 @@ void RunVisitorT<T>::visitprivate(const ListExp &e)
     types::GenericType* pStep = static_cast<types::GenericType*>(pITStep);
     setResult(NULL);
     if (pITStep == NULL ||
-        ((pITStep->isGenericType() == false || pStep->getSize() != 1 || (pStep->isDouble() && pStep->getAs<types::Double>()->isComplex())) &&
-        pStep->isList() == false)) // list case => call overload
+            ((pITStep->isGenericType() == false || pStep->getSize() != 1 || (pStep->isDouble() && pStep->getAs<types::Double>()->isComplex())) &&
+             pStep->isList() == false)) // list case => call overload
     {
         pITStart->killMe();
         if (pITStep)
@@ -1535,8 +1534,8 @@ void RunVisitorT<T>::visitprivate(const ListExp &e)
     types::GenericType* pEnd = static_cast<types::GenericType*>(pITEnd);
     setResult(NULL);
     if (pITEnd == NULL ||
-        ((pITEnd->isGenericType() == false || pEnd->getSize() != 1 || (pEnd->isDouble() && pEnd->getAs<types::Double>()->isComplex())) &&
-        pEnd->isList() == false)) // list case => call overload
+            ((pITEnd->isGenericType() == false || pEnd->getSize() != 1 || (pEnd->isDouble() && pEnd->getAs<types::Double>()->isComplex())) &&
+             pEnd->isList() == false)) // list case => call overload
     {
         pITStart->killMe();
         pITStep->killMe();
@@ -1994,7 +1993,7 @@ void RunVisitorT<T>::visitprivate(const TryCatchExp  &e)
         ConfigVariable::setSilentError(oldVal);
         //to lock lasterror
         ConfigVariable::setLastErrorCall();
-        // reset call stack filled when error occured
+        // reset call stack filled when error occurred
         ConfigVariable::resetWhereError();
         try
         {