Skip to content

Commit

Permalink
Fixed small bug in codegen (statements in wrong order).
Browse files Browse the repository at this point in the history
Added whitespace when unparsing modifier list (nicer layout when printing large annotations)
dummy equation der(dummy) = 0 changed to der(dummy) = sin(time*628.56....), to better cope with automatic step size when no states present in model.)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2731 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Feb 26, 2007
1 parent 89ab88d commit a79ff6b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
10 changes: 9 additions & 1 deletion Compiler/DAELow.mo
Expand Up @@ -602,9 +602,17 @@ algorithm
SOME(
DAE.VAR_ATTR_REAL(NONE,NONE,NONE,(NONE,NONE),NONE,SOME(true),NONE,NONE)),NONE,DAE.NON_CONNECTOR()), vars);
then
/*(vars_1,(EQUATION(
Exp.CALL(Absyn.IDENT("der"),
{Exp.CREF(Exp.CREF_IDENT("$dummy",{}),Exp.REAL())},false,true,Exp.REAL()),Exp.RCONST(0.0)) :: eqns));*/

(vars_1,(EQUATION(
Exp.CALL(Absyn.IDENT("der"),
{Exp.CREF(Exp.CREF_IDENT("$dummy",{}),Exp.REAL())},false,true,Exp.REAL()),Exp.RCONST(0.0)) :: eqns));
{Exp.CREF(Exp.CREF_IDENT("$dummy",{}),Exp.REAL())},false,true,Exp.REAL()),
Exp.CALL(Absyn.IDENT("sin"),{Exp.BINARY(
Exp.CREF(Exp.CREF_IDENT("time",{}),Exp.REAL()),
Exp.MUL(Exp.REAL()),
Exp.RCONST(628.318530717))},false,true,Exp.REAL())) :: eqns));
end matchcontinue;
end addDummyState;

Expand Down
6 changes: 3 additions & 3 deletions Compiler/Dump.mo
Expand Up @@ -881,7 +881,7 @@ algorithm
case (Absyn.CLASSMOD(elementArgLst = {})) then "";
case (Absyn.CLASSMOD(elementArgLst = l,expOption = NONE))
equation
s1 = getStringList(l, unparseElementArgStr, ",");
s1 = getStringList(l, unparseElementArgStr, ", ");
s2 = stringAppend("(", s1);
str = stringAppend(s2, ")");
then
Expand Down Expand Up @@ -1814,7 +1814,7 @@ algorithm
equation
s1 = Absyn.pathString(p);
s2 = stringAppend("extends ", s1);
s3 = getStringList(l, unparseElementArgStr, ",");
s3 = getStringList(l, unparseElementArgStr, ", ");
is = indentStr(i);
str = Util.stringAppendList({is,f,r,io,s2,"(",s3,")"});
then
Expand Down Expand Up @@ -2428,7 +2428,7 @@ algorithm
case {} then "";
case l
equation
s1 = getStringList(l, unparseElementArgStr, ",");
s1 = getStringList(l, unparseElementArgStr, ", ");
s2 = stringAppend("(", s1);
str = stringAppend(s2, ")");
then
Expand Down
1 change: 0 additions & 1 deletion Compiler/Inst.mo
Expand Up @@ -3840,7 +3840,6 @@ algorithm
(cache,compenv,dae,csets_1,ty_1) = instVar2(cache,env, ci_state, mod, pre, csets, n, cl, attr, dims_1, idxs,
inst_dims, impl, comment,io);
ty = makeArrayType(dims_1, ty_1);
print("making array type:");print(Types.unparseType(ty));print("\n");
then
(cache,compenv,dae,csets_1,ty);
// Generic case: fall trough
Expand Down
19 changes: 13 additions & 6 deletions Compiler/Interactive.mo
Expand Up @@ -1939,13 +1939,20 @@ algorithm

refactoredClass = Refactor.refactorGraphicalAnnotation(p, cls);
p = updateProgram(Absyn.PROGRAM({refactoredClass}, Absyn.TOP), p);
// Dump.dump(Absyn.PROGRAM({cls}, Absyn.TOP));
// Dump.dump(p);
resstr = Dump.unparseStr(Absyn.PROGRAM({refactoredClass}, Absyn.TOP));
// resstr = "Test K�rning";
resstr = Dump.unparseStr(Absyn.PROGRAM({refactoredClass},Absyn.TOP())) ",false";
then
(resstr,SYMBOLTABLE(p,s,ic,iv,cf,lf));
/*******************************************************************************/

case (ISTMTS(interactiveStmtLst =
{IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "refactorClass"),functionArgs = Absyn.FUNCTIONARGS(args = {Absyn.CREF(componentReg = cr)})))}),
(st as SYMBOLTABLE(ast = p,explodedAst = s,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf,loadedFiles = lf)))
local Absyn.Path path; Absyn.Class cls, refactoredClass;
equation
s1 = Dump.printComponentRefStr(cr);
resstr = Util.stringAppendList({"Failed in translating", s1, " to Modelica v2.0 graphicall annotations"});
then
(resstr,SYMBOLTABLE(p,s,ic,iv,cf,lf));

case (ISTMTS(interactiveStmtLst = {IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "getClassNames"),functionArgs = Absyn.FUNCTIONARGS(args = {})))}),(st as SYMBOLTABLE(ast = p,explodedAst = s,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)))
equation
resstr = getTopClassnames(p);
Expand Down Expand Up @@ -15970,4 +15977,4 @@ algorithm
end matchcontinue;
end loadFileInteractiveQualified;

end Interactive;
end Interactive;
4 changes: 2 additions & 2 deletions Compiler/SimCodegen.mo
Expand Up @@ -2761,8 +2761,8 @@ algorithm
(exp_func,e_str,cg_id_1) = Codegen.generateExpression(e, cg_id, Codegen.simContext);
(func,cg_id_2) = generateParameterAssignments(vs, cg_id_1);
stmt = Util.stringAppendList({cr_str," = ",e_str,";"});
func_1 = Codegen.cAddStatements(func, {stmt});
func_2 = Codegen.cMergeFns({exp_func,func_1});
exp_func = Codegen.cAddStatements(exp_func, {stmt});
func_2 = Codegen.cMergeFns({exp_func,func});
then
(func_2,cg_id_2);
case ((_ :: vs),cg_id)
Expand Down

0 comments on commit a79ff6b

Please sign in to comment.