ajout frame_descriptor

This commit is contained in:
Nicolas PENELOUX 2024-01-01 18:19:13 +01:00
parent 7beb9e284b
commit dd7fa10c6b

View file

@ -522,11 +522,28 @@ module FrameManager (IS : InstructionSelector) : FrameManager = struct
Mint.size_in_bytes Mint.size_in_bytes
+ ((if empty_frame fd then 0 else 1) * Mint.size_in_bytes) + ((if empty_frame fd then 0 else 1) * Mint.size_in_bytes)
+ fd.locals_space + fd.locals_space
;;
let add_stack stack list start op_addr =
let stack, _ = List.fold_left
(fun (stack,addr) id ->
S.IdMap.add id (Mint.of_int addr) stack,
op_addr addr)
(stack,start)
list
in stack
let frame_descriptor ~params ~locals = let frame_descriptor ~params ~locals =
(* TODO: Student! Implement me! *) (* TODO: Student! Implement me! *)
{ param_count = 0; locals_space = 0; stack_map = S.IdMap.empty } let stack = add_stack S.IdMap.empty locals (-8) (fun x -> x - 8) in
let stack = add_stack stack params 16 (fun x -> x + 8) in
{param_count = List.length params; locals_space = (List.length locals) * 8; stack_map = stack; }
;;
(* Ajout à la pile les variables présentent dans la liste *)
;; ;;
let location_of fd id : T.address = let location_of fd id : T.address =