@@ -854,7 +854,7 @@ algorithm
854854 (newExp1,assrtLst) = Expression . traverseExpBottomUp(newExp,function inlineCall(fns= fns),assrtLst);
855855 else // normal Modelica
856856 // get inputs, body and output
857- (crefs,lst_cr,stmts,repl) = getFunctionInputsOutputBody(fn,{},{},{}, repl);
857+ (crefs,lst_cr,stmts,repl) = getFunctionInputsOutputBody(fn, repl);
858858 // merge statements to one line
859859 (repl,assrtStmts) = mergeFunctionBody(stmts,repl,{});
860860 // depend on detection of assert or not
@@ -986,7 +986,7 @@ algorithm
986986 (fn,comment) = getFunctionBody(p,fns);
987987 (checkcr,repl) = getInlineHashTableVarTransform();
988988 // get inputs, body and output
989- (crefs,lst_cr,stmts,repl) = getFunctionInputsOutputBody(fn,{},{},{}, repl);
989+ (crefs,lst_cr,stmts,repl) = getFunctionInputsOutputBody(fn,repl);
990990 // merge statements to one line
991991 (repl,_) = mergeFunctionBody(stmts,repl,{});
992992 // newExp = VarTransform.getReplacement(repl,cr);
@@ -1110,71 +1110,71 @@ end addTplAssignToRepl;
11101110
11111111protected function getFunctionInputsOutputBody
11121112 input list< DAE . Element > fn;
1113- input list< DAE . ComponentRef > iInputs;
1114- input list< DAE . ComponentRef > iOutput;
1115- input list< DAE . Statement > iBody;
11161113 input VarTransform . VariableReplacements iRepl;
1117- output list< DAE . ComponentRef > oInputs;
1118- output list< DAE . ComponentRef > oOutput;
1119- output list< DAE . Statement > oBody;
1120- output VarTransform . VariableReplacements oRepl;
1114+ output list< DAE . ComponentRef > oInputs = {};
1115+ output list< DAE . ComponentRef > oOutputs = {};
1116+ output list< DAE . Statement > oBody = {};
1117+ output VarTransform . VariableReplacements oRepl = iRepl;
1118+ protected
1119+ DAE . Element elt;
1120+ DAE . ComponentRef cr;
1121+ Option < DAE . Exp > binding;
1122+ DAE . Type tp;
1123+ DAE . Exp exp;
1124+ list< DAE . Statement > st;
1125+
11211126algorithm
1122- (oInputs,oOutput,oBody,oRepl) := match(fn,iInputs,iOutput,iBody,iRepl)
1123- local
1124- DAE . ComponentRef cr;
1125- list< DAE . Statement > st;
1126- list< DAE . Element > rest;
1127- VarTransform . VariableReplacements repl;
1128- Option < DAE . Exp > binding;
1129- DAE . Type tp;
1130- DAE . Element elt;
1131- DAE . Exp exp;
1132- case ({},_,_,_,_) then (listReverse(iInputs),listReverse(iOutput),iBody,iRepl);
1133- case (DAE . VAR (componentRef= cr,direction= DAE . INPUT ())::rest,_,_,_,_)
1134- equation
1135- (oInputs,oOutput,oBody,repl) = getFunctionInputsOutputBody(rest,cr::iInputs,iOutput,iBody,iRepl);
1136- then
1137- (oInputs,oOutput,oBody,repl);
1127+ for elt in fn loop
1128+ _ := match(elt)
11381129
1139- case (DAE . VAR (componentRef= cr,direction= DAE . OUTPUT (), binding= binding as SOME (exp))::rest,_,_,_,_)
1130+ case DAE . VAR (componentRef= cr,direction= DAE . INPUT ())
1131+ equation
1132+ oInputs = cr::oInputs;
1133+ then ();
1134+
1135+ case DAE . VAR (componentRef= cr,direction= DAE . OUTPUT (), binding= binding as SOME (exp))
11401136 equation
11411137 // use type of cref, since var type is different
11421138 // and has no hint on array or record type
11431139 tp = ComponentReference . crefTypeFull(cr);
1144- st = listAppend(iBody, {DAE . STMT_ASSIGN (exp1 = Expression . crefExp(cr), exp = exp, source= DAE . emptyElementSource, type_= tp)});
1145- (oInputs,oOutput,oBody,repl) = getFunctionInputsOutputBody(rest,iInputs,cr::iOutput,st,iRepl);
1146- then
1147- (oInputs,oOutput,oBody,repl);
1148-
1140+ oBody = listAppend(oBody, {DAE . STMT_ASSIGN (exp1 = Expression . crefExp(cr), exp = exp, source= DAE . emptyElementSource, type_= tp)});
1141+ oOutputs = cr :: oOutputs;
1142+ then ();
11491143
1150- case ( DAE . VAR (componentRef= cr,direction= DAE . OUTPUT (), binding= NONE ())::rest,_,_,_,_ )
1144+ case DAE . VAR (componentRef= cr,direction= DAE . OUTPUT (), binding= NONE ())
11511145 equation
1152- (oInputs,oOutput,oBody,repl) = getFunctionInputsOutputBody(rest,iInputs,cr::iOutput,iBody,iRepl);
1153- then
1154- (oInputs,oOutput,oBody,repl);
1146+ oOutputs = cr :: oOutputs;
1147+ then ();
11551148
1156- case ( DAE . VAR (componentRef= cr,protection= DAE . PROTECTED (),binding= binding)::rest,_,_,_,_ )
1149+ case DAE . VAR (componentRef= cr,protection= DAE . PROTECTED (),binding= binding)
11571150 equation
11581151 // use type of cref, since var type is different
11591152 // and has no hint on array or record type
11601153 tp = ComponentReference . crefTypeFull(cr);
11611154 false = Expression . isArrayType(tp);
11621155 false = Expression . isRecordType(tp);
1163- repl = addOptBindingReplacements(cr,binding,iRepl);
1164- (oInputs,oOutput,oBody,repl) = getFunctionInputsOutputBody(rest,iInputs,iOutput,iBody,repl);
1156+ oRepl = addOptBindingReplacements(cr,binding,oRepl);
11651157 then
1166- (oInputs,oOutput,oBody,repl);
1167- case (DAE . ALGORITHM (algorithm_ = DAE . ALGORITHM_STMTS (st))::rest,_,_,_,_)
1158+ ();
1159+
1160+ case DAE . ALGORITHM (algorithm_ = DAE . ALGORITHM_STMTS (st))
11681161 equation
1169- st = listAppend(iBody,st);
1170- (oInputs,oOutput,oBody,repl) = getFunctionInputsOutputBody(rest,iInputs,iOutput,st,iRepl);
1162+ oBody = listAppend(oBody,st);
11711163 then
1172- (oInputs,oOutput,oBody,repl);
1173- case (elt::rest,_,_,_,_)
1164+ ();
1165+
1166+ case _
11741167 algorithm
11751168 Error . addInternalError("Unknown element: " + DAEDump . dumpElementsStr({elt}), sourceInfo());
11761169 then fail();
1177- end match;
1170+ end match;
1171+
1172+
1173+ end for ;
1174+
1175+ oInputs := listReverse(oInputs);
1176+ oOutputs := listReverse(oOutputs);
1177+
11781178end getFunctionInputsOutputBody;
11791179
11801180protected function addOptBindingReplacements
0 commit comments