diff --git a/hw3/bin/backend.ml b/hw3/bin/backend.ml index 41e5b91..25bb6ad 100644 --- a/hw3/bin/backend.ml +++ b/hw3/bin/backend.ml @@ -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.