Skip to content

Commit

Permalink
Inline.inlineCall and forceInlineCall return DAE.TUPLE for more than…
Browse files Browse the repository at this point in the history
… a single assignment statement
  • Loading branch information
vruge authored and OpenModelica-Hudson committed Oct 25, 2015
1 parent 111757f commit 5c33b20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
8 changes: 8 additions & 0 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -3323,6 +3323,14 @@ algorithm
outExp := makeASUB(exp,{sub});
end makeASUBSingleSub;

public function makeTuple
input list<DAE.Exp> inExps;
output DAE.Exp outExp;
algorithm
outExp := if listLength(inExps) > 1 then DAE.TUPLE(inExps) else List.first(inExps);
end makeTuple;


public function generateCrefsExpFromExpVar "
Author: Frenkel TUD 2010-05"
input DAE.Var inVar;
Expand Down
16 changes: 9 additions & 7 deletions Compiler/FrontEnd/Inline.mo
Expand Up @@ -783,7 +783,7 @@ algorithm
list<DAE.Exp> args;
list<DAE.ComponentRef> crefs;
list<tuple<DAE.ComponentRef, DAE.Exp>> argmap;
DAE.ComponentRef cr;
list<DAE.ComponentRef> lst_cr;
DAE.ElementSource source;
DAE.Exp newExp,newExp1, e1, cond, msg, level, newAssrtCond, newAssrtMsg, newAssrtLevel;
DAE.InlineType inlineType;
Expand Down Expand Up @@ -825,13 +825,13 @@ algorithm
(newExp1,(_,_,assrtLst)) = Expression.Expression.traverseExpBottomUp(newExp,inlineCall,(fns,true,assrtLstIn));
else // normal Modelica
// get inputs, body and output
(crefs,{cr},stmts,repl) = getFunctionInputsOutputBody(fn,{},{},{},VarTransform.emptyReplacements());
(crefs,lst_cr,stmts,repl) = getFunctionInputsOutputBody(fn,{},{},{},VarTransform.emptyReplacements());
// merge statements to one line
(repl,assrtStmts) = mergeFunctionBody(stmts,repl,{});
// depend on detection of assert or not
if (listEmpty(assrtStmts))
then // no assert detected
newExp = getReplacementCheckComplex(repl,cr,ty);
newExp = Expression.makeTuple(list( getReplacementCheckComplex(repl,cr,ty) for cr in lst_cr));
argmap = List.threadTuple(crefs,args);
(argmap,checkcr) = extendCrefRecords(argmap,HashTableCG.emptyHashTable());
// compare types
Expand All @@ -847,7 +847,8 @@ algorithm
true = listLength(assrtStmts) == 1;
assrt = listHead(assrtStmts);
DAE.STMT_ASSERT() = assrt;
newExp = getReplacementCheckComplex(repl,cr,ty); // the function that replaces the output variable
//newExp = getReplacementCheckComplex(repl,cr,ty); // the function that replaces the output variable
newExp = Expression.makeTuple(list( getReplacementCheckComplex(repl,cr,ty) for cr in lst_cr));
argmap = List.threadTuple(crefs,args);
(argmap,checkcr) = extendCrefRecords(argmap,HashTableCG.emptyHashTable());
// compare types
Expand Down Expand Up @@ -930,7 +931,7 @@ algorithm
list<DAE.Element> fn;
Absyn.Path p;
list<DAE.Exp> args;
DAE.ComponentRef cr;
list<DAE.ComponentRef> lst_cr;
list<DAE.ComponentRef> crefs;
list<DAE.Statement> assrtStmts;
list<tuple<DAE.ComponentRef, DAE.Exp>> argmap;
Expand All @@ -949,10 +950,11 @@ algorithm
true = checkInlineType(inlineType,fns);
(fn,comment) = getFunctionBody(p,fns);
// get inputs, body and output
(crefs,{cr},stmts,repl) = getFunctionInputsOutputBody(fn,{},{},{},VarTransform.emptyReplacements());
(crefs,lst_cr,stmts,repl) = getFunctionInputsOutputBody(fn,{},{},{},VarTransform.emptyReplacements());
// merge statements to one line
(repl,_) = mergeFunctionBody(stmts,repl,{});
newExp = VarTransform.getReplacement(repl,cr);
//newExp = VarTransform.getReplacement(repl,cr);
newExp = Expression.makeTuple(list( VarTransform.getReplacement(repl,cr) for cr in lst_cr));
argmap = List.threadTuple(crefs,args);
(argmap,checkcr) = extendCrefRecords(argmap,HashTableCG.emptyHashTable());
// compare types
Expand Down

0 comments on commit 5c33b20

Please sign in to comment.