Skip to content

Commit 1597fe0

Browse files
authored
Fix Interactive.evaluateGraphicalApi_dispatch (#8662)
- Have all API functions update the Absyn themselves if needed, instead of trusting that they return the updated Absyn. Since e.g. the NF can load libraries on demand we don't always know if the Absyn was changed or not, and setting it at the end of evaluateGraphicalApi_dispatch can overwrite any changes made.
1 parent de06db4 commit 1597fe0

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

OMCompiler/Compiler/Script/Interactive.mo

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ algorithm
944944
Absyn.CREF(componentRef = cr),
945945
Absyn.CODE(code = Absyn.C_MODIFICATION(modification = mod))} := args;
946946
(p, outResult) := setComponentModifier(class_, cr, mod, p);
947+
SymbolTable.setAbsyn(p);
947948
then
948949
outResult;
949950

@@ -957,13 +958,15 @@ algorithm
957958
case Absyn.C_ELEMENT(element = el) then fail();
958959
end match;
959960
(p, outResult) := InteractiveUtil.setElementModifier(class_, cr, mod, p);
961+
SymbolTable.setAbsyn(p);
960962
then
961963
outResult;
962964

963965
case "setParameterValue"
964966
algorithm
965967
{Absyn.CREF(componentRef = class_), Absyn.CREF(componentRef = crident), exp} := args;
966968
(p, outResult) := setParameterValue(class_, crident, exp, p);
969+
SymbolTable.setAbsyn(p);
967970
then
968971
outResult;
969972

@@ -973,13 +976,15 @@ algorithm
973976
Absyn.CREF(componentRef = cr),
974977
Absyn.ARRAY(dimensions)} := args;
975978
(p, outResult) := setComponentDimensions(class_, cr, dimensions, p);
979+
SymbolTable.setAbsyn(p);
976980
then
977981
outResult;
978982

979983
case "createModel"
980984
algorithm
981985
{Absyn.CREF(componentRef = cr)} := args;
982986
p := createModel(cr, p);
987+
SymbolTable.setAbsyn(p);
983988
then
984989
"true";
985990

@@ -992,6 +997,7 @@ algorithm
992997
Absyn.PROGRAM({
993998
Absyn.CLASS(name,false,false,false,Absyn.R_MODEL(),AbsynUtil.dummyParts,AbsynUtil.dummyInfo)
994999
}, Absyn.WITHIN(path)), p);
1000+
SymbolTable.setAbsyn(p);
9951001
then
9961002
"true";
9971003

@@ -1000,6 +1006,7 @@ algorithm
10001006
algorithm
10011007
{Absyn.CREF(componentRef = cr)} := args;
10021008
(outResult, p) := deleteClass(cr, p);
1009+
SymbolTable.setAbsyn(p);
10031010
then
10041011
outResult;
10051012

@@ -1010,6 +1017,7 @@ algorithm
10101017
Absyn.CREF(componentRef = model_)} := args;
10111018
nargs := getApiFunctionNamedArgs(inStatement);
10121019
p := addComponent(name, tp, model_, nargs, p);
1020+
SymbolTable.setAbsyn(p);
10131021
Print.clearBuf();
10141022
then
10151023
"true";
@@ -1021,6 +1029,7 @@ algorithm
10211029
Absyn.CREF(componentRef = model_)} := args;
10221030
nargs := getApiFunctionNamedArgs(inStatement);
10231031
(p, outResult) := updateComponent(name, tp, model_, nargs, p);
1032+
SymbolTable.setAbsyn(p);
10241033
then
10251034
outResult;
10261035

@@ -1030,6 +1039,7 @@ algorithm
10301039
Absyn.CREF(componentRef = model_)} := args;
10311040
{} := getApiFunctionNamedArgs(inStatement);
10321041
p := deleteOrUpdateComponent(name, model_, p, NONE());
1042+
SymbolTable.setAbsyn(p);
10331043
Print.clearBuf();
10341044
then "true";
10351045

@@ -1180,6 +1190,7 @@ algorithm
11801190
Absyn.CREF(componentRef = cr2),
11811191
Absyn.STRING(value = cmt)} := args;
11821192
(p, outResult) := setConnectionComment(cr, cr1, cr2, cmt, p);
1193+
SymbolTable.setAbsyn(p);
11831194
then
11841195
outResult;
11851196

@@ -1190,6 +1201,7 @@ algorithm
11901201
Absyn.CREF(componentRef = cr)} := args;
11911202
nargs := getApiFunctionNamedArgs(inStatement);
11921203
(outResult, p) := addConnection(cr, cr1, cr2, nargs, p);
1204+
SymbolTable.setAbsyn(p);
11931205
then
11941206
outResult;
11951207

@@ -1199,6 +1211,7 @@ algorithm
11991211
Absyn.CREF(componentRef = cr2),
12001212
Absyn.CREF(componentRef = cr)} := args;
12011213
(outResult, p) := deleteConnection(cr, cr1, cr2, p);
1214+
SymbolTable.setAbsyn(p);
12021215
then
12031216
outResult;
12041217

@@ -1357,6 +1370,7 @@ algorithm
13571370
cls := InteractiveUtil.getPathedClassInProgram(AbsynUtil.crefToPath(cr), p);
13581371
cls := Refactor.refactorGraphicalAnnotation(p, cls);
13591372
p := InteractiveUtil.updateProgram(Absyn.PROGRAM({cls}, Absyn.TOP()), p);
1373+
SymbolTable.setAbsyn(p);
13601374
outResult := Dump.unparseStr(Absyn.PROGRAM({cls}, Absyn.TOP()), false);
13611375
else
13621376
outResult := "Failed in translating " + Dump.printComponentRefStr(cr)
@@ -1458,6 +1472,7 @@ algorithm
14581472
// For now, renaming a class clears all caches...
14591473
// Substantial analysis required to find out what to keep in cache and what must be thrown out
14601474
(outResult, p) := renameClass(p, old_cname, new_cname);
1475+
SymbolTable.setAbsyn(p);
14611476
then
14621477
outResult;
14631478

@@ -1467,6 +1482,7 @@ algorithm
14671482
Absyn.CREF(componentRef = old_cname),
14681483
Absyn.CREF(componentRef = new_cname)} := args;
14691484
(outResult, p) := renameComponent(p, cr, old_cname, new_cname);
1485+
SymbolTable.setAbsyn(p);
14701486
then outResult;
14711487

14721488
case "renameComponentInClass"
@@ -1475,6 +1491,7 @@ algorithm
14751491
Absyn.CREF(componentRef = old_cname),
14761492
Absyn.CREF(componentRef = new_cname)} := args;
14771493
(outResult, p) := renameComponentOnlyInClass(p, cr, old_cname, new_cname);
1494+
SymbolTable.setAbsyn(p);
14781495
then outResult;
14791496

14801497
case "getCrefInfo"
@@ -1490,6 +1507,7 @@ algorithm
14901507
Absyn.CREF(componentRef = subident),
14911508
Absyn.CODE(code = Absyn.C_MODIFICATION(modification = mod))} := args;
14921509
(p, outResult) := setExtendsModifierValue(class_, crident, subident, mod, p);
1510+
SymbolTable.setAbsyn(p);
14931511
then
14941512
outResult;
14951513

@@ -1549,6 +1567,7 @@ algorithm
15491567
Absyn.CREF(componentRef = cr),
15501568
Absyn.STRING(value = cmt)} := args;
15511569
(outResult, p) := setComponentComment(class_, cr, cmt, p);
1570+
SymbolTable.setAbsyn(p);
15521571
then
15531572
outResult;
15541573

@@ -1580,6 +1599,7 @@ algorithm
15801599
(outResult, p) := setComponentProperties(AbsynUtil.crefToPath(class_), cr,
15811600
finalPrefix, flowPrefix, streamPrefix, protected_, repl,
15821601
/*parallelism,*/ variability, {dref1,dref2}, causality, p/*, isField*/);
1602+
SymbolTable.setAbsyn(p);
15831603
then
15841604
outResult;
15851605

@@ -1631,8 +1651,6 @@ algorithm
16311651
stringAppendList({"\"", outResult, "\""});
16321652

16331653
end match;
1634-
1635-
SymbolTable.setAbsyn(p);
16361654
end evaluateGraphicalApi_dispatch;
16371655

16381656
protected function extractAllComponentreplacements

0 commit comments

Comments
 (0)