@@ -5214,6 +5214,7 @@ algorithm
52145214 Option<Absyn.ConstrainClass> cc,cc2;
52155215 InstanceHierarchy ih;
52165216
5217+ Boolean is_function_input;
52175218 // Imports are simply added to the current frame, so that the lookup rule can find them.
52185219 // Import have allready been added to the environment so there is nothing more to do here.
52195220 case (cache,env,ih,store,mod,pre,csets,ci_state,(SCode.IMPORT(imp = imp),_),instdims,_,graph)
@@ -5372,8 +5373,9 @@ algorithm
53725373 eq = Mod.modEquation(mod_1);
53735374
53745375 // The variable declaration and the (optional) equation modification are inspected for array dimensions.
5375-
5376- (cache,dims,fdae4) = elabArraydim(cache, env2_1, owncref, t,ad, eq, impl, NONE, true) ;
5376+ is_function_input = isFunctionInput(ci_state, dir);
5377+ (cache,dims,fdae4) = elabArraydim(cache, env2_1, owncref, t,ad, eq, impl, NONE, true, is_function_input);
5378+
53775379 //Instantiate the component
53785380 inst_dims = listAppend(inst_dims,{{}}); // Start a new "set" of inst_dims for this component (in instance hierarchy), see InstDims
53795381 (cache,mod_1,fdae2) = Mod.updateMod(cache,cenv, pre, mod_1, impl);
@@ -5488,7 +5490,7 @@ algorithm
54885490 // The variable declaration and the (optional) equation modification are inspected for array dimensions.
54895491 // Gather all the dimensions
54905492 // (Absyn.IDENT("Integer") is used as a dummie)
5491- (cache,dims,fdae1) = elabArraydim(cache,env, owncref, Absyn.IDENT("Integer"),ad, NONE, impl, NONE,true) ;
5493+ (cache,dims,fdae1) = elabArraydim(cache,env, owncref, Absyn.IDENT("Integer"),ad, NONE, impl, NONE,true, false ) ;
54925494
54935495 // Instantiate the component
54945496 (cache,compenv,ih,store,dae,csets_1,ty,graphNew) = instVar(cache,env, ih, store,ci_state, m_1, pre, csets, n, cl, attr, prot, dims, {}, inst_dims, impl, comment,io,finalPrefix,aInfo,graph);
@@ -6866,7 +6868,7 @@ algorithm
68666868 owncref = Absyn.CREF_IDENT(id,{});
68676869 ad_1 = getOptionArraydim(ad);
68686870 // Absyn.IDENT("Integer") used as a dummie
6869- (cache,dim1,fdae) = elabArraydim(cache,env, owncref, Absyn.IDENT("Integer"), ad_1, NONE, impl, NONE,true);
6871+ (cache,dim1,fdae) = elabArraydim(cache,env, owncref, Absyn.IDENT("Integer"), ad_1, NONE, impl, NONE,true, false );
68706872 then (cache,dim1,cl,fdae,DAE.NOMOD);
68716873 // Partial function definitions with no output - stefan
68726874 case (cache,env,_,_,cl as SCode.CLASS(name = id,restriction = SCode.R_FUNCTION(),partialPrefix = true),_,_) then (cache,{},cl,DAEUtil.emptyDae,DAE.NOMOD);
@@ -6893,7 +6895,7 @@ algorithm
68936895 mods_3 = Mod.lookupCompModification(mods_2, id);
68946896 (cache,dim1,cl,fdae2,type_mods) = getUsertypeDimensions(cache,cenv, mods_3, pre, cl, dims, impl);
68956897 type_mods = Mod.merge(mod_1, type_mods, env, pre);
6896- (cache,dim2,fdae3) = elabArraydim(cache,env, owncref, cn, ad_1, eq, impl, NONE,true);
6898+ (cache,dim2,fdae3) = elabArraydim(cache,env, owncref, cn, ad_1, eq, impl, NONE,true, false );
68976899 res = listAppend(dim2, dim1);
68986900 fdae = DAEUtil.joinDaeLst({fdae,fdae2,fdae3});
68996901 then
@@ -7279,7 +7281,7 @@ algorithm
72797281 eq = Mod.modEquation(mod_3);
72807282
72817283 owncref = Absyn.CREF_IDENT(name,{});
7282- (cache,dims,dae3) = elabArraydim(cache,env,owncref,path,ad,eq,impl,NONE,true)
7284+ (cache,dims,dae3) = elabArraydim(cache,env,owncref,path,ad,eq,impl,NONE,true, false )
72837285 "The variable declaration and the (optional) equation modification are inspected for array dimensions." ;
72847286 /* Instantiate the component */
72857287 (cache,compenv,ih,_,DAE.DAE(_,funcs),csets_1,ty,_) = instVar(cache, cenv, ih, UnitAbsyn.noStore, ci_state, mod_3, pre, csets, name, cl, attr, prot, dims, {}, {}, impl, NONE, io, finalPrefix, info, ConnectionGraph.EMPTY);
@@ -8021,7 +8023,7 @@ algorithm
80218023 DAE.DAElist dae;
80228024 case (cache,env,owncref,path,SOME(ad),eq,impl,st,doVect)
80238025 equation
8024- (cache,res,dae) = elabArraydim(cache,env, owncref, path,ad, eq, impl, st,doVect);
8026+ (cache,res,dae) = elabArraydim(cache,env, owncref, path,ad, eq, impl, st,doVect, false );
80258027 then
80268028 (cache,res,dae);
80278029 case (cache,env,owncref,path,NONE,eq,impl,st,doVect) then (cache,{},DAEUtil.emptyDae);
@@ -8050,12 +8052,14 @@ protected function elabArraydim
80508052 input Boolean inBoolean;
80518053 input Option<Interactive.InteractiveSymbolTable> inInteractiveInteractiveSymbolTableOption;
80528054 input Boolean performVectorization;
8055+ input Boolean isFunctionInput;
80538056 output Env.Cache outCache;
80548057 output list<DimExp> outDimExpLst;
80558058 output DAE.DAElist outDae "contain functions";
80568059algorithm
80578060 (outCache,outDimExpLst,outDae) :=
8058- matchcontinue (inCache,inEnv,inComponentRef,path,inArrayDim,inTypesEqModOption,inBoolean,inInteractiveInteractiveSymbolTableOption,performVectorization)
8061+ matchcontinue
8062+ (inCache,inEnv,inComponentRef,path,inArrayDim,inTypesEqModOption,inBoolean,inInteractiveInteractiveSymbolTableOption,performVectorization,isFunctionInput)
80598063 local
80608064 list<Option<DimExp>> dim,dim1,dim2;
80618065 list<DimExp> dim_1,dim3;
@@ -8072,13 +8076,23 @@ algorithm
80728076 DAE.Properties prop;
80738077 DAE.DAElist dae,dae1,dae2;
80748078
8075- case (cache,env,cref,path,ad,NONE,impl,st,doVect) /* impl */
8079+ // The size of function input arguments should not be set here, since they
8080+ // may vary depending on the inputs. So we ignore any modifications on input
8081+ // variables here.
8082+ case (cache, env, cref, path, ad, _, impl, st, doVect, true)
8083+ equation
8084+ (cache, dim, dae) = elabArraydimDecl(cache, env, cref, ad, true, st, doVect);
8085+ dim_1 = completeArraydim(dim);
8086+ then
8087+ (cache, dim_1, dae);
8088+
8089+ case (cache,env,cref,path,ad,NONE,impl,st,doVect, _) /* impl */
80768090 equation
80778091 (cache,dim,dae) = elabArraydimDecl(cache,env, cref, ad, impl, st,doVect);
80788092 dim_1 = completeArraydim(dim);
80798093 then
80808094 (cache,dim_1,dae);
8081- case (cache,env,cref,path,ad,SOME(DAE.TYPED(e,_,prop)),impl,st,doVect) /* Untyped expressions must be elaborated. */
8095+ case (cache,env,cref,path,ad,SOME(DAE.TYPED(e,_,prop)),impl,st,doVect, _ ) /* Untyped expressions must be elaborated. */
80828096 equation
80838097 t = Types.getPropType(prop);
80848098 (cache,dim1,dae) = elabArraydimDecl(cache,env, cref, ad, impl, st,doVect);
@@ -8087,7 +8101,7 @@ algorithm
80878101 dim3 = compatibleArraydim(dim1, dim2);
80888102 then
80898103 (cache,dim3,dae);
8090- case (cache,env,cref,path,ad,SOME(DAE.UNTYPED(e)),impl,st,doVect)
8104+ case (cache,env,cref,path,ad,SOME(DAE.UNTYPED(e)),impl,st,doVect, _ )
80918105 local Absyn.Exp e;
80928106 equation
80938107 (cache,e_1,prop,_,dae1) = Static.elabExp(cache,env, e, impl, st,doVect);
@@ -8099,7 +8113,7 @@ algorithm
80998113 dae = DAEUtil.joinDaes(dae1,dae2);
81008114 then
81018115 (cache,dim3,dae);
8102- case (cache,env,cref,path,ad,SOME(DAE.TYPED(e,_,DAE.PROP(t,_))),impl,st,doVect)
8116+ case (cache,env,cref,path,ad,SOME(DAE.TYPED(e,_,DAE.PROP(t,_))),impl,st,doVect, _ )
81038117 equation
81048118 (cache,dim1,_) = elabArraydimDecl(cache,env, cref, ad, impl, st,doVect);
81058119 dim2 = elabArraydimType(t, ad,e,path);
@@ -8111,7 +8125,7 @@ algorithm
81118125 then
81128126 fail();
81138127 // print some failures
8114- case (_,_,cref,path,ad,eq,_,_,_)
8128+ case (_,_,cref,path,ad,eq,_,_,_,_ )
81158129 local Option<DAE.EqMod> eq;
81168130 equation
81178131 // only display when the failtrace flag is on
@@ -14941,7 +14955,7 @@ algorithm
1494114955 (cache,mod_1,_) = Mod.elabMod(cache,env, Prefix.NOPRE(), mod, impl);
1494214956 mod_1 = Mod.merge(outerMod,mod_1,cenv,Prefix.NOPRE());
1494314957 owncref = Absyn.CREF_IDENT(id,{});
14944- (cache,dimexp,_) = elabArraydim(cache,env, owncref,t, dim, NONE, false, NONE,true);
14958+ (cache,dimexp,_) = elabArraydim(cache,env, owncref,t, dim, NONE, false, NONE,true, false );
1494514959 //Debug.fprint("recconst", "calling inst_var\n");
1494614960 (cache,_,ih,_,_,_,tp_1,_) = instVar(cache,cenv, ih, UnitAbsyn.noStore,ClassInf.FUNCTION(Absyn.IDENT("")), mod_1, Prefix.NOPRE(),
1494714961 Connect.emptySet, id, cl, attr, prot,dimexp, {}, {}, impl, comment,io,finalPrefix,info,ConnectionGraph.EMPTY);
@@ -16066,7 +16080,7 @@ algorithm
1606616080 equation
1606716081 cl2 = removeCrefFromCrefs(cl1, c1);
1606816082 (cache,c,cenv) = Lookup.lookupClass(cache,env, sty, true);
16069- (cache,dims,_) = elabArraydim(cache,cenv, c1, sty, ad, NONE, impl, NONE,true) ;
16083+ (cache,dims,_) = elabArraydim(cache,cenv, c1, sty, ad, NONE, impl, NONE,true, false) ;
1607016084 (cache,compenv,ih,store,dae,_,ty,_) = instVar(cache,cenv,ih, store,state, DAE.NOMOD(), pre, csets, n, c, attr, prot, dims, {}, inst_dims, true, NONE ,io,finalPrefix,info,ConnectionGraph.EMPTY);
1607116085
1607216086 // print("component: " +& n +& " ty: " +& Types.printTypeStr(ty) +& "\n");
@@ -17464,4 +17478,15 @@ algorithm
1746417478 end matchcontinue;
1746517479end isPartial;
1746617480
17481+ protected function isFunctionInput
17482+ input ClassInf.State classState;
17483+ input Absyn.Direction direction;
17484+ output Boolean functionInput;
17485+ algorithm
17486+ functionInput := matchcontinue(classState, direction)
17487+ case (ClassInf.FUNCTION(path = _), Absyn.INPUT()) then true;
17488+ case (_, _) then false;
17489+ end matchcontinue;
17490+ end isFunctionInput;
17491+
1746717492end Inst;
0 commit comments