Skip to content

Commit

Permalink
fix IR renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreif committed Jul 11, 2024
1 parent b6ee8dd commit 812d78d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/ir_def/ir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ let replace_obj_pat pfs pats =

(* Helper for transforming prims, without missing embedded typs and ids *)

let map_prim t_typ t_id p =
let map_prim t_typ t_id t_exp p =
match p with
| CallPrim (ts, _FIXME) -> CallPrim (List.map t_typ ts, _FIXME)
| CallPrim (ts, par) -> CallPrim (List.map t_typ ts, t_exp par)
| UnPrim (ot, op) -> UnPrim (t_typ ot, op)
| BinPrim (ot, op) -> BinPrim (t_typ ot, op)
| RelPrim (ot, op) -> RelPrim (t_typ ot, op)
Expand Down Expand Up @@ -307,9 +307,9 @@ let map_prim t_typ t_id p =
| ICPerformGC
| ICRejectPrim
| ICCallerPrim
| ICCallPrim _ (* FIXME: how to transform this? *)
| ICCallRawPrim
| ICMethodNamePrim -> p
| ICCallPrim setup -> ICCallPrim (Option.map t_exp setup)
| ICStableWrite t -> ICStableWrite (t_typ t)
| ICStableRead t -> ICStableRead (t_typ t)
| ICStableSize t -> ICStableSize (t_typ t)
4 changes: 2 additions & 2 deletions src/ir_def/rename.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ let arg_bind rho a =
let i' = fresh_id a.it in
({a with it = i'}, Renaming.add a.it i' rho)

let rec prim rho p =
Ir.map_prim (fun t -> t) (id rho) p (* rename BreakPrim id etc *)
let rec prim rho =
Ir.map_prim (fun t -> t) (id rho) (exp rho) (* rename BreakPrim id etc *)

and exp rho e = {e with it = exp' rho e.it}
and exp' rho = function
Expand Down
5 changes: 3 additions & 2 deletions src/ir_passes/async.ml
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ let transform prog =
Type.set_kind clone (t_kind (Cons.kind c));
clone

and t_prim p = Ir.map_prim t_typ (fun id -> id) p

and t_field {lab; typ; src} =
{ lab; typ = t_typ typ; src }
in
Expand All @@ -241,6 +239,9 @@ let transform prog =
};
at = exp.at;
}

and t_prim p = Ir.map_prim t_typ (fun id -> id) t_exp p

and t_exp' (exp:exp) =
let exp' = exp.it in
match exp' with
Expand Down
5 changes: 3 additions & 2 deletions src/ir_passes/erase_typ_field.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ let transform prog =
Type.set_kind clone (t_kind (Cons.kind c));
clone

and t_prim p = Ir.map_prim t_typ (fun id -> id) p

and t_field {lab; typ; src} =
{ lab; typ = t_typ typ; src }
in
Expand All @@ -97,6 +95,9 @@ let transform prog =
};
at = exp.at;
}

and t_prim p = Ir.map_prim t_typ (fun id -> id) t_exp p

and t_exp' (exp : exp) =
let exp' = exp.it in
match exp' with
Expand Down
3 changes: 1 addition & 2 deletions test/run-drun/clone/cloneable.mo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ actor class Cloneable(

// our clone methods, indirecting through makeCloneable
public func clone(init : Nat) : async Cloneable {
Cycles.add<system>(Cycles.balance() / 2);
await makeCloneable(init : Nat);
await (with cycles = Cycles.balance() / 2) makeCloneable init;
}
}

0 comments on commit 812d78d

Please sign in to comment.