diff options
| author | Graydon Hoare <[email protected]> | 2011-01-11 17:58:03 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-01-11 17:58:03 -0800 |
| commit | b81aa05fa19a748e04808145cd8b7241f785693c (patch) | |
| tree | de30d119697c7aee29b423c179c3646e3dc569bd /src/boot/me/semant.ml | |
| parent | Out-of-line all drop glue. Shaves 50kb from rustc. (diff) | |
| download | rust-b81aa05fa19a748e04808145cd8b7241f785693c.tar.xz rust-b81aa05fa19a748e04808145cd8b7241f785693c.zip | |
Recursively genericize types and spread across glue. Saves 1mb size, 8s compile time on rustc.
Diffstat (limited to 'src/boot/me/semant.ml')
| -rw-r--r-- | src/boot/me/semant.ml | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/boot/me/semant.ml b/src/boot/me/semant.ml index 019cd13e..3ce5eba2 100644 --- a/src/boot/me/semant.ml +++ b/src/boot/me/semant.ml @@ -1146,6 +1146,37 @@ let get_nth_tag_tup ;; +let generic_obj_ty = + Ast.TY_obj (Ast.LAYER_value, Hashtbl.create 0) +;; + +let generic_fn_ty = + Ast.TY_fn ({ Ast.sig_input_slots = [| |]; + Ast.sig_input_constrs = [| |]; + Ast.sig_output_slot = + { Ast.slot_mode = Ast.MODE_local; + Ast.slot_ty = Some Ast.TY_nil }; }, + { Ast.fn_is_iter = false; + Ast.fn_effect = Ast.EFF_pure }) +;; + +let rec get_genericized_ty ty = + (* Using a full-and-honest fold here is too slow, sadly. *) + let sub = get_genericized_ty in + match ty with + Ast.TY_obj _ -> generic_obj_ty + | Ast.TY_fn _ -> generic_fn_ty + | Ast.TY_vec t -> Ast.TY_vec (sub t) + | Ast.TY_tup tys -> Ast.TY_tup (Array.map sub tys) + | Ast.TY_rec elts -> + Ast.TY_rec (Array.map (fun (id, t) -> (id, sub t)) elts) + | Ast.TY_box t -> + Ast.TY_box (sub t) + | Ast.TY_mutable t -> + Ast.TY_mutable (sub t) + | _ -> ty +;; + let associative_binary_op_ty_fold (default:'a) |