Skip to content
Browse files

allow storing type parameters in get_build_infos

  • Loading branch information...
1 parent 641b5e1 commit 7797e9fda904670efc1b31b5d9a67b4bc7832b30 @Simn Simn committed Dec 3, 2013
Showing with 9 additions and 9 deletions.
  1. +1 −1 typecore.ml
  2. +1 −1 typeload.ml
  3. +7 −7 typer.ml
View
2 typecore.ml
@@ -67,7 +67,7 @@ type typer_globals = {
mutable std : module_def;
mutable hook_generate : (unit -> unit) list;
type_patches : (path, (string * bool, type_patch) Hashtbl.t * type_patch) Hashtbl.t;
- mutable get_build_infos : unit -> (module_type * Ast.class_field list) option;
+ mutable get_build_infos : unit -> (module_type * t list * Ast.class_field list) option;
delayed_macros : (unit -> unit) DynArray.t;
mutable global_using : tclass list;
(* api *)
View
2 typeload.ml
@@ -1420,7 +1420,7 @@ let build_module_def ctx mt meta fvars context_init fbuild =
let s = try String.concat "." (List.rev (string_list_of_expr_path epath)) with Error (_,p) -> error "Build call parameter must be a class path" p in
if ctx.in_macro then error "You cannot use @:build inside a macro : make sure that your enum is not used in macro" p;
let old = ctx.g.get_build_infos in
- ctx.g.get_build_infos <- (fun() -> Some (mt, fvars()));
+ ctx.g.get_build_infos <- (fun() -> Some (mt, List.map snd (t_infos mt).mt_types, fvars()));
context_init();
let r = try apply_macro ctx MBuild s el p with e -> ctx.g.get_build_infos <- old; raise e in
ctx.g.get_build_infos <- old;
View
14 typer.ml
@@ -3801,12 +3801,12 @@ let make_macro_api ctx p =
);
Interp.get_local_type = (fun() ->
match ctx.g.get_build_infos() with
- | Some (mt,_) ->
+ | Some (mt,tl,_) ->
Some (match mt with
- | TClassDecl c -> TInst (c,List.map snd c.cl_types)
- | TEnumDecl e -> TEnum (e,List.map snd e.e_types)
- | TTypeDecl t -> TType (t,List.map snd t.t_types)
- | TAbstractDecl a -> TAbstract(a,List.map snd a.a_types))
+ | TClassDecl c -> TInst (c,tl)
+ | TEnumDecl e -> TEnum (e,tl)
+ | TTypeDecl t -> TType (t,tl)
+ | TAbstractDecl a -> TAbstract(a,tl))
| None ->
if ctx.curclass == null_class then
None
@@ -3830,7 +3830,7 @@ let make_macro_api ctx p =
Interp.get_build_fields = (fun() ->
match ctx.g.get_build_infos() with
| None -> Interp.VNull
- | Some (_,fields) -> Interp.enc_array (List.map Interp.encode_field fields)
+ | Some (_,_,fields) -> Interp.enc_array (List.map Interp.encode_field fields)
);
Interp.get_pattern_locals = (fun e t ->
!get_pattern_locals_ref ctx e t
@@ -4120,7 +4120,7 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
| Interp.VNull ->
(match ctx.g.get_build_infos() with
| None -> assert false
- | Some (_,fields) -> fields)
+ | Some (_,_,fields) -> fields)
| _ ->
List.map Interp.decode_field (Interp.dec_array v)
) in

0 comments on commit 7797e9f

Please sign in to comment.
Something went wrong with that request. Please try again.