@@ -8105,7 +8105,31 @@ function: elabCallArgs
81058105 output DAE.DAElist outDae "contain functions";
81068106algorithm
81078107 (outCache,outExp,outProperties,outDae) :=
8108- matchcontinue (inCache,inEnv,inPath,inAbsynExpLst,inAbsynNamedArgLst,inBoolean,inInteractiveInteractiveSymbolTableOption)
8108+ elabCallArgs2(inCache,inEnv,inPath,inAbsynExpLst,inAbsynNamedArgLst,inBoolean,Util.makeStatefulBoolean(false),inInteractiveInteractiveSymbolTableOption);
8109+ end elabCallArgs;
8110+
8111+ protected function elabCallArgs2 "
8112+ function: elabCallArgs
8113+ Given the name of a function and two lists of expression and
8114+ NamedArg respectively to be used
8115+ as actual arguments in a function call to that function, this
8116+ function finds the function definition and matches the actual
8117+ arguments to the formal parameters."
8118+ input Env.Cache inCache;
8119+ input Env.Env inEnv;
8120+ input Absyn.Path inPath;
8121+ input list<Absyn.Exp> inAbsynExpLst;
8122+ input list<Absyn.NamedArg> inAbsynNamedArgLst;
8123+ input Boolean inBoolean;
8124+ input Util.StatefulBoolean stopElab;
8125+ input Option<Interactive.InteractiveSymbolTable> inInteractiveInteractiveSymbolTableOption;
8126+ output Env.Cache outCache;
8127+ output DAE.Exp outExp;
8128+ output DAE.Properties outProperties;
8129+ output DAE.DAElist outDae "contain functions";
8130+ algorithm
8131+ (outCache,outExp,outProperties,outDae) :=
8132+ matchcontinue (inCache,inEnv,inPath,inAbsynExpLst,inAbsynNamedArgLst,inBoolean,stopElab,inInteractiveInteractiveSymbolTableOption)
81098133 local
81108134 tuple<DAE.TType, Option<Absyn.Path>> t,outtype,restype,functype;
81118135 list<tuple<Ident, tuple<DAE.TType, Option<Absyn.Path>>>> fargs;
@@ -8144,7 +8168,7 @@ algorithm
81448168 * this could be also fixed by transforming the function call arguments into modifications and
81458169 * send the modifications as an option in Lookup.lookup* functions!
81468170 */
8147- case (cache,env,fn,args,nargs,impl,st)
8171+ case (cache,env,fn,args,nargs,impl,stopElab, st)
81488172 local list<SCode.Element> comps; list<String> names;
81498173 equation
81508174 (cache,cl as SCode.CLASS(restriction = SCode.R_PACKAGE()),_) =
@@ -8169,7 +8193,7 @@ algorithm
81698193 (cache,DAE.CALL(fn,args_2,false,false,tp,DAE.NO_INLINE),DAE.PROP((DAE.T_NOTYPE(),NONE()),DAE.C_CONST()),DAEUtil.emptyDae);
81708194
81718195 // adrpo: deal with function call via an instance: MultiBody world.gravityAcceleration
8172- case (cache, env, fn, args, nargs, impl, st)
8196+ case (cache, env, fn, args, nargs, impl, stopElab, st)
81738197 local
81748198 DAE.ExpType tp;
81758199 String str2, stringifiedInstanceFunctionName;
@@ -8198,6 +8222,7 @@ algorithm
81988222 // lookup the function using the correct typeOf(world).functionName
81998223 Debug.fprintln("static", "Looking up class: " +& Absyn.pathString(functionClassPath));
82008224 (_, scodeClass, classEnv) = Lookup.lookupClass(cache, env, functionClassPath, true);
8225+ Util.setStatefulBoolean(stopElab,true);
82018226 // see if class scodeClass is derived and then
82028227 // take the applied modifications and transform
82038228 // them into function arguments by prefixing them
@@ -8230,7 +8255,7 @@ algorithm
82308255 (cache,call_exp,prop_1,dae);
82318256
82328257 /* Record constructors, user defined or implicit */ // try the hard stuff first
8233- case (cache,env,fn,args,nargs,impl,st)
8258+ case (cache,env,fn,args,nargs,impl,stopElab, st)
82348259 local
82358260 String lastId;
82368261 list<Env.Frame> recordEnv;
@@ -8242,6 +8267,7 @@ algorithm
82428267// print(" inst record: " +& name +& " \n");
82438268 (_,recordCl,recordEnv) = Lookup.lookupClass(cache,env,fn, false);
82448269 true = MetaUtil.classHasRestriction(recordCl, SCode.R_RECORD());
8270+ Util.setStatefulBoolean(stopElab,true);
82458271 lastId = Absyn.pathLastIdent(fn);
82468272 fn = Env.joinEnvPath(recordEnv, Absyn.IDENT(lastId));
82478273
@@ -8265,7 +8291,7 @@ algorithm
82658291 (cache,call_exp,prop_1,dae);
82668292
82678293 /* ------ */
8268- case (cache,env,fn,args,nargs,impl,st) /* Metamodelica extension, added by simbj */
8294+ case (cache,env,fn,args,nargs,impl,stopElab, st) /* Metamodelica extension, added by simbj */
82698295 local
82708296 SCode.Class c;
82718297 SCode.Restriction re;
@@ -8277,7 +8303,9 @@ algorithm
82778303 Absyn.Path fqPath;
82788304 equation
82798305 true = RTOpts.acceptMetaModelicaGrammar();
8306+ false = Util.getStatefulBoolean(stopElab);
82808307 (cache,t as (DAE.T_METARECORD(index,vars),_),env_1) = Lookup.lookupType(cache, env, fn, false);
8308+ Util.setStatefulBoolean(stopElab,true);
82818309 (cache,c,env_1) = Lookup.lookupClass(cache, env_1, fn, false);
82828310 // (_, _, _, _, (DAE.T_COMPLEX(complexClassType = ClassInf.META_RECORD(_), complexVarLst = vars),_), _, _, _) = Inst.instClass(cache,env_1,DAE.NOMOD(),Prefix.NOPRE(), Connect.emptySet,c,{},false,Inst.INNER_CALL(), ConnectionGraph.EMPTY);
82838311 fieldNames = Util.listMap(vars, Types.getVarName);
@@ -8295,14 +8323,15 @@ algorithm
82958323 (cache,DAE.METARECORDCALL(fqPath,args_2,fieldNames,index),prop,DAEUtil.emptyDae);
82968324 /* ------ */
82978325
8298- case (cache,env,fn,args,nargs,impl,st) /* ..Other functions */
8326+ case (cache,env,fn,args,nargs,impl,stopElab, st) /* ..Other functions */
82998327 local
83008328 DAE.ExpType tp;
83018329 DAE.Exp callExp;
83028330 String str2,debugPrintString;
83038331 list<DAE.Type> ltypes;
83048332 list<String> lstr;
83058333 equation
8334+ false = Util.getStatefulBoolean(stopElab);
83068335 (cache,typelist as _::_,dae1) = Lookup.lookupFunctionsInEnv(cache, env, fn)
83078336 "PR. A function can have several types. Taking an array with
83088337 different dimensions as parameter for example. Because of this we
@@ -8311,6 +8340,7 @@ algorithm
83118340 functiontype of several possibilites. The solution is to send
83128341 in the function type of the user function and check both the
83138342 function name and the function\'s type." ;
8343+ Util.setStatefulBoolean(stopElab,true);
83148344 (cache,args_1,constlist,restype,functype as (DAE.T_FUNCTION(inline = inline),_),vect_dims,slots,dae2) =
83158345 elabTypes(cache, env, args, nargs, typelist, true/* Check types*/, impl)
83168346 "The constness of a function depends on the inputs. If all inputs are constant the call itself is constant." ;
@@ -8335,15 +8365,15 @@ algorithm
83358365 then
83368366 (cache,call_exp,prop_1,dae);
83378367
8338- case (cache,env,fn,args,nargs,impl,st) /* no matching type found, no candidates. */
8368+ case (cache,env,fn,args,nargs,impl,stopElab, st) /* no matching type found, no candidates. */
83398369 equation
83408370 (cache,{},_) = Lookup.lookupFunctionsInEnv(cache,env, fn);
83418371 fn_str = Absyn.pathString(fn);
83428372 Error.addMessage(Error.NO_MATCHING_FUNCTION_FOUND_NO_CANDIDATE, {fn_str});
83438373 then
83448374 fail();
83458375
8346- case (cache,env,fn,args,nargs,impl,st) /* no matching type found, with -one- candidate */
8376+ case (cache,env,fn,args,nargs,impl,stopElab, st) /* no matching type found, with -one- candidate */
83478377 local list<DAE.Exp> args1; String argStr; DAE.Type tp1;
83488378 equation
83498379 (cache,typelist as {tp1},_) = Lookup.lookupFunctionsInEnv(cache, env, fn);
@@ -8356,7 +8386,7 @@ algorithm
83568386 then
83578387 fail();
83588388
8359- case (cache,env,fn,args,nargs,impl,st) /* no matching type found, with candidates */
8389+ case (cache,env,fn,args,nargs,impl,stopElab, st) /* no matching type found, with candidates */
83608390 equation
83618391 (cache,typelist as _::_::_,_) = Lookup.lookupFunctionsInEnv(cache,env, fn);
83628392
@@ -8377,7 +8407,7 @@ algorithm
83778407 then
83788408 fail(); */
83798409
8380- case (cache,env,fn,args,nargs,impl,st)
8410+ case (cache,env,fn,args,nargs,impl,stopElab, st)
83818411 local
83828412 list<Absyn.Exp> t4;
83838413 equation
@@ -8389,14 +8419,14 @@ algorithm
83898419 then
83908420 fail();
83918421
8392- case (cache,env,fn,args,nargs,impl,st)
8422+ case (cache,env,fn,args,nargs,impl,stopElab, st)
83938423 equation
83948424 true = RTOpts.debugFlag("failtrace");
83958425 Debug.fprintln("failtrace", "- Static.elabCallArgs failed on: " +& Absyn.pathString(fn) +& " in env: " +& Env.printEnvPathStr(env));
83968426 then
83978427 fail();
83988428 end matchcontinue;
8399- end elabCallArgs ;
8429+ end elabCallArgs2 ;
84008430
84018431protected function instantiateDaeFunction "help function to elabCallArgs. Instantiates the function as a dae and adds it to the
84028432functiontree of a newly created dae"
0 commit comments