Skip to content

Commit

Permalink
- remove Repl for const funcCalls
Browse files Browse the repository at this point in the history
  • Loading branch information
vwaurich authored and OpenModelica-Hudson committed Sep 2, 2015
1 parent d1ecf33 commit f252d1f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Compiler/BackEnd/EvaluateFunctions.mo
Expand Up @@ -1679,7 +1679,7 @@ algorithm
repl = BackendVarTransform.removeReplacements(repl,outputs,NONE());

// check if its constant, a record or a tuple
isCon = Expression.isConst(exp2);
isCon = Expression.isConstValue(exp2);
eqDim = listLength(scalars) == listLength(expLst); // so it can be partly constant
isRec = ComponentReference.isRecord(cref) or Expression.isCall(exp2);
isTpl = Expression.isTuple(exp1) and Expression.isTuple(exp2);
Expand All @@ -1698,7 +1698,7 @@ algorithm
repl = if isCon and not isRec then BackendVarTransform.addReplacement(repl,cref,exp2,NONE()) else repl;
repl = if isCon and isRec then BackendVarTransform.addReplacements(repl,scalars,expLst,NONE()) else repl;
repl = if not isCon and not isRec then BackendVarTransform.removeReplacement(repl,cref,NONE()) else repl;
repl = if not isCon and isRec then BackendVarTransform.removeReplacements(repl,varScalars,NONE()) else repl;
repl = if not isCon and isRec then BackendVarTransform.removeReplacements(repl,cref::varScalars,NONE()) else repl;
repl = if not isCon and isRec then BackendVarTransform.addReplacements(repl,constScalars,expLst,NONE()) else repl;

//bcall(isCon and not isRec,print,"add the replacement: "+ComponentReference.crefStr(cref)+" --> "+ExpressionDump.printExpStr(exp2)+"\n");
Expand Down Expand Up @@ -1744,7 +1744,7 @@ algorithm
repl = BackendVarTransform.removeReplacements(repl,outputs,NONE());

// check if its constant, a record or a tuple
isCon = Expression.isConst(exp2);
isCon = Expression.isConstValue(exp2);
eqDim = listLength(scalars) == listLength(expLst); // so it can be partly constant
isRec = ComponentReference.isRecord(cref);
isArr = ComponentReference.isArrayElement(cref);
Expand Down Expand Up @@ -1779,7 +1779,7 @@ algorithm
tplStmts = List.map2(List.intRange(listLength(tplExpsLHS)),makeAssignmentMap,tplExpsLHS,tplExpsRHS);
stmts1 = if isTpl then tplStmts else {alg};
if Flags.isSet(Flags.EVAL_FUNC_DUMP) then
print("evaluated assignment to:\n"+stringDelimitList(List.map(stmts1,DAEDump.ppStatementStr),"\n")+"\n");
print("evaluated array assignment to:\n"+stringDelimitList(List.map(stmts1,DAEDump.ppStatementStr),"\n")+"\n");
end if;

//stmts1 = listAppend({alg},lstIn);
Expand Down Expand Up @@ -1866,7 +1866,7 @@ algorithm
//print("\nthe RHS after\n");
//print(ExpressionDump.printExpStr(exp1));
//BackendDump.dumpEquationList(addEqs,"the additional equations after");
isCon = Expression.isConst(exp1);
isCon = Expression.isConstValue(exp1);
exp1 = if isCon then exp1 else exp0;
if Flags.isSet(Flags.EVAL_FUNC_DUMP) then
print("--> is the tuple const? "+boolString(isCon)+"\n");
Expand Down Expand Up @@ -2105,7 +2105,7 @@ algorithm
(exp1,(_,_,_,_)) = Expression.traverseExpTopDown(exp1,evaluateConstantFunctionWrapper,(exp1,funcTree,idx,{}));
(exp1,_) = BackendVarTransform.replaceExp(exp1,replIn,NONE());
(exp1,_) = ExpressionSimplify.simplify(exp1);
isCon = Expression.isConst(exp1);
isCon = Expression.isConstValue(exp1);
isIf = if isCon then Expression.toBool(exp1) else false;

// check if its the IF case, if true then evaluate:
Expand Down Expand Up @@ -2175,7 +2175,7 @@ algorithm
(exp1,(_,_,_,_)) = Expression.traverseExpTopDown(expIf,evaluateConstantFunctionWrapper,(expIf,funcTree,idx,{}));
(exp1,_) = BackendVarTransform.replaceExp(exp1,replIn,NONE());
(exp1,_) = ExpressionSimplify.simplify(exp1);
isCon = Expression.isConst(exp1);
isCon = Expression.isConstValue(exp1);
isElseIf = if isCon then Expression.toBool(exp1) else false;
if isCon and not isElseIf then
(stmts,isElseIf) = evaluateElse(else_,info);
Expand Down

0 comments on commit f252d1f

Please sign in to comment.