Skip to content

Commit ab7bd52

Browse files
committed
- use Error.addCompilerWarning instead of print in BackendDAETransform.splitMixedEquations
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17843 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 386ceb9 commit ab7bd52

File tree

5 files changed

+158
-96
lines changed

5 files changed

+158
-96
lines changed

Compiler/BackEnd/BackendDAETransform.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,8 @@ algorithm
899899
then (contEqnLst, contVarLst, discEqnLst, discVarLst, indxcontEqnLst, indxcontVarLst, indxdiscEqnLst, indxdiscVarLst);
900900

901901
case (_, _, _, _) equation
902-
BackendDump.printVarList(varLst);
903-
BackendDump.printEquationList(eqnLst);
902+
Error.addCompilerWarning(BackendDump.varListString(varLst, "involved variables"));
903+
Error.addCompilerWarning(BackendDump.equationListString(eqnLst, "involved equations"));
904904
then fail();
905905
end matchcontinue;
906906
end splitMixedEquations;

Compiler/BackEnd/BackendDump.mo

Lines changed: 82 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,40 @@ algorithm
161161
oInteger := (i + 1,iscalar + size);
162162
end printEquationList2;
163163

164+
public function equationListString
165+
input list<BackendDAE.Equation> inEqns;
166+
input String heading;
167+
output String outString;
168+
algorithm
169+
outString := match(inEqns, heading)
170+
local
171+
String buffer;
172+
173+
case (_, "") equation
174+
((_, _, buffer)) = List.fold(inEqns, equationList2String, (1, 1, ""));
175+
then buffer;
176+
177+
else equation
178+
((_, _, buffer)) = List.fold(inEqns, equationList2String, (1, 1, ""));
179+
buffer = heading +& "\n" +& UNDERLINE +& "\n" +& buffer;
180+
then buffer;
181+
end match;
182+
end equationListString;
183+
184+
protected function equationList2String
185+
input BackendDAE.Equation inEquation;
186+
input tuple<Integer, Integer, String /*buffer*/> inTuple;
187+
output tuple<Integer, Integer, String /*buffer*/> outTuple;
188+
protected
189+
Integer iscalar, i, size;
190+
String buffer;
191+
algorithm
192+
(i, iscalar, buffer) := inTuple;
193+
size := BackendEquation.equationSize(inEquation);
194+
buffer := buffer +& intString(i) +& "/" +& intString(iscalar) +& " (" +& intString(size) +& "): " +& equationString(inEquation) +& "\n";
195+
outTuple := (i + 1, iscalar + size, buffer);
196+
end equationList2String;
197+
164198
public function printEquations ""
165199
input list<Integer> inIntegerLst;
166200
input BackendDAE.EqSystem syst;
@@ -282,7 +316,7 @@ algorithm
282316
debuglst((crstates,ComponentReference.printComponentRefStr,"\n","\n"));
283317
end printStateSet;
284318

285-
public function printVar ""
319+
public function printVar
286320
input BackendDAE.Var inVar;
287321
algorithm
288322
print(varString(inVar) +& "\n");
@@ -311,6 +345,40 @@ algorithm
311345
outVarNo := inVarNo + 1;
312346
end printVars1;
313347

348+
public function varListString
349+
input list<BackendDAE.Var> inVars;
350+
input String heading;
351+
output String outString;
352+
algorithm
353+
outString := match(inVars, heading)
354+
local
355+
String buffer;
356+
357+
case (_, "") equation
358+
((_, buffer)) = List.fold(inVars, var1String, (1, ""));
359+
then buffer;
360+
361+
else equation
362+
((_, buffer)) = List.fold(inVars, var1String, (1, ""));
363+
buffer = heading +& "\n" +& UNDERLINE +& "\n" +& buffer;
364+
then buffer;
365+
end match;
366+
end varListString;
367+
368+
protected function var1String
369+
input BackendDAE.Var inVar;
370+
input tuple<Integer /*inVarNo*/, String /*buffer*/> inTpl;
371+
output tuple<Integer /*outVarNo*/, String /*buffer*/> outTpl;
372+
protected
373+
Integer varNo;
374+
String buffer;
375+
algorithm
376+
(varNo, buffer) := inTpl;
377+
buffer := buffer +& intString(varNo) +& ": ";
378+
buffer := buffer +& varString(inVar) +& "\n";
379+
outTpl := (varNo + 1, buffer);
380+
end var1String;
381+
314382
protected function printExternalObjectClasses "dump classes of external objects"
315383
input BackendDAE.ExternalObjectClasses cls;
316384
algorithm
@@ -2828,19 +2896,20 @@ algorithm
28282896
local
28292897
array<Integer> ass1;
28302898
BackendDAE.StrongComponents comps;
2831-
case (BackendDAE.NO_MATCHING()) equation print("no matching\n"); then ();
2832-
case (BackendDAE.MATCHING(ass1,_,comps))
2833-
equation
2834-
dumpMatching(ass1);
2835-
print("\n\n");
2836-
dumpComponents(comps);
2837-
then
2838-
();
2839-
end match;
2899+
2900+
case (BackendDAE.NO_MATCHING()) equation
2901+
print("no matching\n");
2902+
then ();
2903+
2904+
case (BackendDAE.MATCHING(ass1, _, comps)) equation
2905+
dumpMatching(ass1);
2906+
print("\n\n");
2907+
dumpComponents(comps);
2908+
then ();
2909+
end match;
28402910
end dumpFullMatching;
28412911

2842-
public function dumpMatching
2843-
"author: PA
2912+
public function dumpMatching "author: PA
28442913
prints the matching information on stdout."
28452914
input array<Integer> v;
28462915
protected
@@ -2856,8 +2925,7 @@ algorithm
28562925
dumpMatching2(v, 1, len);
28572926
end dumpMatching;
28582927

2859-
protected function dumpMatching2
2860-
"author: PA
2928+
protected function dumpMatching2 "author: PA
28612929
Helper function to dumpMatching."
28622930
input array<Integer> v;
28632931
input Integer i;

Compiler/BackEnd/Initialization.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ algorithm
185185
initdae = BackendDAEUtil.transformBackendDAE(initdae, SOME((BackendDAE.NO_INDEX_REDUCTION(), BackendDAE.EXACT())), NONE(), NONE());
186186

187187
// simplify system
188-
(initdae, Util.SUCCESS()) = BackendDAEUtil.postOptimizeDAE(initdae, pastOptModules, matchingAlgorithm, daeHandler);
188+
(initdae, Util.SUCCESS()) = BackendDAEUtil.postOptimizeDAE(initdae, pastOptModules, matchingAlgorithm, daeHandler);
189189
Debug.fcall2(Flags.DUMP_INITIAL_SYSTEM, BackendDump.dumpBackendDAE, initdae, "solved initial system");
190190

191191
// warn about selected default initial conditions

Compiler/BackEnd/Uncertainties.mo

Lines changed: 60 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,111 +2196,92 @@ public function applyOptionSimplify
21962196
input Option<DAE.Exp> bindExpIn;
21972197
output Option<DAE.Exp> bindExpOut;
21982198
algorithm
2199-
bindExpOut:=
2200-
match (bindExpIn)
2199+
bindExpOut := match(bindExpIn)
22012200
local
2202-
DAE.Exp e,e1;
2203-
case (NONE()) then NONE();
2204-
case (SOME(e))
2205-
equation
2206-
(e1,_) = ExpressionSimplify.simplify1(e);
2207-
then
2208-
SOME(e1);
2201+
DAE.Exp e, e1;
2202+
2203+
case NONE()
2204+
then NONE();
2205+
2206+
case SOME(e) equation
2207+
(e1,_) = ExpressionSimplify.simplify1(e);
2208+
then SOME(e1);
22092209
end match;
22102210
end applyOptionSimplify;
22112211

2212-
public function setVarCref "
2213-
author: PA
2214-
2215-
sets the ComponentRef of a variable.
2216-
"
2212+
public function setVarCref "author: PA
2213+
Sets the ComponentRef of a variable."
22172214
input BackendDAE.Var inVar;
22182215
input DAE.ComponentRef cr;
22192216
output BackendDAE.Var outVar;
2220-
algorithm
2221-
outVar := match (inVar,cr)
2222-
local
2223-
DAE.ComponentRef name;
2224-
BackendDAE.VarKind kind;
2225-
DAE.VarDirection dir;
2226-
DAE.VarParallelism prl;
2227-
DAE.Type tp;
2228-
Option<DAE.Exp> bind ;
2229-
Option<Values.Value> bindval;
2230-
DAE.InstDims ad;
2231-
DAE.ElementSource source;
2232-
Option<DAE.VariableAttributes> attr;
2233-
Option<SCode.Comment> cmt;
2234-
DAE.ConnectorType ct;
2235-
case (BackendDAE.VAR(name,kind,dir,prl,tp,bind,bindval,ad,source,attr,cmt,ct),_) then
2236-
BackendDAE.VAR(cr,kind,dir,prl,tp,bind,bindval,ad,source,attr,cmt,ct);
2237-
end match;
2217+
protected
2218+
DAE.ComponentRef name;
2219+
BackendDAE.VarKind kind;
2220+
DAE.VarDirection dir;
2221+
DAE.VarParallelism prl;
2222+
DAE.Type tp;
2223+
Option<DAE.Exp> bind ;
2224+
Option<Values.Value> bindval;
2225+
DAE.InstDims ad;
2226+
DAE.ElementSource source;
2227+
Option<DAE.VariableAttributes> attr;
2228+
Option<SCode.Comment> cmt;
2229+
DAE.ConnectorType ct;
2230+
algorithm
2231+
BackendDAE.VAR(name,kind,dir,prl,tp,bind,bindval,ad,source,attr,cmt,ct) := inVar;
2232+
outVar := BackendDAE.VAR(cr,kind,dir,prl,tp,bind,bindval,ad,source,attr,cmt,ct);
22382233
end setVarCref;
22392234

2240-
public function setVarBindingOpt "
2241-
author: PA
2242-
2243-
sets the optional binding of a variable.
2244-
"
2235+
public function setVarBindingOpt "author: PA
2236+
Sets the optional binding of a variable."
22452237
input BackendDAE.Var inVar;
22462238
input Option<DAE.Exp> bindExp;
22472239
output BackendDAE.Var outVar;
2248-
algorithm
2249-
outVar := match (inVar,bindExp)
2250-
local
2251-
DAE.ComponentRef name;
2252-
BackendDAE.VarKind kind;
2253-
DAE.VarDirection dir;
2254-
DAE.VarParallelism prl;
2255-
BackendDAE.Type tp;
2256-
Option<DAE.Exp> bind ;
2257-
Option<Values.Value> bindval;
2258-
DAE.InstDims ad;
2259-
DAE.ElementSource source;
2260-
Option<DAE.VariableAttributes> attr;
2261-
Option<SCode.Comment> cmt;
2262-
DAE.ConnectorType ct;
2263-
case (BackendDAE.VAR(name,kind,dir,prl,tp,bind,bindval,ad,source,attr,cmt,ct),_) then
2264-
BackendDAE.VAR(name,kind,dir,prl,tp,bindExp,bindval,ad,source,attr,cmt,ct);
2265-
end match;
2240+
protected
2241+
DAE.ComponentRef name;
2242+
BackendDAE.VarKind kind;
2243+
DAE.VarDirection dir;
2244+
DAE.VarParallelism prl;
2245+
BackendDAE.Type tp;
2246+
Option<DAE.Exp> bind ;
2247+
Option<Values.Value> bindval;
2248+
DAE.InstDims ad;
2249+
DAE.ElementSource source;
2250+
Option<DAE.VariableAttributes> attr;
2251+
Option<SCode.Comment> cmt;
2252+
DAE.ConnectorType ct;
2253+
algorithm
2254+
BackendDAE.VAR(name,kind,dir,prl,tp,bind,bindval,ad,source,attr,cmt,ct) := inVar;
2255+
outVar := BackendDAE.VAR(name,kind,dir,prl,tp,bindExp,bindval,ad,source,attr,cmt,ct);
22662256
end setVarBindingOpt;
22672257

22682258
public function moveVariables "
22692259
This function takes the two variable lists of a dae (states+alg) and
22702260
known vars and moves a set of variables from the first to the second set.
22712261
This function is needed to manage this in complexity O(n) by only
2272-
traversing the set once for all variables.
2273-
"
2262+
traversing the set once for all variables."
22742263
input BackendDAE.Variables inVariables1;
22752264
input BackendDAE.Variables inVariables2;
22762265
input HashTable.HashTable hashTable;
22772266
output BackendDAE.Variables outVariables1;
22782267
output BackendDAE.Variables outVariables2;
2279-
algorithm
2280-
(outVariables1,outVariables2) := match (inVariables1,inVariables2,hashTable)
2281-
local
2282-
list<BackendDAE.Var> lst1,lst2,lst1_1,lst2_1;
2283-
BackendDAE.Variables v1,v2,vars,knvars,vars1,vars2;
2284-
HashTable.HashTable mvars;
2285-
case (vars1,vars2,mvars)
2286-
equation
2287-
lst1 = BackendVariable.varList(vars1);
2288-
lst2 = BackendVariable.varList(vars2);
2289-
(lst1_1,lst2_1) = moveVariables2(lst1, lst2, mvars);
2290-
v1 = BackendVariable.emptyVars();
2291-
v2 = BackendVariable.emptyVars();
2292-
//vars = addVarsNoUpdCheck(lst1_1, v1);
2293-
vars = BackendVariable.addVars(lst1_1, v1);
2294-
//knvars = addVarsNoUpdCheck(lst2_1, v2);
2295-
knvars = BackendVariable.addVars(lst2_1, v2);
2296-
then
2297-
(vars,knvars);
2298-
end match;
2268+
protected
2269+
list<BackendDAE.Var> lst1, lst2, lst1_1, lst2_1;
2270+
BackendDAE.Variables v1, v2, vars, knvars;
2271+
algorithm
2272+
lst1 := BackendVariable.varList(inVariables1);
2273+
lst2 := BackendVariable.varList(inVariables2);
2274+
(lst1_1, lst2_1) := moveVariables2(lst1, lst2, hashTable);
2275+
v1 := BackendVariable.emptyVars();
2276+
v2 := BackendVariable.emptyVars();
2277+
//vars := addVarsNoUpdCheck(lst1_1, v1);
2278+
outVariables1 := BackendVariable.addVars(lst1_1, v1);
2279+
//knvars := addVarsNoUpdCheck(lst2_1, v2);
2280+
outVariables2 := BackendVariable.addVars(lst2_1, v2);
22992281
end moveVariables;
23002282

23012283
protected function moveVariables2 "
2302-
helper function to move_variables.
2303-
"
2284+
Helper function to moveVariables."
23042285
input list<BackendDAE.Var> inVarLst1;
23052286
input list<BackendDAE.Var> inVarLst2;
23062287
input HashTable.HashTable hashTable;

Compiler/Util/Error.mo

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,4 +1121,17 @@ algorithm
11211121
end match;
11221122
end addCompilerWarning;
11231123

1124+
public function addCompilerNotification
1125+
"Used to make a compiler notification"
1126+
input String message;
1127+
algorithm
1128+
_ := match (message)
1129+
case _
1130+
equation
1131+
addMessage(COMPILER_NOTIFICATION, {message});
1132+
then
1133+
();
1134+
end match;
1135+
end addCompilerNotification;
1136+
11241137
end Error;

0 commit comments

Comments
 (0)