* [#16193](https://bugzilla.scilab.org/16193): `covStart()` clear previous coverage information. `profileEnable()` could be use to append a macro later on.
* [#16196](https://bugzilla.scilab.org/16196): `covStart()` help page was incomplete about the API usage.
* [#16274](https://bugzilla.scilab.org/16274): assert_checkequal() did not considered equal matching Nan or void elements in (nested) containers.
+* [#16297](https://bugzilla.scilab.org/16297): After function test(), e={}, endfunction; macr2tree(test) crashes Scilab.
* [#16337](https://bugzilla.scilab.org/16337): The 3rd output of `[U,km,ku] = unique(..)` was not implemented.
* [#16342](https://bugzilla.scilab.org/16342): `strcat()` was much slower in Scilab 6.0.2.
* [#16350](https://bugzilla.scilab.org/16350): in if/while conditions, the empty sparse boolean was considered as TRUE.
* [#16549](https://bugzilla.scilab.org/16549): simple script crashed Scilab in GUI mode.
* [#16551](https://bugzilla.scilab.org/16551): `num2cell` returned {} for any input array of empty strings.
* [#16553](https://bugzilla.scilab.org/16553): `unique(["" ""])` returned `["" ""]`.
+* [#16557](https://bugzilla.scilab.org/16557): `macr2tree` + `tree2code` translated `e={2}` into `"e=1"` and `e={2,"ab"}` into `"e=[2,"ab"]"`.
### Bugs fixed in 6.1.0:
virtual void visit(const NotExp &e);
virtual void visit(const TransposeExp &e);
virtual void visit(const FunctionDec &e);
+ virtual void visit(const CellExp &e);
inline types::List* getList()
{
static types::List* createOperation();
static types::List* createAssign();
static types::InternalType* getVerbose(const Exp& e);
+ static types::List* matrixOrCellExp(const exps_t& lines, TreeVisitor& me, const std::wstring& what);
types::InternalType* getEOL();
private:
#include "printvisitor.hxx"
#include "execvisitor.hxx"
#include "token.hxx"
+#include "cell.hxx"
extern "C"
{
return;
}
- types::List* sub = createOperation();
- types::List* ope = new types::List();
-
- int idx = 0;
- for (auto it : lines)
- {
- it->accept(*this);
-
- if (idx >= 2)
- {
- sub->append(ope);
- ope->killMe();
- sub->append(new types::String(L"cc"));
+ l = matrixOrCellExp(lines, *this, L"cc");
+}
- //create a new operation
- //put previous stage in lhs and
- //result in rhs
- types::List* subcolcatOperation = createOperation();
- types::List* subcolcatOperands = new types::List();
- subcolcatOperands->append(sub);
- sub->killMe();
- //add EOL
- //subcolcatOperands->append(getEOL());
- types::InternalType* tmp = getList();
- subcolcatOperands->append(tmp);
- tmp->killMe();
+void TreeVisitor::visit(const CellExp &e)
+{
+ exps_t lines = e.getLines();
- ope = subcolcatOperands;
- sub = subcolcatOperation;
- }
- else
- {
- types::InternalType* tmp = getList();
- ope->append(tmp);
- tmp->killMe();
- }
+ if (lines.size() == 0)
+ {
+ l = createConst(new types::Cell());
+ return;
+ }
- ++idx;
+ if (lines.size() == 1)
+ {
+ lines.front()->accept(*this);
+ types::List* pL = getList();
+ pL->get(pL->getSize() - 1)->getAs<types::String>()->set(0, L"crc");
+ return;
}
- sub->append(ope);
- ope->killMe();
- sub->append(new types::String(L"cc"));
- l = sub;
+
+ l = matrixOrCellExp(lines, *this, L"ccc");
}
void TreeVisitor::visit(const MatrixLineExp &e)
return new types::String(L";");
}
}
+
+types::List* TreeVisitor::matrixOrCellExp(const exps_t& lines, TreeVisitor& me, const std::wstring& what)
+{
+ types::List* sub = createOperation();
+ types::List* ope = new types::List();
+
+ int idx = 0;
+ for (auto it : lines)
+ {
+ it->accept(me);
+
+ if (idx >= 2)
+ {
+ sub->append(ope);
+ ope->killMe();
+ sub->append(new types::String(what.data()));
+
+ //create a new operation
+ //put previous stage in lhs and
+ //result in rhs
+ types::List* subcolcatOperation = createOperation();
+ types::List* subcolcatOperands = new types::List();
+ subcolcatOperands->append(sub);
+ sub->killMe();
+ //add EOL
+ //subcolcatOperands->append(getEOL());
+ types::InternalType* tmp = me.getList();
+ subcolcatOperands->append(tmp);
+ tmp->killMe();
+
+ ope = subcolcatOperands;
+ sub = subcolcatOperation;
+ }
+ else
+ {
+ types::InternalType* tmp = me.getList();
+ ope->append(tmp);
+ tmp->killMe();
+ }
+
+ ++idx;
+ }
+ sub->append(ope);
+ ope->killMe();
+ sub->append(new types::String(what.data()));
+ return sub;
+}
}
// ---------
case "operation" then
operator=e.operator
+ bracket = ["[", "]"];
+ // if Cell Exp {}
+ if or(operator == ["ccc", "crc"]) then
+ operator = part(operator, 2:$);
+ bracket = ["{", "}"];
+ end
+
operands=[]
nb_op=size(e.operands)
if and(operator<>["cc","cceol"]) then
end
end
end
- C="["+strcat(operands,",")+"]"
+ C=bracket(1)+strcat(operands,",")+bracket(2);
// Multi-line column concatenation
elseif operator=="cceol" then
for i=1:nb_op
end
if i==1 then
- C="["
+ C=bracket(1)
if size(opi,"*")>1 then
C = [C+opi(1);opi(2:$)]
else
else
C = [C(1:$-1);C($)+opi]
end
- C($)=C($)+"]"
+ C($)=C($)+bracket(2)
end
end
// Column concatenation
elseif operator=="cc" then
- C="["
+ C=bracket(1)
for i=1:nb_op
opi=expression2code(e.operands(i))
// Delete [ and ] if there are...
end
end
end
- C($)=C($)+"]"
+ C($)=C($)+bracket(2)
// Extraction
elseif operator=="ext" then
if size(e.operands)==1 then
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2020 - ESI Group - Cedric Delamarre
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+// <-- Non-regression test for bug 16297 -->
+//
+// <-- Bugzilla URL -->
+// https://bugzilla.scilab.org/show_bug.cgi?id=16297
+//
+// <-- Short Description -->
+// After function test(), e={}, endfunction; macr2tree(test) crashes Scilab
+
+function test()
+ e = {};
+ e = {1,2};
+ e = {1,2;3,4};
+endfunction
+t=macr2tree(test);
+
+result = ["function test()"; ...
+ "e = {};"; ...
+ "e = {1,2};"; ...
+ "e = {1,2;3,4};"; ...
+ "endfunction"; ...
+ "" ];
+
+assert_checkequal(tree2code(t), result);
\ No newline at end of file