Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
marcpouzet committed Oct 28, 2024
1 parent 4a5649d commit 1dba3af
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/compiler/gencode/oprinter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ and mkind mk =
| Eencore -> "encore "
| Eperiod -> "period "

and memory ff { m_name; m_value; m_typ; m_kind = k; m_size } =
fprintf ff "%s%a%a : %a = %a" (mkind k) name m_name
and memory ff { m_name; m_value; m_typ; m_kind; m_size } =
let mem = function
| None -> "" | Some(k) -> (Ptypes.kind k) ^ " " in
fprintf ff "%s%a%a : %a = %a" (mem m_kind) name m_name
(print_list_no_space (print_with_braces (exp 0) "[" "]") "" "" "")
m_size ptype m_typ (print_opt (exp 0)) m_value

Expand Down
25 changes: 11 additions & 14 deletions src/compiler/gencode/translate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -320,29 +320,26 @@ let append loop_path l_env env =
let apply k env loop_path e e_list
({ mem = m; init = i; instances = j; reset = r; step = s } as code) =
match k with
| Deftypes.Tstatic _
| Deftypes.Tany | Deftypes.Tdiscrete(false) -> Oapp(e, e_list), code
| Deftypes.Tdiscrete(true)
| Deftypes.Tcont
| Deftypes.Tproba ->
| Deftypes.Tfun _ -> Eapp { f = e; arg_list = e_list }, code
| Deftypes.Tnode _ ->
(* the first [n-1] arguments are static *)
let se_list, arg = Zmisc.firsts e_list in
let f_opt = match e with | Oglobal(g) -> Some(g) | _ -> None in
let loop_path = List.map (fun ix -> Olocal(ix)) loop_path in
let se_list, arg = Misc.firsts e_list in
let f_opt = match e with | Eglobal(g) -> Some(g) | _ -> None in
let loop_path = List.map (fun ix -> Elocal(ix)) loop_path in
(* create an instance *)
let o = Zident.fresh "i" in
let o = Ident.fresh "i" in
let j_code = { i_name = o; i_machine = e; i_kind = k;
i_params = se_list; i_size = [] } in
let reset_code =
Omethodcall({ met_machine = f_opt; met_name = Oaux.reset;
Emethodcall({ met_machine = f_opt; met_name = Oaux.reset;
met_instance = Some(o, loop_path); met_args = [] }) in
let step_code =
Omethodcall({ met_machine = f_opt; met_name = Oaux.step;
Emethodcall({ met_machine = f_opt; met_name = Oaux.step;
met_instance = Some(o, loop_path); met_args = [arg] }) in
step_code,
{ code with instances = Parseq.cons j_code j;
init = sequence (Oexp(reset_code)) i;
reset = sequence (Oexp(reset_code)) r }
init = seq (Oexp(reset_code)) i;
reset = seq (Oexp(reset_code)) r }

(** Translation of expressions under an environment [env] *)
(* [code] is the code already generated in the context. *)
Expand All @@ -353,7 +350,7 @@ let apply k env loop_path e e_list
let rec exp env loop_path code { Zelus.e_desc = desc } =
match desc with
| Zelus.Econst(i) -> Oconst(immediate i), code
| Zelus.Elocal(n)
| Zelus.Evar(n)
| Zelus.Elast(n) -> var (entry_of n env), code
| Zelus.Eglobal { lname = ln } -> Oglobal(ln), code
| Zelus.Econstr0(ln) -> Oconstr0(ln), code
Expand Down
6 changes: 6 additions & 0 deletions src/typdefs/ptypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ let print_list print_el sep ff l =
in
printrec ff l

let kind k =
match k with
| Cont -> "cont" | Zero -> "zero"
| Period -> "period" | Horizon -> "horizon"
| Encore -> "encore" | Major -> "major"

let arrow_tostring = function
| Tfun(k) ->
(match k with Tconst -> "-V->" | Tstatic -> "-S->" | Tany -> "-A->")
Expand Down

0 comments on commit 1dba3af

Please sign in to comment.