rename Ir.compile_lambda => lower_lambda

This commit is contained in:
tali 2023-12-13 17:37:19 -05:00
parent fab3b76d9c
commit 37377c044d
1 changed files with 3 additions and 4 deletions

View File

@ -190,14 +190,12 @@ let lower ~lib (modl : Ast.modl) =
fns, name :: vls, init :: ins fns, name :: vls, init :: ins
| Ast.Item_fun (name, args, body) -> | Ast.Item_fun (name, args, body) ->
let fn = name, compile_lambda self env args body in let fn = (name, lower_lambda self env args body) in
fn :: fns, vls, ins) fn :: fns, vls, ins)
([], [], []) ([], [], [])
items items
in in
(* TODO: closure conversion *)
(* if [is_scope], return the last expr, otherwise return the object itself *) (* if [is_scope], return the last expr, otherwise return the object itself *)
let ret, inits_r = match is_scope, inits_r with let ret, inits_r = match is_scope, inits_r with
| true, init :: inits -> init, inits | true, init :: inits -> init, inits
@ -217,9 +215,10 @@ let lower ~lib (modl : Ast.modl) =
inits_r inits_r
) )
and compile_lambda self env args body = and lower_lambda self env args body =
let args = List.map (fun a -> a, new_id ()) args in let args = List.map (fun a -> a, new_id ()) args in
let env = Env.Cons (Fun { args }, env) in let env = Env.Cons (Fun { args }, env) in
(* TODO: closure conversion *)
let body = lower_exp env body in let body = lower_exp env body in
let args = List.map snd args in let args = List.map snd args in
{ self; args; body } { self; args; body }