Skip to content

Commit

Permalink
store type parameters in FClosure too
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Jan 15, 2015
1 parent ac9a023 commit f996b26
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion codegen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ module DeprecationCheck = struct
| FAnon cf ->
check_cf com cf e.epos
| FClosure(co,cf) ->
(match co with None -> () | Some c -> check_class com c e.epos);
(match co with None -> () | Some (c,_) -> check_class com c e.epos);
check_cf com cf e.epos
| FEnum(en,ef) ->
check_enum com en e.epos;
Expand Down
6 changes: 3 additions & 3 deletions gencommon.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3374,7 +3374,7 @@ struct
expr,clscapt
| Some _ ->
{
eexpr = TField(expr, FClosure(Some cls,invokecf));
eexpr = TField(expr, FClosure(Some (cls,[]),invokecf)); (* TODO: FClosure change *)
etype = invokecf.cf_type;
epos = cls.cl_pos
}, clscapt
Expand Down Expand Up @@ -6226,7 +6226,7 @@ struct
cf,t,false
| true ->
let (cf, actual_t, error), is_static = match f with
| FInstance(c,_,cf) | FClosure(Some c,cf) ->
| FInstance(c,_,cf) | FClosure(Some (c,_),cf) ->
(* get from overloads *)
(* FIXME: this is a workaround for issue #1743 . Uncomment this code after it was solved *)
(* let t, cf = List.find (fun (t,cf2) -> cf == cf2) (Typeload.get_overloads cl (field_name f)) in *)
Expand Down Expand Up @@ -7785,7 +7785,7 @@ struct
| Var _
| Method MethDynamic -> { eexpr = TField (ethis, FInstance(cl,List.map snd cl.cl_params,cf)); etype = cf_type; epos = pos }
| _ ->
{ eexpr = TField (this, FClosure(Some cl, cf)); etype = cf_type; epos = pos }
{ eexpr = TField (this, FClosure(Some (cl,[]), cf)); etype = cf_type; epos = pos } (* TODO: FClosure change *)
in

let do_field cf cf_type static =
Expand Down
2 changes: 1 addition & 1 deletion genjs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ and gen_expr ctx e =
print ctx "$iterator(";
gen_value ctx x;
print ctx ")";
| TField (x,FClosure (Some {cl_path=[],"Array"}, {cf_name="push"})) ->
| TField (x,FClosure (Some ({cl_path=[],"Array"},_), {cf_name="push"})) ->
(* see https://github.com/HaxeFoundation/haxe/issues/1997 *)
add_feature ctx "use.$arrayPushClosure";
print ctx "$arrayPushClosure(";
Expand Down
2 changes: 1 addition & 1 deletion genpy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ module Transformer = struct
| (is_value, TBinop(OpAssignOp op,{eexpr = TField(e1,FDynamic s)},e2)) ->
let e = dynamic_field_read_write ae.a_next_id e1 s op e2 in
transform_expr ~is_value:is_value e
| (is_value, TField(e1, FClosure(Some {cl_path = [],("String" | "list")},cf))) ->
| (is_value, TField(e1, FClosure(Some ({cl_path = [],("String" | "list")},_),cf))) ->
let e = dynamic_field_read e1 cf.cf_name in
transform_expr ~is_value:is_value e
| (is_value, TBinop(OpAssign, left, right))->
Expand Down
2 changes: 1 addition & 1 deletion interp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4564,7 +4564,7 @@ and encode_field_access fa =
| FStatic(c,cf) -> 1,[encode_clref c;encode_cfref cf]
| FAnon(cf) -> 2,[encode_cfref cf]
| FDynamic(s) -> 3,[enc_string s]
| FClosure(co,cf) -> 4,[vopt encode_clref co;encode_cfref cf]
| FClosure(co,cf) -> 4,[(match co with Some (c,_) -> encode_clref c | None -> VNull);encode_cfref cf] (* TODO: breaking change, kind of, too *)
| FEnum(en,ef) -> 5,[encode_enref en;encode_efield ef]
in
enc_enum IFieldAccess tag pl
Expand Down
2 changes: 1 addition & 1 deletion optimizer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ let rec reduce_loop ctx e =
| None -> reduce_expr ctx e
| Some e -> reduce_loop ctx e)
| TCall ({ eexpr = TField (o,FClosure (c,cf)) } as f,el) ->
let fmode = (match c with None -> FAnon cf | Some c -> FInstance (c,[],cf)) in (* TODO *)
let fmode = (match c with None -> FAnon cf | Some (c,tl) -> FInstance (c,tl,cf)) in
{ e with eexpr = TCall ({ f with eexpr = TField (o,fmode) },el) }
| TSwitch (e1,[[{eexpr = TConst (TBool true)}],{eexpr = TConst (TBool true)}],Some ({eexpr = TConst (TBool false)})) ->
(* introduced by extractors in some cases *)
Expand Down
6 changes: 3 additions & 3 deletions type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ and tfield_access =
| FStatic of tclass * tclass_field
| FAnon of tclass_field
| FDynamic of string
| FClosure of tclass option * tclass_field (* None class = TAnon *)
| FClosure of (tclass * tparams) option * tclass_field (* None class = TAnon *)
| FEnum of tenum * tenum_field

and texpr = {
Expand Down Expand Up @@ -907,7 +907,7 @@ let rec s_expr s_type e =
let fstr = (match f with
| FStatic (c,f) -> "static(" ^ s_type_path c.cl_path ^ "." ^ f.cf_name ^ ")"
| FInstance (c,_,f) -> "inst(" ^ s_type_path c.cl_path ^ "." ^ f.cf_name ^ " : " ^ s_type f.cf_type ^ ")"
| FClosure (c,f) -> "closure(" ^ (match c with None -> f.cf_name | Some c -> s_type_path c.cl_path ^ "." ^ f.cf_name) ^ ")"
| FClosure (c,f) -> "closure(" ^ (match c with None -> f.cf_name | Some (c,_) -> s_type_path c.cl_path ^ "." ^ f.cf_name) ^ ")"
| FAnon f -> "anon(" ^ f.cf_name ^ ")"
| FEnum (en,f) -> "enum(" ^ s_type_path en.e_path ^ "." ^ f.ef_name ^ ")"
| FDynamic f -> "dynamic(" ^ f ^ ")"
Expand Down Expand Up @@ -1076,7 +1076,7 @@ let rec s_expr_ast print_var_ids tabs s_type e =
let sfa = match fa with
| FInstance(c,tl,cf) -> tag "FInstance" ~extra_tabs:"\t" [s_type (TInst(c,tl)); cf.cf_name]
| FStatic(c,cf) -> tag "FStatic" ~extra_tabs:"\t" [s_type_path c.cl_path; cf.cf_name]
| FClosure(co,cf) -> tag "FClosure" ~extra_tabs:"\t" [(match co with None -> "None" | Some c -> s_type_path c.cl_path); cf.cf_name]
| FClosure(co,cf) -> tag "FClosure" ~extra_tabs:"\t" [(match co with None -> "None" | Some (c,_) -> s_type_path c.cl_path); cf.cf_name]
| FAnon cf -> tag "FAnon" ~extra_tabs:"\t" [cf.cf_name]
| FDynamic s -> tag "FDynamic" ~extra_tabs:"\t" [s]
| FEnum(en,ef) -> tag "FEnum" ~extra_tabs:"\t" [s_type_path en.e_path; ef.ef_name]
Expand Down
6 changes: 3 additions & 3 deletions typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ let rec acc_get ctx g p =
| _ -> assert false)
| AKInline (e,f,fmode,t) ->
(* do not create a closure for static calls *)
let cmode = (match fmode with FStatic _ -> fmode | FInstance (c,_,f) -> FClosure (Some c,f) | _ -> assert false) in
let cmode = (match fmode with FStatic _ -> fmode | FInstance (c,tl,f) -> FClosure (Some (c,tl),f) | _ -> assert false) in
ignore(follow f.cf_type); (* force computing *)
(match f.cf_expr with
| None ->
Expand Down Expand Up @@ -1126,7 +1126,7 @@ let field_access ctx mode f fmode t e p =
| _ , MGet ->
let cmode = (match fmode with
| FInstance(_, _, cf) | FStatic(_, cf) when Meta.has Meta.Generic cf.cf_meta -> display_error ctx "Cannot create closure on generic function" p; fmode
| FInstance (c,_,cf) -> FClosure (Some c,cf)
| FInstance (c,tl,cf) -> FClosure (Some (c,tl),cf)
| FStatic _ | FEnum _ -> fmode
| FAnon f -> FClosure (None, f)
| FDynamic _ | FClosure _ -> assert false
Expand Down Expand Up @@ -2012,7 +2012,7 @@ and type_binop2 ctx op (e1 : texpr) (e2 : Ast.expr) is_assign_op wt p =
let std = type_type ctx ([],"Std") e.epos in
let acc = acc_get ctx (type_field ctx std "string" e.epos MCall) e.epos in
ignore(follow acc.etype);
let acc = (match acc.eexpr with TField (e,FClosure (Some c,f)) -> { acc with eexpr = TField (e,FInstance (c,[],f)) } | _ -> acc) in
let acc = (match acc.eexpr with TField (e,FClosure (Some (c,tl),f)) -> { acc with eexpr = TField (e,FInstance (c,tl,f)) } | _ -> acc) in
make_call ctx acc [e] ctx.t.tstring e.epos
| KAbstract (a,tl) ->
loop (Abstract.get_underlying_type a tl)
Expand Down

0 comments on commit f996b26

Please sign in to comment.