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

Commit 08ea75e

Browse files
committed
replace parameters in external objects, extend simCodeDebugDump
1 parent db19191 commit 08ea75e

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

Compiler/BackEnd/BackendVarTransform.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,7 @@ algorithm
25882588
case(BackendDAE.VAR(bindExp=SOME(exp)),_)
25892589
equation
25902590
exp = replaceExp(exp,repl,NONE());
2591+
(exp,_) = ExpressionSimplify.simplify(exp);
25912592
then BackendVariable.setBindExp(varIn,SOME(exp));
25922593
case(BackendDAE.VAR(bindExp=NONE()),_)
25932594
then varIn;

Compiler/BackEnd/EvaluateParameter.mo

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ algorithm
308308
print("markarr: " + stringDelimitList(List.map(arrayList(markarr), intString), ",") + "\n");
309309
end if;
310310

311+
// replace evaluated parameter in external objects
312+
shared.externalObjects := BackendVariable.listVar1(List.map1(BackendVariable.varList(shared.externalObjects),BackendVarTransform.replaceBindingExp,repl));
313+
311314
shared.globalKnownVars := globalKnownVars;
312315
shared.aliasVars := aliasVars;
313316
shared.initialEqs := initialEqs;

Compiler/SimCode/SimCodeUtil.mo

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7269,28 +7269,28 @@ algorithm
72697269
SimCodeVar.AliasVariable aliasvar;
72707270
String s1, s2, s3, sProt;
72717271
list<String> numArrayElement;
7272-
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NOALIAS(), index = i, initialValue=init, arrayCref=arrCref,variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
7272+
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NOALIAS(), index = i, initialValue=init, arrayCref=arrCref, variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
72737273
equation
72747274
s1 = ComponentReference.printComponentRefStr(name);
72757275
if Util.isSome(arrCref) then s3 = " \tarrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3="\tno arrCref"; end if;
72767276
sProt = if isProtected then " protected " else "";
72777277
s = "index: "+intString(i)+": "+s1+" (no alias) "+sProt+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
72787278
then s;
7279-
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.ALIAS(varName = name2), arrayCref=arrCref,variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
7279+
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.ALIAS(varName = name2), index = i, initialValue=init, arrayCref=arrCref, variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
72807280
equation
72817281
s1 = ComponentReference.printComponentRefStr(name);
72827282
s2 = ComponentReference.printComponentRefStr(name2);
72837283
sProt = if isProtected then " protected "else "";
7284-
if Util.isSome(arrCref) then s3 = " arrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3=""; end if;
7285-
s = "index: "+printVarIndx(variable_index) +": "+s1+" (alias: "+s2+s3+") "+sProt+" [" + stringDelimitList(numArrayElement,",")+"] ";
7284+
if Util.isSome(arrCref) then s3 = " \tarrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3="\tno arrCref"; end if;
7285+
s = "index: "+intString(i)+": "+s1+" (alias: "+s2+") "+sProt+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
72867286
then s;
7287-
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NEGATEDALIAS(varName = name2), arrayCref=arrCref,variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
7287+
case (SimCodeVar.SIMVAR(name= name, aliasvar = SimCodeVar.NEGATEDALIAS(varName = name2), index = i, initialValue=init, arrayCref=arrCref,variable_index=variable_index, numArrayElement=numArrayElement, isProtected=isProtected))
72887288
equation
72897289
s1 = ComponentReference.printComponentRefStr(name);
72907290
s2 = ComponentReference.printComponentRefStr(name2);
72917291
sProt = if isProtected then " protected "else "";
7292-
if Util.isSome(arrCref) then s3 = " arrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3=""; end if;
7293-
s = "index:("+printVarIndx(variable_index)+")"+s1+" (negated alias: "+s2+s3+") "+sProt+" [" + stringDelimitList(numArrayElement,",")+"] ";
7292+
if Util.isSome(arrCref) then s3 = " \tarrCref:"+ComponentReference.printComponentRefStr(Util.getOption(arrCref)); else s3="\tno arrCref"; end if;
7293+
s = "index: "+intString(i)+": "+s1+" (negated alias: "+s2+") "+sProt+" initial: "+ExpressionDump.printOptExpStr(init) + s3 + " index:("+printVarIndx(variable_index)+")" +" [" + stringDelimitList(numArrayElement,",")+"] ";
72947294
then s;
72957295
end match;
72967296
end simVarString;
@@ -7376,6 +7376,7 @@ protected
73767376
list<SimCodeVar.SimVar> aliasVars;
73777377
list<SimCodeVar.SimVar> intAliasVars;
73787378
list<SimCodeVar.SimVar> paramVars;
7379+
list<SimCodeVar.SimVar> boolParamVars;
73797380
list<SimCodeVar.SimVar> intParamVars;
73807381
list<SimCodeVar.SimVar> extObjVars;
73817382
list<SimCodeVar.SimVar> constVars;
@@ -7385,7 +7386,7 @@ protected
73857386
algorithm
73867387
SimCode.MODELINFO(vars=simVars, varInfo=varInfo, functions=functions) := modelInfo;
73877388
SimCodeVar.SIMVARS(stateVars=stateVars,derivativeVars=derivativeVars,algVars=algVars,intAlgVars=intAlgVars,discreteAlgVars=discreteAlgVars,aliasVars=aliasVars,intAliasVars=intAliasVars,
7388-
paramVars=paramVars,intParamVars=intParamVars,extObjVars=extObjVars,constVars=constVars,intConstVars=intConstVars,stringConstVars=stringConstVars) := simVars;
7389+
paramVars=paramVars,intParamVars=intParamVars,boolParamVars=boolParamVars, extObjVars=extObjVars,constVars=constVars,intConstVars=intConstVars,stringConstVars=stringConstVars) := simVars;
73897390
SimCode.VARINFO(numStateVars=nsv,numAlgVars=nalgv) := varInfo;
73907391
dumpVarLst(stateVars,"stateVars ("+intString(nsv)+")");
73917392
dumpVarLst(derivativeVars,"derivativeVars");
@@ -7396,6 +7397,7 @@ algorithm
73967397
dumpVarLst(intAliasVars,"intAliasVars");
73977398
dumpVarLst(paramVars,"paramVars");
73987399
dumpVarLst(intParamVars,"intParamVars");
7400+
dumpVarLst(boolParamVars,"boolParamVars");
73997401
dumpVarLst(extObjVars,"extObjVars");
74007402
dumpVarLst(constVars,"constVars");
74017403
dumpVarLst(intConstVars,"intConstVars");
@@ -7764,9 +7766,18 @@ protected function extObjInfoString
77647766
protected
77657767
list<SimCodeVar.SimVar> vars;
77667768
list<SimCode.ExtAlias> aliases;
7769+
DAE.ComponentRef cr1, cr2;
77677770
algorithm
77687771
SimCode.EXTOBJINFO(vars=vars, aliases=aliases) := info;
7769-
dumpVarLst(vars,"external object info\n-----------------------\n");
7772+
dumpVarLst(vars,"external object info");
7773+
if not listEmpty(aliases) then
7774+
print("external object aliase ("+intString(listLength(aliases))+")");
7775+
for tpl in aliases loop
7776+
(cr1,cr2) := tpl;
7777+
print(ComponentReference.crefStr(cr1)+" = "+ComponentReference.crefStr(cr2));
7778+
end for;
7779+
print("\n");
7780+
end if;
77707781
end extObjInfoString;
77717782

77727783
protected function dumpClockPartition

0 commit comments

Comments
 (0)