Browse Source

reverted r4815, instead translate ["iterator"] to .iterator

Nicolas Cannasse 13 years ago
parent
commit
93cf34a5f0
3 changed files with 13 additions and 11 deletions
  1. 3 0
      genjs.ml
  2. 3 1
      std/js/JQuery.hx
  3. 7 10
      typer.ml

+ 3 - 0
genjs.ml

@@ -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 "[";

+ 3 - 1
std/js/JQuery.hx

@@ -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.

+ 7 - 10
typer.ml

@@ -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
@@ -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);