Browse Source

fixed null references in class constructors for array arguments
fixed php.Boot.__string_rec() when invoked from toString

Franco Ponticelli 17 years ago
parent
commit
4b36a730e5
3 changed files with 86 additions and 191 deletions
  1. 2 0
      doc/CHANGES.txt
  2. 19 126
      genphp.ml
  3. 65 65
      std/php/Boot.hx

+ 2 - 0
doc/CHANGES.txt

@@ -7,6 +7,8 @@ TODO inlining : allow inlined getter/setter
 TODO inlining : substitute class+function type parameters in order to have fully typed expressions
 
 2008-??-??: 2.01
+	fixed null references in class constructors for array arguments
+	fixed php.Boot.__string_rec() when invoked from toString
 	added neko.NativeString
 	fixed php.Sys
 

+ 19 - 126
genphp.ml

@@ -37,7 +37,6 @@ type context = {
 	mutable in_static : bool;
 	mutable handle_break : bool;
 	mutable imports : (string,string list list) Hashtbl.t;
-(*	mutable required_paths : (string list * string) list;  *)
 	mutable locals : (string,string) PMap.t;
 	mutable inv_locals : (string,string) PMap.t;
 	mutable local_types : t list;
@@ -64,25 +63,6 @@ let inc_path ctx path =
 		| (pack,name) ->
 		pre ^ (slashes (List.length (fst ctx.path))) ^ String.concat "/" pack ^ "/" ^ name ^ ".php"
 
-(*
-let rec register_required_path ctx path = match path with
-	| [], "Float"
-	| [], "Int"
-	| [], "Array"
-	| [], "Void"
-	| [], "Class"
-	| [], "Enum"
-	| [], "Dynamic"
-	| ["php"], "PhpMath__"
-	| ["php"], "PhpDate__"
-	| ["php"], "PhpXml__"
-	| ["php"], "HException"
-	| [], "String"
-	| [], "Bool" -> ()
-	| _, _ -> if not (List.exists(fun p -> p = path) ctx.required_paths) then
-		ctx.required_paths <- path :: ctx.required_paths
-*)
-
 let s_expr_expr e =
 	match e.eexpr with
 	| TConst _ -> "TConst"
@@ -189,7 +169,7 @@ let rec is_string_type t =
 	   | _ -> false)
 	| _ -> false
 
-let is_string_expr e = is_string_type e.etype (* match follow e.etype with TInst ({ cl_path = [],"String" },_) -> true | _ -> false *)
+let is_string_expr e = is_string_type e.etype
 (*
 	let s = s_expr_name e in
 	if s = "#Null<String>" || s = "Null<String>" || s = "#String" || s = "String" then true else false
@@ -202,7 +182,6 @@ let s_path ctx path isextern p =
 	if isextern then 
 		snd path
 	else begin
-(*		register_required_path ctx path; *)
 		(match path with
 		| ([],"List")			-> "HList"
 		| ([],name)				-> name
@@ -288,7 +267,6 @@ let init com cwd path def_type =
 		locals = PMap.empty;
 		inv_locals = PMap.empty;
 		local_types = [];
-(*		required_paths = []; *)
 		inits = [];
 		get_sets = Hashtbl.create 0;
 		constructor_block = false;
@@ -326,19 +304,6 @@ let parent e =
 
 let close ctx =
 	output_string ctx.ch "<?php\n";
-(*
-	Hashtbl.iter (fun name paths ->
-		List.iter (fun pack ->
-			let path = pack, name in
-			register_required_path ctx path
-		) paths
-	) ctx.imports;
-*)
-(*
-	List.iter (fun path ->
-		if path <> ctx.path then output_string ctx.ch ("// require_once dirname(__FILE__).'/" ^ inc_path ctx path ^ "';\n");
-	) (List.rev ctx.required_paths);
-*)
 	output_string ctx.ch "\n";
 	output_string ctx.ch (Buffer.contents ctx.buf);
 	close_out ctx.ch
@@ -414,17 +379,6 @@ let gen_constant ctx p = function
 	| TSuper -> spr ctx "ERROR /* unexpected call to super in gen_constant */"
 	
 let s_funarg ctx arg t p c = 
-(*
-	let arg_default p c =
-		match c with
-		| None | Some TNull -> e
-		| Some c -> Codegen.concat (Codegen.set_default ctx.com arg c t p) e in
-		(*
-		match c with
-		| None -> ()
-		| Some c -> 
-			spr ctx " = ";
-			gen_constant ctx p c in*) *)
 	let byref = if is_array_type t || (String.length arg > 7 && String.sub arg 0 7 = "byref__") then "&" else "" in
 	(match t with
 	| TInst (cl,_) -> 
@@ -437,24 +391,14 @@ let s_funarg ctx arg t p c =
 		| ([], "Class") 
 		| ([], "Bool") -> 
 			print ctx "%s%s$%s" byref (escphp ctx.quotes) arg;
-			
-(*			arg_default p c *)
-			
-(*			if o then spr ctx " = null" *)
 		| _ ->
 			if cl.cl_kind = KNormal && not cl.cl_extern then
 				print ctx "/*%s*/ %s%s$%s" (s_path ctx cl.cl_path cl.cl_extern p) byref (escphp ctx.quotes) arg
-				(* was: print ctx "%s %s%s$%s = null" (s_path ctx c.cl_path c.cl_extern p) byref (escphp ctx.quotes) arg *)
 			else begin
 				print ctx "%s%s$%s" byref (escphp ctx.quotes) arg;
-
-(*				arg_default p c *)
-				
-(*				if o then spr ctx " = null" *)
 			end)
 	| _ -> 
 		print ctx "%s%s$%s" byref (escphp ctx.quotes) arg;
-(*		arg_default p c *)
 	)
 
 let is_in_dynamic_methods ctx e s =
@@ -478,10 +422,6 @@ let fun_block ctx f p =
 		| None | Some TNull -> e
 		| Some c -> Codegen.concat (Codegen.set_default ctx.com a c t p) e
 	) e f.tf_args in
-	(*
-	if ctx.com.debug then
-		Codegen.stack_block ctx.stack ctx.current (fst ctx.curmethod) e
-	else *)
 		mk_block e
 
 let gen_function_header ctx name f params p =
@@ -596,7 +536,7 @@ let rec gen_call ctx e el =
 		
 and gen_call_value ctx e =
 	match e.eexpr with
-	| TConst TNull -> spr ctx "php_Boot::__array_null()";
+	| TConst TNull -> spr ctx "php_Boot::__null()";
 	| _ -> gen_value ctx e
 	
 and gen_call_ref ctx e =
@@ -711,10 +651,9 @@ and could_be_array_call s =
 	s = "copy" || s = "unshift" || s = "insert" || s = "remove" || s = "iterator"
 
 and gen_uncertain_string_or_array_call ctx s e el =
-(* only toString so far *)
 	spr ctx "php_Boot::__string_rec(";
 	gen_value ctx e;
-	print ctx ")"
+	print ctx ", null)"
 	
 and gen_uncertain_string_call ctx s e el =
 	let p = escphp ctx.quotes in
@@ -851,10 +790,6 @@ and gen_member_access ctx isvar e s =
 		| _ -> print ctx "->%s" (s_ident s))
 	| _ -> print ctx "->%s" (s_ident s)
 	
-(*
-let isunc = is_uncertain_expr e1 in
-if isunc then print ctx "/* %s */" (s_type_name (follow e1.etype));
-*)
 and gen_field_access ctx isvar e s =
 	match e.eexpr with
 	| TTypeExpr t ->
@@ -897,9 +832,6 @@ and gen_dynamic_function ctx isstatic name f params p =
 		s_funarg ctx arg t p o;
 		) f.tf_args;
 	spr ctx ") {";
-	
-	(* TODO: check me *)
-(*	gen_expr ctx (fun_block ctx f e.epos); *)
 
 	if (List.length f.tf_args) > 0 then begin
 		if isstatic then
@@ -940,13 +872,7 @@ and gen_function ctx name f params p =
 		s_funarg ctx arg t p o;
 	) f.tf_args;
 	print ctx ") ";
-	
-	
-	(* TODO: check me *)
 	gen_expr ctx (fun_block ctx f p);
-	
-	
-(*	gen_expr ctx (mk_block f.tf_expr); *)
 	ctx.in_value <- old;
 	ctx.locals <- old_l;
 	ctx.inv_locals <- old_li;
@@ -969,15 +895,7 @@ and gen_inline_function ctx f params p =
 		incr c;
 		print ctx "%s\"%s%s\" => &%s$%s" pq n pq pq n;
 	) old_li;
-	(*
-	PMap.iter (fun n _ ->
-		if not (PMap.exists n old_l) then begin
-		if !c > 0 then spr ctx ", ";
-		incr c;
-		print ctx "%s\"%s%s\" => &%s$%s" pq n pq pq n;
-		end
-	) old_li;
-*)
+	
 	print ctx "), %s\"" pq;
 	ctx.quotes <- ctx.quotes + 1;
 	concat ctx "," (fun (arg,o,t) ->
@@ -987,9 +905,7 @@ and gen_inline_function ctx f params p =
 	ctx.quotes <- ctx.quotes - 1;
 	print ctx "%s\", %s\"" pq pq;
 	ctx.quotes <- ctx.quotes + 1;
-	(* TODO: check me *)
 	gen_expr ctx (fun_block ctx f p);
-(*	gen_expr ctx (mk_block f.tf_expr); *)
 	ctx.quotes <- ctx.quotes - 1;
 	print ctx "%s\")" pq;
 	ctx.in_value <- old;
@@ -1028,7 +944,6 @@ and gen_expr ctx e =
 	| TLocal s ->
 		spr ctx ((escphp ctx.quotes) ^ "$" ^ (try PMap.find s ctx.locals with Not_found -> error ("Unknown local " ^ s) e.epos))
 	| TEnumField (en,s) ->
-(*		register_required_path ctx en.e_path; *)
 		(match (try PMap.find s en.e_constrs with Not_found -> error ("Unknown local " ^ s) e.epos).ef_type with
 		| TFun (args,_) -> print ctx "%s::%s" (s_path ctx en.e_path en.e_extern e.epos) (s_ident s)
 		| _ -> print ctx "%s::%s$%s" (s_path ctx en.e_path en.e_extern e.epos) (escphp ctx.quotes) (s_ident s))
@@ -1121,7 +1036,6 @@ and gen_expr ctx e =
 			then begin	
 				(match e1.eexpr with 
 				| TField (f, s) when is_anonym_expr e1 || is_unknown_expr e1 ->
-(*					register_required_path ctx ([], "Reflect"); *)
 					spr ctx "Reflect::field(";
 					gen_value ctx f;
 					print ctx ", \"%s\")" s;
@@ -1132,7 +1046,6 @@ and gen_expr ctx e =
 				
 				(match e2.eexpr with 
 				| TField (f, s) when is_anonym_expr e2 || is_unknown_expr e2 ->
-(*					register_required_path ctx ([], "Reflect"); *)
 					spr ctx "Reflect::field(";
 					gen_value ctx f;
 					print ctx ", \"%s\")" s;
@@ -1227,7 +1140,6 @@ and gen_expr ctx e =
 
 	| TTypeExpr t ->
 		let p = escphp ctx.quotes in
-(*		register_required_path ctx (t_path t); *)
 		print ctx "php_Boot::__qtype(%s\"%s%s\")" p (s_path_haxe (t_path t)) p
 	| TParenthesis e ->
 		spr ctx "(";
@@ -1290,12 +1202,7 @@ and gen_expr ctx e =
 					let old = ctx.in_value in
 					ctx.in_value <- Some name;
 					ctx.quotes <- ctx.quotes + 1;
-					
-					(* TODO: check me *)
 					gen_expr ctx (fun_block ctx fd e.epos);
-					
-					
-(*					gen_expr ctx (mk_block fd.tf_expr); *)
 					ctx.quotes <- ctx.quotes - 1;
 					ctx.in_value <- old;
 					print ctx "\")";
@@ -1346,7 +1253,6 @@ and gen_expr ctx e =
 	| TThrow e ->
 		spr ctx "throw new HException(";
 		gen_value ctx e;
-(* TODO: add POS here *)
 		spr ctx ")";
 	| TVars [] ->
 		()
@@ -1372,7 +1278,21 @@ and gen_expr ctx e =
 			spr ctx ")"
 		| (_, _), _ ->
 			print ctx "new %s(" (s_path ctx c.cl_path c.cl_extern e.epos);
-			concat ctx ", " (gen_value ctx) el;
+			let count = ref (-1) in
+			concat ctx ", " (fun e -> 
+				incr count;
+				match c.cl_constructor with
+				| Some f ->
+					(match follow f.cf_type with
+					| TFun (al, _) ->
+						let _, _, t = List.nth al !count in
+						if (try is_array_type t with Failure _ -> false) then 
+							gen_call_value ctx e
+						else 
+							gen_value ctx e;
+					| _ -> ())
+				| _ -> ();
+			) el;
 			spr ctx ")")
 	| TIf (cond,e,eelse) ->
 		spr ctx "if";
@@ -1595,7 +1515,6 @@ and gen_value ctx e =
 	| TFor _
 	| TWhile _
 	| TThrow _ ->
-		(* value is discarded anyway *)
 		let v = value true in
 		gen_expr ctx e;
 		v()
@@ -1671,8 +1590,6 @@ let generate_field ctx static f =
 	ctx.in_static <- static;
 	ctx.locals <- PMap.empty;
 	ctx.inv_locals <- PMap.empty;
-(*	let public = f.cf_public || Hashtbl.mem ctx.get_sets (f.cf_name,static) || (f.cf_name = "main" && static) || f.cf_name = "__resolve" in
-	let rights = (if public then "public" else "/*protected*/ public") ^ (if static then " static" else "") in *)
 	let rights = if static then "static" else "public" in 
 	let p = ctx.curclass.cl_pos in
 	match f.cf_expr with
@@ -1691,8 +1608,6 @@ let generate_field ctx static f =
 			| TFun (args,r) ->
 				print ctx "function %s(" f.cf_name;
 				concat ctx ", " (fun (arg,o,t) ->
-				(*	spr ctx arg;
-					if o then spr ctx " = null"; *)
 					s_funarg ctx arg t p o; 
 				) args;
 				print ctx ")";
@@ -1777,8 +1692,6 @@ let generate_class ctx all_dynamic_methods c =
 	List.iter (define_getset ctx true) c.cl_ordered_statics;
 	ctx.local_types <- List.map snd c.cl_types;
 
-(*	register_required_path ctx (["php"], "Boot"); *)
-
 	print ctx "%s %s " (if c.cl_interface then "interface" else "class") (s_path ctx c.cl_path c.cl_extern c.cl_pos);
 	(match c.cl_super with
 	| None -> ()
@@ -1885,8 +1798,6 @@ let generate_enum ctx e =
 	let pack = open_block ctx in
 	let ename = s_path ctx e.e_path e.e_extern e.e_pos in
 
-(*	register_required_path ctx (["php"], "Boot"); *)
-
 	print ctx "class %s extends enum {" ename;
 	let cl = open_block ctx in
 	PMap.iter (fun _ c ->
@@ -1950,11 +1861,6 @@ let generate com =
 			else (match c.cl_path with
 			| [], "@Main" ->
 				createmain com c;
-				(*
-				let ctx = init dir "" ([], "index") 0 in
-				generate_main ctx c;
-				close ctx;
-				*)
 			| _ ->
 				let ctx = init com "lib" c.cl_path (if c.cl_interface then 2 else 0) in
 				(*let cp = s_path ctx c.cl_path c.cl_extern c.cl_pos in*)
@@ -1964,15 +1870,6 @@ let generate com =
 				| Some e ->
 					newline ctx;
 					gen_expr ctx e);
-				(*
-				if c.cl_interface then begin
-					newline ctx;
-					print ctx "// php_Boot::__register_type(new __interfacetype__(\"%s\", \"%s\"))" cp (s_path_haxe c.cl_path);
-				end else begin
-					newline ctx;
-					print ctx "// php_Boot::__register_type(new __classtype__(\"%s\", \"%s\"))" cp (s_path_haxe c.cl_path);
-				end;
-				*)
 				List.iter (generate_static_field_assign ctx c.cl_path) c.cl_ordered_statics;
 				newline ctx;
 				close ctx);
@@ -1982,10 +1879,6 @@ let generate com =
 			else
 				let ctx = init com "lib" e.e_path 1 in
 			generate_enum ctx e;
-(*
-			print ctx "// php_Boot::__register_type(new __enumtype__(\"%s\", \"%s\"))" (s_path ctx e.e_path false e.e_pos) (s_path_haxe e.e_path);
-			newline ctx;
-*)
 			close ctx
 		| TTypeDecl t ->
 			());

+ 65 - 65
std/php/Boot.hx

@@ -5,7 +5,7 @@ class Boot {
 		var msg = if( i != null ) i.fileName+":"+i.lineNumber+": " else "";
 		untyped __call__("echo", msg+ __string_rec(v)+"<br/>"); // TODO: __unhtml
 	}
-	
+
 	static public function __anonymous(?p : Dynamic) : Dynamic {
 		untyped __php__("$o = new Anonymous();
 		if(is_array($p)) {
@@ -15,7 +15,7 @@ class Boot {
 		}
 		return $o");
 	}
-	
+
 	static private var __cid = 0;
 	static public var __scopes = [];
 	static public function __closure(locals : ArrayAccess<Dynamic>, params : String, body : String) : String {
@@ -24,38 +24,38 @@ class Boot {
 //		if(locals == null) locals = [];
 		untyped __php__("php_Boot::$__scopes[$n] = array('scope' => null, 'locals' => $locals)");
 		var f : String = untyped __call__(
-			"create_function", 
-			params, 
+			"create_function",
+			params,
 			"$__this =& php_Boot::$__scopes['"+n+"']['scope'];\nforeach(array_keys(php_Boot::$__scopes['"+n+"']['locals']) as ${'%k'}) ${${'%k'}} =& php_Boot::$__scopes['"+n+"']['locals'][${'%k'}];\n"+body);
 		var nl = "__"+f.substr(1)+"__";
 		untyped __php__("php_Boot::$__scopes[$nl] =& php_Boot::$__scopes[$n]");
 		return f;
 	}
-	
+
 	static public function __is_lambda(s : String) : Bool {
 		return untyped __call__("is_string", s) && s.substr(0, 8) == __call__("chr", 0) + "lambda_";
 	}
-	
+
 	static public function __array() : Dynamic {
 		return untyped __call__("func_get_args");
 	}
-	
+
 	static public function __array_empty() : Dynamic {
 		return untyped __call__("array");
 	}
-	
-	static public function __array_null() : Dynamic {
+
+	static public function __null() : Dynamic {
 		return null;
 	}
-	
+
 	static public function __array_copy(a : ArrayAccess<Dynamic>) : Dynamic {
 		return cast a;
 	}
-	
+
 	static public function __array_iterator<T>(arr : Dynamic) : Iterator<T> {
 		return untyped __php__("new HArrayIterator($arr)");
 	}
-	
+
 	static public function __array_sort<T>(arr : Array<T>, f : T -> T -> Int) : Void {
 		var i = 0;
 		var l = arr.length;
@@ -74,13 +74,13 @@ class Boot {
 			}
 			if(!swap) break;
 			i += 1;
-		}	
+		}
 	}
 
 	static public function __array_insert<T>(arr : Array<T>,  pos : Int, x : T) : Void {
 		untyped __php__("array_splice")(arr, pos, 0, __call__("array", x));
 	}
-	
+
 	static public function __array_remove<T>(arr : Array<T>, x : T) : Bool {
 		for(i in 0...arr.length)
 			if(arr[i] == x) {
@@ -90,42 +90,42 @@ class Boot {
 			}
 		return false;
 	}
-	
+
 	static public function __array_remove_at(arr : Array<Dynamic>, pos : Int) : Bool {
 		if(untyped __php__("array_key_exists")(pos, arr)) {
 			untyped __php__("unset")(arr[pos]);
 			return true;
 		} else return false;
 	}
-	
+
 	static public function __array_splice(arr : Array<Dynamic>, pos : Int, len : Int) : Bool {
 		if(len < 0) len = 0;
 		return untyped __php__("array_splice")(arr, pos, len);
 	}
-	
+
 	static public function __array_slice(arr : Array<Dynamic>, pos : Int, ?end : Int) : Bool {
 		if(end == null)
 			return untyped __php__("array_slice")(arr, pos);
 		else
 			return untyped __php__("array_slice")(arr, pos, end-pos);
 	}
-  
+
 	static public function __array_set<T>(arr : Array<Dynamic>, pos : Int, v : T) : T untyped {
 		if(__call__("is_int", pos)) {
 			var l = __call__("count", arr);
 			if(l < pos) {
-			__call__("array_splice", arr, l, 0, __call__("array_fill", l, pos-l, null)); 
+			__call__("array_splice", arr, l, 0, __call__("array_fill", l, pos-l, null));
 			}
 		}
 		__php__("$arr[$pos] = $v");
 		return v;
 	}
-	
+
 	static public function __char_code_at(s : String, pos : Int) : Null<Int> untyped {
 		if(__call__("empty", s) || pos >= s.length) return null;
 		return s.cca(pos);
 	}
-	
+
 	static public function __substr(s : String, pos : Int, ?len : Int) {
 		if( pos != null && pos != 0 && len != null && len < 0 ) return '';
 		if( len == null ) len = s.length;
@@ -145,15 +145,15 @@ class Boot {
 		else
 			return x;
 	}
-	
+
 	static public function __last_index_of(s : String, value : String, ?startIndex : Int) {
 		var x = untyped __php__("strrpos")(s, value, startIndex == null ? null : s.length - startIndex);
-		if(untyped __php__("$x === false")) 
+		if(untyped __php__("$x === false"))
 			return -1
 		else
 			return x;
 	}
-	
+
 	static public function __instanceof(v : Dynamic, t : Dynamic) {
 		if(t == null) return false;
 		switch(t.__tname__) {
@@ -177,10 +177,10 @@ class Boot {
 				return untyped __call__("is_a", v, t.__tname__);
 		}
 	}
-	
+
 	static public function __shift_right(v : Int, n : Int) {
-		untyped __php__("$z = 0x80000000;  
-		if ($z & $v) { 
+		untyped __php__("$z = 0x80000000;
+		if ($z & $v) {
 			$v = ($v>>1);
 			$v &= (~$z);
 			$v |= 0x40000000;
@@ -188,7 +188,7 @@ class Boot {
 		} else $v = ($v>>$n)");
 		return v;
 	}
-	
+
 	static public function __error_handler(errno : Int, errmsg : String, filename : String, linenum : Int, vars : Dynamic) {
 		var msg = errmsg + " (errno: " + errno + ") in " + filename + " at line #" + linenum;
 		var e = new php.HException(msg, errmsg, errno);
@@ -197,12 +197,12 @@ class Boot {
 		untyped __php__("throw $e");
 		return null;
 	}
-	
+
 	static public function __exception_handler(e : Dynamic) {
 		var msg = "<pre>Uncaught exception: <b>"+e.getMessage()+"</b>\nin file: <b>"+e.getFile()+"</b> line <b>"+e.getLine()+"</b>\n\n"+e.getTraceAsString()+"</pre>";
 		untyped __php__("die($msg)");
 	}
-  
+
 	static public function __equal(x : Dynamic, y : Dynamic) untyped {
 		if(__call__("is_null", x)) {
 			return __call__("is_null", y);
@@ -229,21 +229,21 @@ class Boot {
 	static public function __qtype(n) untyped {
 		if(__call__("isset", __qtypes[n]))
 			return __qtypes[n];
-		else 
+		else
 			return null;
 	}
 
 	static public function __ttype(n) untyped {
 		if(__call__("isset", __ttypes[n]))
 			return __ttypes[n];
-		else 
+		else
 			return null;
 	}
-	
+
 	static public function __deref(byref__o : Dynamic) {
 		return byref__o;
 	}
-	
+
 	static public function __byref__array_get(byref__o : Dynamic, index : Dynamic) {
 		return untyped byref__o[index];
 	}
@@ -274,7 +274,7 @@ class Boot {
 			default: throw "Invalid Operation: " + method;
 		}
 	}
-	
+
 	public static function __array_call(arr : Array<Dynamic>, method : String, params : ArrayAccess<Dynamic>) {
 		if(!untyped __call__("is_array", arr)) return untyped __php__("call_user_func_array(array($arr, $method), $params)");
 		switch(method) {
@@ -295,13 +295,13 @@ class Boot {
 			default: throw "Invalid Operation: " + method;
 		}
 	}
-	
+
 	public static function __len(o : Dynamic) {
 		return untyped __php__("is_array($o) ? count($o) : (is_string($o) ? strlen($o) : $o->length)");
 	}
-	
+
 //	public static var __REGISTERED_CLASSES : Array<Dynamic>;
-  
+
 	static function __init__() untyped {
 		__php__("//error_reporting(0);
 set_error_handler(array('php_Boot', '__error_handler'), E_ALL);
@@ -320,26 +320,26 @@ class Anonymous extends stdClass{
 			throw new HException('Unable to call «'.$m.'»');
 		}
 	}
-	
+
 	public function __set($n, $v) {
 		$this->$n = $v;
 	}
-	
+
 	public function &__get($n) {
 		if(isset($this->$n))
 			return $this->$n;
 		$null = null;
 		return $null;
 	}
-	
+
 	public function __isset($n) {
 		return isset($this->$n);
 	}
-	
+
 	public function __unset($n) {
 		unset($this->$n);
 	}
-	
+
 	public function __toString() {
 		return php_Boot::__string_rec($this, null);
 	}
@@ -347,16 +347,16 @@ class Anonymous extends stdClass{
 
 class __type__ {
 	public $__tname__;
-	public $__qname__;  
-	public $__path__;  
+	public $__qname__;
+	public $__path__;
 	public function __construct($cn, $qn, $path = null) {
 		$this->__tname__ = $cn;
 		$this->__qname__ = $qn;
 		$this->__path__ = $path;
 	}
-	
+
 	public function toString()   { return $this->__toString(); }
-	
+
 	public function __toString() {
 		return $this->__qname__;
 	}
@@ -370,7 +370,7 @@ class __type__ {
 			$this->rfl = null;
 		return $this->rfl;
 	}
-	
+
 	public function __call($n, $a) {
 		return call_user_func_array(array($this->__tname__, $n), $a);
 	}
@@ -409,12 +409,12 @@ class HArrayIterator {
 		$this->a = $a;
 		$this->i = 0;
 	}
-	
+
 	public function next() {
 		if(!$this->hasNext()) return null;
 		return $this->a[$this->i++];
 	}
-	
+
 	public function hasNext() {
 		return $this->i < count($this->a);
 	}
@@ -482,7 +482,7 @@ if(!file_exists($_autload_cache_file)) {
 				} else if(substr($bn, -10) == '.interface') {
 					$bn = substr($bn, 0, -10);
 					$t = 2;
-				} else 
+				} else
 					continue;
 				$qname = ($bn == 'HList' && empty($pack)) ? 'List' : join(array_merge($pack, array($bn)), '.');
 				$a[] = array(
@@ -497,11 +497,11 @@ if(!file_exists($_autload_cache_file)) {
 		}
 		closedir($h);
 	}
-	
+
 	$a = array();
-	
+
 	buildPaths($_lib_dir, $a, array());
-	
+
 	$content = '<?php\n\n';
 	for($i=0;$i<count($a);$i++) {
 		$content .= 'php_Boot::__register_type(new ';
@@ -536,7 +536,7 @@ spl_autoload_register('__haxe_autoload')");
 
 	static public function __string(o : Dynamic) {
 		if( o == null )
-			return "null";		
+			return "null";
 		if(untyped __call__("is_int", o) || __call__("is_float", o))
 			return o;
 		if(untyped __call__("is_bool", o))
@@ -554,7 +554,7 @@ spl_autoload_register('__haxe_autoload')");
 					return "[" + __ttype(c) + "]";
 			}
 		}
-		
+
 		if(untyped __call__("is_string", o)) {
 			if(__is_lambda(o)) return "«function»";
 			return o;
@@ -563,22 +563,22 @@ spl_autoload_register('__haxe_autoload')");
 			if(untyped __call__("is_callable", o)) return "«function»";
 			return "Array";
 		}
-		
+
 		return '';
 	}
-	
+
 	static public function __string_rec(o : Dynamic, ?s : String) {
 		if( o == null )
 			return "null";
 		if( s.length >= 5 )
 			return "<...>"; // too much deep recursion
-		
+
 		if(untyped __call__("is_int", o) || __call__("is_float", o))
 			return o;
-			
+
 		if(untyped __call__("is_bool", o))
 			return o ? "true" : "false";
-			
+
 		if(untyped __call__("is_object", o)) {
 			var c = untyped __call__("get_class", o);
 			if(untyped __php__("$o instanceof enum")) {
@@ -587,7 +587,7 @@ spl_autoload_register('__haxe_autoload')");
 					s += "\t";
 					b += '(';
 					for( i in 0...untyped __call__("count", o.params) ) {
-						if(i > 0) 
+						if(i > 0)
 							b += ', ' + __string_rec(o.params[i],s);
 						else
 							b += __string_rec(o.params[i],s);
@@ -620,7 +620,7 @@ spl_autoload_register('__haxe_autoload')");
 					return "[" + __ttype(c) + "]";
 			}
 		}
-			
+
 		if(untyped __call__("is_string", o)) {
 			if(__is_lambda(o)) return "«function»";
 			if(s != null)
@@ -628,7 +628,7 @@ spl_autoload_register('__haxe_autoload')");
 			else
 				return o;
 		}
-			
+
 		if(untyped __call__("is_array", o)) {
 			if(untyped __call__("is_callable", o)) return "«function»";
 			var str = "[";
@@ -638,7 +638,7 @@ spl_autoload_register('__haxe_autoload')");
 			str += "]";
 			return str;
 		}
-		
+
 		return '';
 	}
 	static public var skip_constructor = false;