implement size_ty

Signed-off-by: Mariano Uvalle <u.g.a.mariano@gmail.com>
This commit is contained in:
Mariano Uvalle 2025-02-12 21:16:19 -08:00
parent ca3e1df031
commit ea32e468a3

View file

@ -173,7 +173,12 @@ let compile_operand (ctxt : ctxt) (dest : X86.operand) : Ll.operand -> ins = fun
Your function should simply return 0 in those cases
*)
let rec size_ty (tdecls : (tid * ty) list) (t : Ll.ty) : int =
failwith "size_ty not implemented"
match t with
| Struct tl -> List.fold_left (fun acc st -> acc + size_ty tdecls st) 0 tl
| Array (sz, at) -> sz * size_ty tdecls at
| Namedt lb -> size_ty tdecls (lookup tdecls lb)
| I1 | I64 | Ptr _ -> 8
| Void | I8 | Fun _ -> 0
;;
(* Generates code that computes a pointer value.