@@ -406,7 +406,8 @@ relation inst_element : (Env, Mod, Prefix, Connect.Sets, ClassInf.State,
406406 (** binding. *)
407407
408408 make_binding (env,attr,eq,cl) => binding &
409- Env.extend_frame_v(env,Types.VAR(n,attr,prot,ty,binding)) => env' &
409+ Env.extend_frame_v(env,Types.VAR(n,Types.ATTR(flow,acc,param,dir),
410+ prot,ty,binding)) => env' &
410411
411412 (** If the type is one of the simple, predifined types a *)
412413 (** simple variable declaration is added to the DAE. *)
@@ -421,8 +422,7 @@ relation inst_element : (Env, Mod, Prefix, Connect.Sets, ClassInf.State,
421422 attr as SCode.ATTR(ad,flow,acc,param,dir),
422423 t,m))
423424 => (dae, env',csets',ci_state,
424- [Types.VAR(n,SCode.ATTR([],flow,acc,param,dir),
425- prot, ty, binding)])
425+ [Types.VAR(n,Types.ATTR(flow,acc,param,dir), prot, ty, binding)])
426426
427427
428428 (** If the class lookup in the previous rule fails, this
@@ -478,7 +478,8 @@ relation inst_var : (Env.Env,Mod.Mod,Prefix.Prefix,Connect.Sets,Ident,
478478 eq,[],idxs)
479479 => (dae,csets',ty)
480480
481- rule inst_array(env,mod,pre,csets,n,(cl,attr),1,dim,dims,idxs)
481+ rule print "= inst_array mod: " & print n & Mod.print_mod mod & print "\n" &
482+ inst_array(env,mod,pre,csets,n,(cl,attr),1,dim,dims,idxs)
482483 => (dae, csets', ty) &
483484 Types.lift_array(ty,SOME(dim)) => ty'
484485 -------------------------------
@@ -754,8 +755,7 @@ relation add_package : (Env.Env, Absyn.Ident, Types.Type, ClassInf.State,
754755
755756 rule ClassInf.valid(st, Absyn.R_PACKAGE) &
756757 Env.extend_frame_v(env,
757- Types.VAR(n, SCode.ATTR([],
758- false,SCode.RO,Absyn.CONST,
758+ Types.VAR(n, Types.ATTR(false,SCode.RO,Absyn.CONST,
759759 Absyn.BIDIR),
760760 false,
761761 ty,Types.UNBOUND)) => env'
@@ -909,9 +909,13 @@ relation inst_equation : (Env,Mod, Prefix, Connect.Sets, ClassInf.State,
909909 **
910910 ** The loop expression is evaluated to a constant array of
911911 ** integers, and then the loop is unrolled.
912+ **
912913 **)
913914
914- rule Static.elab_exp (env,e)
915+ rule Lookup.lookup_var(env, Exp.CREF_IDENT(i,[]))
916+ => (Types.ATTR(false, SCode.RW, Absyn.VAR, _),
917+ Types.T_INTEGER, Types.UNBOUND) &
918+ Static.elab_exp (env,e)
915919 => (e',Static.PROP(Types.T_ARRAY(Types.DIM(_),
916920 Types.T_INTEGER),
917921 true)) &
@@ -923,6 +927,14 @@ relation inst_equation : (Env,Mod, Prefix, Connect.Sets, ClassInf.State,
923927 inst_equation(env,mod,pre,csets,ci_state,SCode.EQ_FOR(i,e,el))
924928 => (dae, env,csets', ci_state')
925929
930+ rule not Lookup.lookup_var(env, Exp.CREF_IDENT(i,[]))
931+ => (Types.ATTR(false, SCode.RW, Absyn.VAR, _),
932+ Types.T_INTEGER, Types.UNBOUND) &
933+ print "# Invalid loop variable: " & print i & print "\n"
934+ -----------------------------------------------------------
935+ inst_equation(env,mod,pre,csets,ci_state,SCode.EQ_FOR(i,e,el))
936+ => fail
937+
926938 rule print "- inst_equation failed\n"
927939 ----------------------------------
928940 inst_equation(_,_,_,_,_,_) => fail
@@ -987,6 +999,9 @@ relation inst_eq_equation_2 : (Exp.Exp, Exp.Exp, Types.Type)
987999 => [DAE.EQUATION(e1,e2)]
9881000
9891001 rule RTOpts.split_arrays => true &
1002+ print " Array equation: " &
1003+ Exp.print_exp e1 & print " = " &
1004+ Exp.print_exp e2 & print "\n" &
9901005 inst_array_equation(e1,e2,ad,t) => dae
9911006 -----------------------------------------
9921007 inst_eq_equation_2(e1,e2,Types.T_ARRAY(ad,t)) => dae
@@ -1142,8 +1157,7 @@ relation unroll : (Env, Mod, Prefix, Connect.Sets, ClassInf.State,
11421157
11431158 rule Env.open_scope env => env' &
11441159 Env.extend_frame_v (env',
1145- Types.VAR(i, SCode.ATTR([],
1146- false,
1160+ Types.VAR(i, Types.ATTR(false,
11471161 SCode.RO,
11481162 Absyn.CONST,
11491163 Absyn.BIDIR),
@@ -1270,7 +1284,7 @@ relation inst_connect: (Connect.Sets, Env, Prefix,
12701284 Static.canon_cref(env, c1') => c1'' &
12711285 Static.canon_cref(env, c2') => c2'' &
12721286 Lookup.lookup_var_local(env,c1'')
1273- => (attr1 as SCode .ATTR(_, flow1,_,_,_),ty1,_) &
1287+ => (attr1 as Types .ATTR(flow1,_,_,_),ty1,_) &
12741288 Lookup.lookup_var_local(env,c2'') => (attr2,ty2,_) &
12751289
12761290 (** Check that the types of the connectors are good. *)
@@ -1320,45 +1334,45 @@ end
13201334 **)
13211335
13221336relation check_connect_types : (Exp.ComponentRef, Types.Type,
1323- SCode .Attributes,
1337+ Types .Attributes,
13241338 Exp.ComponentRef, Types.Type,
1325- SCode .Attributes) => () =
1339+ Types .Attributes) => () =
13261340
13271341 rule print "# Can't connect two input variables\n" &
13281342 print " while connecting " & Exp.print_component_ref c1 &
13291343 print " to " & Exp.print_component_ref c2 & print "\n"
13301344 ------------------------------------------------------
1331- check_connect_types(c1,_,SCode .ATTR(_, _,_,_,Absyn.INPUT),
1332- c2,_,SCode .ATTR(_, _,_,_,Absyn.INPUT)) => fail
1345+ check_connect_types(c1,_,Types .ATTR(_,_,_,Absyn.INPUT),
1346+ c2,_,Types .ATTR(_,_,_,Absyn.INPUT)) => fail
13331347
13341348 rule print "# Can't connect two output variables\n" &
13351349 print " while connecting " & Exp.print_component_ref c1 &
13361350 print " to " & Exp.print_component_ref c2 & print "\n"
13371351 ------------------------------------------------------
1338- check_connect_types(c1,_,SCode .ATTR(_, _,_,_,Absyn.OUTPUT),
1339- c2,_,SCode .ATTR(_, _,_,_,Absyn.OUTPUT)) => fail
1352+ check_connect_types(c1,_,Types .ATTR(_,_,_,Absyn.OUTPUT),
1353+ c2,_,Types .ATTR(_,_,_,Absyn.OUTPUT)) => fail
13401354
13411355 rule flow1 = flow2 &
13421356 Types.equivtypes(t1, t2) => true
13431357 -------------------------------
1344- check_connect_types(_,t1,SCode .ATTR(_, flow1,_,_,_),
1345- _,t2,SCode .ATTR(_, flow2,_,_,_))
1358+ check_connect_types(_,t1,Types .ATTR(flow1,_,_,_),
1359+ _,t2,Types .ATTR(flow2,_,_,_))
13461360
13471361 rule print "# Can't connect flow component " &
13481362 Exp.print_component_ref c1 &
13491363 print " to non-flow component " &
13501364 Exp.print_component_ref c2 & print "\n"
13511365 ------------------------------------------------------
1352- check_connect_types(c1,_,SCode .ATTR(_, true,_,_,_),
1353- c2,_,SCode .ATTR(_, false,_,_,_)) => fail
1366+ check_connect_types(c1,_,Types .ATTR(true,_,_,_),
1367+ c2,_,Types .ATTR(false,_,_,_)) => fail
13541368
13551369 rule print "# Can't connect non-flow component " &
13561370 Exp.print_component_ref c1 &
13571371 print " to flow component " &
13581372 Exp.print_component_ref c2 & print "\n"
13591373 ------------------------------------------------------
1360- check_connect_types(c1,_,SCode .ATTR(_, false,_,_,_),
1361- c2,_,SCode .ATTR(_, true,_,_,_)) => fail
1374+ check_connect_types(c1,_,Types .ATTR(false,_,_,_),
1375+ c2,_,Types .ATTR(true,_,_,_)) => fail
13621376
13631377 rule print "- check_connect_types(" & Exp.print_component_ref c1 &
13641378 print " <-> " & Exp.print_component_ref c2 & print ") failed\n"
@@ -1446,9 +1460,9 @@ relation connect_vars : (Connect.Sets,
14461460 connect_vars(sets',c1,f1,xs1,c2,f2,xs2) => sets''
14471461 --------------------------------------
14481462 connect_vars(sets,
1449- c1,f1, Types.VAR(n,attr1 as SCode .ATTR(_, flow1,_,vt1,_),
1463+ c1,f1, Types.VAR(n,attr1 as Types .ATTR(flow1,_,vt1,_),
14501464 _,ty1,_)::xs1,
1451- c2,f2, Types.VAR(_,attr2 as SCode .ATTR(_, flow2,_,vt2,_),
1465+ c2,f2, Types.VAR(_,attr2 as Types .ATTR(flow2,_,vt2,_),
14521466 _,ty2,_)::xs2)
14531467 => sets''
14541468
0 commit comments