Skip to content

Commit cf618db

Browse files
perostOpenModelica-Hudson
authored andcommitted
Fix setCommandLineOptions with -d=newInst.
- Invalidate the builtin cache if the newInst flag is toggled via setCommandLineOptions. - Call execStatReset in Main.main to make sure the global root is always initialized. Belonging to [master]: - OpenModelica/OMCompiler#2067
1 parent 71f4da2 commit cf618db

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Compiler/Main/Main.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ protected
837837
GC.ProfStats stats;
838838
Integer seconds;
839839
algorithm
840+
execStatReset();
840841
try
841842
try
842843
args_1 := init(args);

Compiler/Script/CevalScript.mo

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,8 @@ algorithm
601601
SCode.Encapsulated encflag;
602602
SCode.Restriction restr;
603603
list<list<Values.Value>> valsLst;
604+
Boolean new_inst;
605+
604606
case (cache,_,"parseString",{Values.STRING(str1),Values.STRING(str2)},st,_)
605607
equation
606608
Absyn.PROGRAM(classes=classes,within_=within_) = Parser.parsestring(str1,str2);
@@ -935,8 +937,15 @@ algorithm
935937

936938
case (_,_,"setCommandLineOptions",{Values.STRING(str)},st,_)
937939
equation
940+
new_inst = Flags.isSet(Flags.SCODE_INST);
938941
args = System.strtok(str, " ");
939942
{} = Flags.readArgs(args);
943+
944+
// Invalidate the builtin cache if the newInst flag was toggled,
945+
// so we don't reuse the wrong builtin program.
946+
if new_inst <> Flags.isSet(Flags.SCODE_INST) then
947+
setGlobalRoot(Global.builtinIndex, {});
948+
end if;
940949
then
941950
(FCore.emptyCache(),Values.BOOL(true),st);
942951

0 commit comments

Comments
 (0)