Skip to content

Commit

Permalink
reverted r4815, instead translate ["iterator"] to .iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Jun 8, 2012
1 parent cf02072 commit 93cf34a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
3 changes: 3 additions & 0 deletions genjs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ and gen_expr ctx e =
| TLocal v -> spr ctx (ident v.v_name)
| TEnumField (e,s) ->
print ctx "%s%s" (ctx.type_accessor (TEnumDecl e)) (field s)
| TArray (e1,{ eexpr = TConst (TString s) }) ->
gen_value ctx e1;
spr ctx (field s)
| TArray (e1,e2) ->
gen_value ctx e1;
spr ctx "[";
Expand Down
4 changes: 3 additions & 1 deletion std/js/JQuery.hx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ extern class JQuery implements ArrayAccess<Dom.HtmlDom> {
//}

// haXe addition
@:defineFeature function iterator() : Iterator<JQuery>;
@:runtime inline function iterator() : Iterator<JQuery> {
return untyped this["iterator"]();
}

/**
Return the current JQuery element (in a callback), similar to $(this) in JS.
Expand Down
17 changes: 7 additions & 10 deletions typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2176,29 +2176,26 @@ and check_to_string ctx t =
(* ---------------------------------------------------------------------- *)
(* DEAD CODE ELIMINATION *)

let dce_check_metadata ctx ?(auto_keep=false) meta =
let keep = ref auto_keep in
let r = List.exists (fun (m,e,_) ->
let dce_check_metadata ctx meta =
List.exists (fun (m,e,_) ->
match m,e with
| ":?used",_
| ":keep",_ ->
true
| ":defineFeature",_ ->
keep := false;
false
| ":feature",el ->
List.exists (fun e -> match e with (EConst(String s),_) -> has_feature ctx.com s | _ -> false) el
| _ -> false
) meta in
r || !keep
) meta

let dce_check_class ctx c =
let keep_whole_class = c.cl_interface || has_meta ":keep" c.cl_meta || (match c.cl_path with ["php"],"Boot" | ["neko"],"Boot" | ["flash"],"Boot" | [],"Array" | [],"String" -> not (platform ctx.com Js) | _ -> false) in
let keep stat f =
keep_whole_class
|| dce_check_metadata ctx ~auto_keep:(c.cl_extern && f.cf_kind <> Method MethInline) f.cf_meta
|| (c.cl_extern && (match f.cf_kind with Method MethInline -> false | _ -> true))
|| dce_check_metadata ctx f.cf_meta
|| (stat && f.cf_name = "__init__")
|| (not stat && f.cf_name = "resolve" && (match c.cl_dynamic with Some _ -> true | None -> false))
|| (f.cf_name = "new" && has_meta ":?used" c.cl_meta)
|| match String.concat "." (fst c.cl_path @ [snd c.cl_path;f.cf_name]) with
| "EReg.new" -> true
| "flash._Boot.RealBoot.new" -> true
Expand Down Expand Up @@ -2254,7 +2251,7 @@ let dce_optimize ctx =
| { cl_interface = true }
| { cl_path = ["flash";"_Boot"],"RealBoot" }
-> ()
| _ when dce_check_metadata ctx c.cl_meta || (match c.cl_constructor with Some f -> dce_check_metadata ctx f.cf_meta | _ -> false)
| _ when has_meta ":?used" c.cl_meta || has_meta ":keep" c.cl_meta || (match c.cl_constructor with Some f -> has_meta ":?used" f.cf_meta | _ -> false)
-> ()
| _ ->
Common.log ctx.com ("Removing " ^ s_type_path c.cl_path);
Expand Down

0 comments on commit 93cf34a

Please sign in to comment.