Skip to content

Commit

Permalink
[As3] handle variable access on interface (fixed issue HaxeFoundation…
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Oct 4, 2012
1 parent 6619d2f commit 4e7a53f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions genas3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -554,15 +554,24 @@ and gen_expr ctx e =
| TBinop (Ast.OpEq,e1,e2) when (match is_special_compare e1 e2 with Some c -> true | None -> false) ->
let c = match is_special_compare e1 e2 with Some c -> c | None -> assert false in
gen_expr ctx (mk (TCall (mk (TField (mk (TTypeExpr (TClassDecl c)) t_dynamic e.epos,"compare")) t_dynamic e.epos,[e1;e2])) ctx.inf.com.basic.tbool e.epos);
| TBinop (op,{ eexpr = TField (e1,s) },e2) ->
(* what is this used for? *)
(* | TBinop (op,{ eexpr = TField (e1,s) },e2) ->
gen_value_op ctx e1;
gen_field_access ctx e1.etype s;
print ctx " %s " (Ast.s_binop op);
gen_value_op ctx e2;
gen_value_op ctx e2; *)
| TBinop (op,e1,e2) ->
gen_value_op ctx e1;
print ctx " %s " (Ast.s_binop op);
gen_value_op ctx e2;
(* variable fields on interfaces are generated as (class["field"] as class) *)
| TField ({etype = TInst({cl_interface = true} as c,_)} as e,s)
| TClosure ({etype = TInst({cl_interface = true} as c,_)} as e,s)
when (try (match (PMap.find s c.cl_fields).cf_kind with Var _ -> true | _ -> false) with Not_found -> false) ->
spr ctx "(";
gen_value ctx e;
print ctx "[\"%s\"]" s;
print ctx " as %s)" (type_str ctx e.etype e.epos);
| TField (e,s) | TClosure (e,s) ->
gen_value ctx e;
gen_field_access ctx e.etype s
Expand Down

0 comments on commit 4e7a53f

Please sign in to comment.