@@ -10,6 +10,7 @@ module Static :
1010
1111 with "absyn.rml"
1212 with "exp.rml"
13+ with "explode.rml"
1314 with "types.rml"
1415 with "env.rml"
1516 with "values.rml"
@@ -335,23 +336,25 @@ end
335336relation elab_call_args : (Env.Env, Absyn.Path, Absyn.Exp list)
336337 => (Exp.Exp, Properties) =
337338
338- (*
339+ (* This rule finds user-defined functions. *)
340+
341+ rule Lookup.lookup_type(env,fn) => (t as Types.T_COMPLEX(st,vl)) &
342+ (* ClassInf.valid(st, Absyn.R_FUNCTION) & *)
343+ function_params(vl) => (in,out as [(_,rt)]) &
344+ elab_input_args(env, args, in) => (args', c)
345+ --------------------------------------------
346+ elab_call_args(env,fn,args) => (Exp.CALL(fn,args'), PROP(rt, c))
347+
348+ (* This rule finds the built-in functions *)
349+
339350 rule Lookup.lookup_type(env,fn) => (t as Types.T_FUNCTION(params,restype)) &
340351 print " function " & Dump.print_path fn & print " is " &
341352 Types.print_type t & print "\n" &
342- elab_call_args(env,args,params) => (args',c)
353+ (* elab_call_args(env,args,params) => (args',c) *)
354+ elab_input_args(env, args, params) => (args',c)
343355 -------------------------------------
344- elab_call2 (env,fn,args) => (Exp.CALL(fn,args'), PROP(restype, c))
345- *)
356+ elab_call_args (env,fn,args) => (Exp.CALL(fn,args'), PROP(restype, c))
346357
347- rule (* Lookup.lookup_class(env,fn) => fcl & *)
348- Lookup.lookup_type(env,fn) => (t as Types.T_COMPLEX(st,vl)) &
349- (* ClassInf.valid(st, Absyn.R_FUNCTION) & *)
350- function_params(vl) => (in,out as [Types.VAR(_,_,_,rt,_)]) &
351- elab_input_args(env, args, in) => args'
352- (** FIXME: calculate properties *)
353- ----------------------------------
354- elab_call_args(env,fn,args) => (Exp.CALL(fn,args'), PROP(rt, false))
355358
356359 rule not Lookup.lookup_type(env,fn) => _ &
357360 print "# Couldn't find function " & Dump.print_path fn & print "\n"
372375 ** separate lists.
373376 **)
374377
375- relation function_params : Types.Var list => (Types.Var list, Types.Var list) =
378+ relation function_params : Types.Var list => ((Ident * Types.Type) list,
379+ (Ident * Types.Type) list) =
376380
377381 axiom function_params [] => ([],[])
378382
@@ -383,20 +387,20 @@ relation function_params : Types.Var list => (Types.Var list, Types.Var list) =
383387
384388 rule function_params vs => (in, out)
385389 ------------------------------
386- function_params ((v as Types.VAR(_,Absyn .ATTR(_,_,_,Absyn.INPUT),
387- false,_,_) )::vs)
388- => (v ::in, out)
390+ function_params (Types.VAR(n,SCode .ATTR(_,_,_,Absyn.INPUT),
391+ false,t,Types.UNBOUND )::vs)
392+ => ((n,t) ::in, out)
389393
390394 rule function_params vs => (in, out)
391395 ------------------------------
392- function_params ((v as Types.VAR(_,Absyn .ATTR(_,_,_,Absyn.OUTPUT),
393- false,_,_) )::vs)
394- => (in, v ::out)
396+ function_params (Types.VAR(n,SCode .ATTR(_,_,_,Absyn.OUTPUT),
397+ false,t,Types.UNBOUND )::vs)
398+ => (in, (n,t) ::out)
395399
396400 rule print "# Components in functions must be INPUT or OUTPUT\n" &
397401 print " component: " & print n & print "\n"
398402 ----------------------------------------------
399- function_params((v as Types.VAR(n,Absyn .ATTR(_,_,_,Absyn.BIDIR),_,_,_))
403+ function_params((v as Types.VAR(n,SCode .ATTR(_,_,_,Absyn.BIDIR),_,_,_))
400404 ::vs) => fail
401405
402406 rule print "- function_params failed\n"
@@ -413,24 +417,25 @@ end
413417 ** `Types.Var'.
414418 **)
415419
416- relation elab_input_args : (Env.Env, Absyn.Exp list, Types.Var list)
417- => Exp.Exp list =
420+ relation elab_input_args : (Env.Env, Absyn.Exp list, (Ident * Types.Type) list)
421+ => ( Exp.Exp list, bool) =
418422
419- axiom elab_input_args(_, [], []) => []
423+ axiom elab_input_args(_, [], []) => ([], true)
420424
421- rule elab_exp(env, e) => (e',PROP(t,_ )) &
425+ rule elab_exp(env, e) => (e',PROP(t, c1 )) &
422426 match_type(e', t, vt) => e'' &
423- elab_input_args(env, es, vs) => args'
427+ elab_input_args(env, es, vs) => (args', c2) &
428+ bool_and(c1, c2) => c
424429 -------------------------------------
425- elab_input_args(env, e::es, Types.VAR (_,_,_,vt,_ )::vs) => e''::args'
430+ elab_input_args(env, e::es, (_,vt )::vs) => ( e''::args', c)
426431
427432 rule elab_exp(env, e) => (e',PROP(t,_)) &
428433 print "# Argument (" & Dump.print_exp e &
429434 print ") doesn't match parameter type\n" &
430435 print " parameter type: " & Types.print_type vt & print "\n" &
431436 print " argument type: " & Types.print_type t & print "\n"
432437 -------------------------------------------------------------
433- elab_input_args(env, e::es, Types.VAR (_,_,_,vt,_ )::vs) => fail
438+ elab_input_args(env, e::es, (_,vt )::vs) => fail
434439
435440end
436441
@@ -484,11 +489,11 @@ relation elab_cref : (Env.Env, Absyn.ComponentRef) => (Exp.Exp, Properties) =
484489 rule print " elab_cref " & Dump.print_component_ref c & print "\n" &
485490 elab_cref_subs (env,c) => (c', const) &
486491 print " subs\n" &
487- Lookup.lookup_var (env,c') => (Absyn .ATTR(ad,_,vartype ,_),
492+ Lookup.lookup_var (env,c') => (SCode .ATTR(ad,_,variability ,_),
488493 t,
489494 binding) &
490495 print " looked it up\n" &
491- elab_cref2 (env, c', vartype , t, binding) => (exp,const) &
496+ elab_cref2 (env, c', variability , t, binding) => (exp,const) &
492497 subscript_cref_type (exp,t) => t' &
493498 print " elab_cref " & Dump.print_component_ref c &
494499 print " => " & print " (" & Types.print_type t' & print ")\n"
509514 **)
510515
511516relation elab_cref2 : (Env.Env,
512- Exp.ComponentRef, Absyn.VarType ,
517+ Exp.ComponentRef, Absyn.Variability ,
513518 Types.Type, Types.Binding) => (Exp.Exp,bool) =
514519
515520 (* FIXME: Check type of expression anyway? *)
0 commit comments