Browse Source

allow iteration over abstracts having length and `@;arrayAccess` fields again

Simon Krajewski 11 years ago
parent
commit
d68e610ff4
3 changed files with 5 additions and 4 deletions
  1. 3 4
      optimizer.ml
  2. 1 0
      typecore.ml
  3. 1 0
      typer.ml

+ 3 - 4
optimizer.ml

@@ -682,13 +682,12 @@ let rec optimize_for_loop ctx i e1 e2 p =
 			end;
 			end;
 			begin try
 			begin try
 				(* first try: do we have an @:arrayAccess getter field? *)
 				(* first try: do we have an @:arrayAccess getter field? *)
-(* 				let todo = mk (TConst TNull) ctx.t.tint p in
-				let cf,_,r = Codegen.AbstractCast.find_array_access ctx a tl todo None p in
+				let todo = mk (TConst TNull) ctx.t.tint p in
+				let cf,_,r,_,_ = (!find_array_access_raise_ref) ctx a tl todo None p in
 				let get_next e_base e_index t p =
 				let get_next e_base e_index t p =
 					make_static_call ctx c cf (apply_params a.a_params tl) [e_base;e_index] r p
 					make_static_call ctx c cf (apply_params a.a_params tl) [e_base;e_index] r p
 				in
 				in
-				gen_int_iter r get_next get_length *)
-				raise Not_found (* TODO *)
+				gen_int_iter r get_next get_length
 			with Not_found ->
 			with Not_found ->
 				(* second try: do we have @:arrayAccess on the abstract itself? *)
 				(* second try: do we have @:arrayAccess on the abstract itself? *)
 				if not (Meta.has Meta.ArrayAccess a.a_meta) then raise Not_found;
 				if not (Meta.has Meta.ArrayAccess a.a_meta) then raise Not_found;

+ 1 - 0
typecore.ml

@@ -155,6 +155,7 @@ let match_expr_ref : (typer -> Ast.expr -> (Ast.expr list * Ast.expr option * As
 let get_pattern_locals_ref : (typer -> Ast.expr -> Type.t -> (string, tvar * pos) PMap.t) ref = ref (fun _ _ _ -> assert false)
 let get_pattern_locals_ref : (typer -> Ast.expr -> Type.t -> (string, tvar * pos) PMap.t) ref = ref (fun _ _ _ -> assert false)
 let get_constructor_ref : (typer -> tclass -> t list -> Ast.pos -> (t * tclass_field)) ref = ref (fun _ _ _ _ -> assert false)
 let get_constructor_ref : (typer -> tclass -> t list -> Ast.pos -> (t * tclass_field)) ref = ref (fun _ _ _ _ -> assert false)
 let cast_or_unify_ref : (typer -> t -> texpr -> Ast.pos -> texpr) ref = ref (fun _ _ _ _ -> assert false)
 let cast_or_unify_ref : (typer -> t -> texpr -> Ast.pos -> texpr) ref = ref (fun _ _ _ _ -> assert false)
+let find_array_access_raise_ref : (typer -> tabstract -> tparams -> texpr -> texpr option -> pos -> (tclass_field * t * t * texpr * texpr option)) ref = ref (fun _ _ _ _ _ _ -> assert false)
 
 
 (* Source: http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#OCaml *)
 (* Source: http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#OCaml *)
 let levenshtein a b =
 let levenshtein a b =

+ 1 - 0
typer.ml

@@ -4829,3 +4829,4 @@ make_call_ref := make_call;
 get_constructor_ref := get_constructor;
 get_constructor_ref := get_constructor;
 cast_or_unify_ref := Codegen.AbstractCast.cast_or_unify_raise;
 cast_or_unify_ref := Codegen.AbstractCast.cast_or_unify_raise;
 type_module_type_ref := type_module_type;
 type_module_type_ref := type_module_type;
+find_array_access_raise_ref := Codegen.AbstractCast.find_array_access_raise