Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 789abbe

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Handle running the same optimization module twice
Useful for testing if removeSimpleEquations helps when done multiple times...
1 parent 2933df6 commit 789abbe

File tree

1 file changed

+22
-33
lines changed

1 file changed

+22
-33
lines changed

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7819,43 +7819,28 @@ protected
78197819
algorithm
78207820
if forceOrdering then
78217821
for name in inStrOptModules loop
7822-
index := getModuleIndex(name, inOptModules);
7823-
7824-
if index < maxIndex then
7825-
Error.addCompilerWarning("Specified ordering will be ignored. Use --" + Flags.configFlagName(Flags.DEFAULT_OPT_MODULES_ORDERING) + "=false to override module ordering.");
7826-
maxIndex := numModules;
7827-
else
7828-
maxIndex := intMax(maxIndex, index);
7829-
end if;
7822+
for index in getModuleIndexes(name, inOptModules) loop
7823+
if index < maxIndex then
7824+
Error.addCompilerWarning("Specified ordering will be ignored. Use --" + Flags.configFlagName(Flags.DEFAULT_OPT_MODULES_ORDERING) + "=false to override module ordering.");
7825+
maxIndex := numModules;
7826+
else
7827+
maxIndex := intMax(maxIndex, index);
7828+
end if;
78307829

7831-
if index <> -1 then
78327830
activeModules[index] := true;
7833-
else
7834-
Error.addCompilerError("'" + name + "' is not a valid optimization module. Please check the flags carefully.");
7835-
fail();
7836-
end if;
7831+
end for;
78377832
end for;
78387833

78397834
for name in inEnabledModules loop
7840-
index := getModuleIndex(name, inOptModules);
7841-
7842-
if index <> -1 then
7835+
for index in getModuleIndexes(name, inOptModules) loop
78437836
activeModules[index] := true;
7844-
else
7845-
Error.addCompilerError("'" + name + "' is not a valid optimization module. Please check the flags carefully.");
7846-
fail();
7847-
end if;
7837+
end for;
78487838
end for;
78497839

78507840
for name in inDisabledModules loop
7851-
index := getModuleIndex(name, inOptModules);
7852-
7853-
if index <> -1 then
7841+
for index in getModuleIndexes(name, inOptModules) loop
78547842
activeModules[index] := false;
7855-
else
7856-
Error.addCompilerError("'" + name + "' is not a valid optimization module. Please check the flags carefully.");
7857-
fail();
7858-
end if;
7843+
end for;
78597844
end for;
78607845

78617846
for i in 1:numModules loop
@@ -7871,22 +7856,26 @@ algorithm
78717856
outOptModules := listReverse(outOptModules);
78727857
end selectOptModules;
78737858

7874-
protected function getModuleIndex
7859+
protected function getModuleIndexes
78757860
input String inModuleName;
78767861
input list<tuple<BackendDAEFunc.optimizationModule, String>> inModuleList;
7877-
output Integer outIndex = 1;
7862+
output list<Integer> outIndexes = {};
78787863
protected
78797864
String name;
7865+
Integer index=1;
78807866
algorithm
78817867
for module in inModuleList loop
78827868
(_, name) := module;
78837869
if stringEqual(inModuleName, name) then
7884-
return;
7870+
outIndexes := index::outIndexes;
78857871
end if;
7886-
outIndex := outIndex+1;
7872+
index := index+1;
78877873
end for;
7888-
outIndex := -1;
7889-
end getModuleIndex;
7874+
if listEmpty(outIndexes) then
7875+
Error.addCompilerError("'" + name + "' is not a valid optimization module. Please check the flags carefully.");
7876+
fail();
7877+
end if;
7878+
end getModuleIndexes;
78907879

78917880
protected function selectOptModules1
78927881
input String strOptModule;

0 commit comments

Comments
 (0)