2
0
Эх сурвалжийг харах

all static functions from php.Boot have been moved to global functions

Franco Ponticelli 17 жил өмнө
parent
commit
7d0174f38c
6 өөрчлөгдсөн 195 нэмэгдсэн , 206 устгасан
  1. 8 8
      genphp.ml
  2. 1 0
      main.ml
  3. 1 1
      std/Std.hx
  4. 12 12
      std/Type.hx
  5. 169 181
      std/php/Boot.hx
  6. 4 4
      std/php/Lib.hx

+ 8 - 8
genphp.ml

@@ -668,13 +668,13 @@ and could_be_array_call s =
 	s = "copy" || s = "unshift" || s = "insert" || s = "remove" || s = "iterator"
 	s = "copy" || s = "unshift" || s = "insert" || s = "remove" || s = "iterator"
 
 
 and gen_uncertain_string_or_array_call ctx s e el =
 and gen_uncertain_string_or_array_call ctx s e el =
-	spr ctx "php_Boot::__string_rec(";
+	spr ctx "_hx_string_rec(";
 	gen_value ctx e;
 	gen_value ctx e;
 	print ctx ", null)"
 	print ctx ", null)"
 
 
 and gen_uncertain_string_call ctx s e el =
 and gen_uncertain_string_call ctx s e el =
 	let p = escphp ctx.quotes in
 	let p = escphp ctx.quotes in
-	spr ctx "php_Boot::__string_call(";
+	spr ctx "_hx_string_call(";
 	gen_value ctx e;
 	gen_value ctx e;
 	print ctx ", %s\"%s%s\", array(" p s p;
 	print ctx ", %s\"%s%s\", array(" p s p;
 	concat ctx ", " (gen_value ctx) el;
 	concat ctx ", " (gen_value ctx) el;
@@ -682,7 +682,7 @@ and gen_uncertain_string_call ctx s e el =
 
 
 and gen_uncertain_array_call ctx s e el =
 and gen_uncertain_array_call ctx s e el =
 	let p = escphp ctx.quotes in
 	let p = escphp ctx.quotes in
-	spr ctx "php_Boot::__array_call(";
+	spr ctx "_hx_array_call(";
 	gen_value ctx e;
 	gen_value ctx e;
 	print ctx ", %s\"%s%s\", array(" p s p;
 	print ctx ", %s\"%s%s\", array(" p s p;
 	concat ctx ", " (gen_value ctx) el;
 	concat ctx ", " (gen_value ctx) el;
@@ -816,7 +816,7 @@ and gen_field_access ctx isvar e s =
 		gen_expr ctx e;
 		gen_expr ctx e;
 		print ctx "->%s" (s_ident s)
 		print ctx "->%s" (s_ident s)
 	| TArray (e1,e2) ->
 	| TArray (e1,e2) ->
-		spr ctx "php_Boot::__byref__array_get(";
+		spr ctx "_hx_array_get_ref(";
 		gen_value ctx e1;
 		gen_value ctx e1;
 		spr ctx ", ";
 		spr ctx ", ";
 		gen_value ctx e2;
 		gen_value ctx e2;
@@ -825,7 +825,7 @@ and gen_field_access ctx isvar e s =
 	| TBlock _
 	| TBlock _
 	| TParenthesis _
 	| TParenthesis _
 	| TNew _ ->
 	| TNew _ ->
-		spr ctx "php_Boot::__deref(";
+		spr ctx "_hx_deref(";
 		ctx.is_call <- true;
 		ctx.is_call <- true;
 		gen_value ctx e;
 		gen_value ctx e;
 		ctx.is_call <- false;
 		ctx.is_call <- false;
@@ -965,7 +965,7 @@ and gen_expr ctx e =
 		| _ -> print ctx "%s::%s$%s" (s_path ctx en.e_path en.e_extern e.epos) (escphp ctx.quotes) (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))
 	| TArray (e1,e2) ->
 	| TArray (e1,e2) ->
 		(*
 		(*
-		spr ctx "php_Boot::__byref__array_get(";
+		spr ctx "_hx_array_get_ref(";
 		gen_value ctx e1;
 		gen_value ctx e1;
 		spr ctx ", ";
 		spr ctx ", ";
 		gen_value ctx e2;
 		gen_value ctx e2;
@@ -973,7 +973,7 @@ and gen_expr ctx e =
 		*)
 		*)
 		(match e1.eexpr with
 		(match e1.eexpr with
 		| TCall _ ->
 		| TCall _ ->
-			spr ctx "php_Boot::__byref__array_get(";
+			spr ctx "_hx_array_get_ref(";
 			gen_value ctx e1;
 			gen_value ctx e1;
 			spr ctx ", ";
 			spr ctx ", ";
 			gen_value ctx e2;
 			gen_value ctx e2;
@@ -1157,7 +1157,7 @@ and gen_expr ctx e =
 
 
 	| TTypeExpr t ->
 	| TTypeExpr t ->
 		let p = escphp ctx.quotes in
 		let p = escphp ctx.quotes in
-		print ctx "php_Boot::__qtype(%s\"%s%s\")" p (s_path_haxe (t_path t)) p
+		print ctx "_hx_qtype(%s\"%s%s\")" p (s_path_haxe (t_path t)) p
 	| TParenthesis e ->
 	| TParenthesis e ->
 		spr ctx "(";
 		spr ctx "(";
 		gen_value ctx e;
 		gen_value ctx e;

+ 1 - 0
main.ml

@@ -260,6 +260,7 @@ try
 		),"<file> : add the SWF library to the compiled SWF");
 		),"<file> : add the SWF library to the compiled SWF");
 		("-neko",Arg.String (set_platform Neko "neko"),"<file> : compile code to Neko Binary");
 		("-neko",Arg.String (set_platform Neko "neko"),"<file> : compile code to Neko Binary");
 		("-php",Arg.String (fun dir ->
 		("-php",Arg.String (fun dir ->
+			classes := (["php"],"Boot") :: !classes;
 			classes := (["php"],"PhpXml__") :: !classes;
 			classes := (["php"],"PhpXml__") :: !classes;
 			classes := (["php"],"PhpDate__") :: !classes;
 			classes := (["php"],"PhpDate__") :: !classes;
 			classes := (["php"],"PhpMath__") :: !classes;
 			classes := (["php"],"PhpMath__") :: !classes;

+ 1 - 1
std/Std.hx

@@ -58,7 +58,7 @@ class Std {
 		#elseif js
 		#elseif js
 		js.Boot.__string_rec(s,"");
 		js.Boot.__string_rec(s,"");
 		#elseif php
 		#elseif php
-		php.Boot.__string_rec(s, '');
+		__call__("_hx_string_rec", s, '');
 		#else
 		#else
 		"";
 		"";
 		#end
 		#end

+ 12 - 12
std/Type.hx

@@ -55,17 +55,17 @@ class Type {
 			if(o == null) return null;
 			if(o == null) return null;
 			untyped if(__call__("is_array",  o)) {
 			untyped if(__call__("is_array",  o)) {
 				if(__call__("count", o) == 2 && __call__("is_callable", o)) return null;
 				if(__call__("count", o) == 2 && __call__("is_callable", o)) return null;
-				return __php__("php_Boot::__ttype('Array')");
+				return __call__("_hx_ttype", 'Array');
 			}
 			}
 			if(untyped __call__("is_string", o)) {
 			if(untyped __call__("is_string", o)) {
 				if(__call__("_hx_is_lambda", untyped o)) return null;
 				if(__call__("_hx_is_lambda", untyped o)) return null;
-				return __php__("php_Boot::__ttype('String')");
+				return __call__("_hx_ttype", 'String');
 			}
 			}
-			var c = __php__("get_class")(o);
+			var c = __call__("get_class", o);
 			if(c == false || c == '_hx_anonymous' || __call__("is_subclass_of", c, "enum"))
 			if(c == false || c == '_hx_anonymous' || __call__("is_subclass_of", c, "enum"))
 				return null;
 				return null;
 			else
 			else
-				return __php__("php_Boot::__ttype($c)");
+				return __call__("_hx_ttype", c);
 		#else
 		#else
 			return null;
 			return null;
 		#end
 		#end
@@ -100,7 +100,7 @@ class Type {
 			if(!__php__("$o instanceof Enum"))
 			if(!__php__("$o instanceof Enum"))
 				return null;
 				return null;
 			else
 			else
-				return __php__("php_Boot::__ttype(get_class($o))");
+				return __php__("_hx_ttype(get_class($o))");
 		#else
 		#else
 			return null;
 			return null;
 		#end
 		#end
@@ -121,7 +121,7 @@ class Type {
 			if(s == false)
 			if(s == false)
 				return null;
 				return null;
 			else
 			else
-				return __php__("php_Boot::__ttype($s)");
+				return __call__("_hx_ttype", s);
 		#else
 		#else
 			return c.__super__;
 			return c.__super__;
 		#end
 		#end
@@ -172,7 +172,7 @@ class Type {
 	public static function resolveClass( name : String ) : Class<Dynamic> untyped {
 	public static function resolveClass( name : String ) : Class<Dynamic> untyped {
 		#if php
 		#if php
 //			php.Boot.__require_once(StringTools.replace(name, '.', '/'));
 //			php.Boot.__require_once(StringTools.replace(name, '.', '/'));
-			var c = untyped __php__("php_Boot::__qtype($name)");
+			var c = untyped __call__("_hx_qtype", name);
 			if(__php__("$c instanceof _hx_class"))
 			if(__php__("$c instanceof _hx_class"))
 				return c;
 				return c;
 			else
 			else
@@ -225,7 +225,7 @@ class Type {
 	**/
 	**/
 	public static function resolveEnum( name : String ) : Enum untyped {
 	public static function resolveEnum( name : String ) : Enum untyped {
 		#if php
 		#if php
-			var e = untyped __php__("php_Boot::__qtype($name)");
+			var e = untyped __call__("_hx_qtype", name);
 			if(untyped __php__("$e instanceof _hx_enum"))
 			if(untyped __php__("$e instanceof _hx_enum"))
 				return e;
 				return e;
 			else
 			else
@@ -338,7 +338,7 @@ class Type {
 			if(cl.__qname__ == 'Array') return [];
 			if(cl.__qname__ == 'Array') return [];
 			if(cl.__qname__ == 'String') return '';
 			if(cl.__qname__ == 'String') return '';
 			try {
 			try {
-				php.Boot.skip_constructor = true;
+				__php__("php_Boot::$skip_constructor = true");
 				var rfl = cl.__rfl__();
 				var rfl = cl.__rfl__();
 				if(rfl == null) return null;
 				if(rfl == null) return null;
 				var m = __php__("$rfl->getConstructor()");
 				var m = __php__("$rfl->getConstructor()");
@@ -350,10 +350,10 @@ class Type {
 				} else {
 				} else {
 					i = __php__("$rfl->newInstanceArgs(array())");
 					i = __php__("$rfl->newInstanceArgs(array())");
 				}
 				}
-				php.Boot.skip_constructor = false;
+				__php__("php_Boot::$skip_constructor = false");
 				return i;
 				return i;
 			} catch( e : Dynamic ) {
 			} catch( e : Dynamic ) {
-				php.Boot.skip_constructor = false;
+				__php__("php_Boot::$skip_constructor = false");
 				throw "Unable to instantiate " + Std.string(cl);
 				throw "Unable to instantiate " + Std.string(cl);
 			}
 			}
 			return null;
 			return null;
@@ -599,7 +599,7 @@ class Type {
 			if(__php__("$v instanceof _hx_enum"))  return TObject;
 			if(__php__("$v instanceof _hx_enum"))  return TObject;
 			if(__php__("$v instanceof _hx_class"))  return TObject;
 			if(__php__("$v instanceof _hx_class"))  return TObject;
 
 
-			var c = __php__("php_Boot::__ttype(get_class($v))");
+			var c = __php__("_hx_ttype(get_class($v))");
 
 
 			if(__php__("$c instanceof _hx_enum"))  return TEnum(cast c);
 			if(__php__("$c instanceof _hx_enum"))  return TEnum(cast c);
 			if(__php__("$c instanceof _hx_class")) return TClass(cast c);
 			if(__php__("$c instanceof _hx_class")) return TClass(cast c);

+ 169 - 181
std/php/Boot.hx

@@ -1,167 +1,27 @@
 package php;
 package php;
 
 
 class Boot {
 class Boot {
-	static private var __qtypes : Array<Dynamic>;
-	static private var __ttypes : Array<Dynamic>;
-	static private var __tpaths : Array<Dynamic>;
-	static public function __register_type(t : Dynamic) {
-		untyped __php__(
-		"php_Boot::$__qtypes[$t->__qname__] = $t;
-		php_Boot::$__ttypes[$t->__tname__] = $t;
-		if($t->__path__ !== null)
-			php_Boot::$__tpaths[$t->__tname__] = $t->__path__");
-	}
-
-	static public function __qtype(n) untyped {
-		if(__call__("isset", __qtypes[n]))
-			return __qtypes[n];
-		else
-			return null;
-	}
-
-	static public function __ttype(n) untyped {
-		if(__call__("isset", __ttypes[n]))
-			return __ttypes[n];
-		else
-			return null;
-	}
-
-	static public function __deref(byref__o : Dynamic) {
-		return byref__o;
-	}
-
-	static public function __byref__array_get(byref__o : Dynamic, index : Dynamic) {
-		var r = null;
-		untyped __php__("if(isset($byref__o[$index])) $r =& $byref__o[$index]");
-		return r;
-	}
-
-	static private var __resources = [];
-	static public function __res(n : String) : String untyped {
-		if(! __php__("isset(self::$__resources[$n])")) {
-			var file = __php__("dirname(__FILE__).'/../../res/'.$n");
-			if(!__call__("file_exists", file))
-				throw "Invalid Resource name: " + n;
-			__php__("self::$__resources[$n] = file_get_contents($file)");
-		}
-		return __php__("self::$__resources[$n]");
-	}
-
-	public static function __string_call(s : Dynamic, method : String, params : ArrayAccess<Dynamic>) {
-		if(!untyped __call__("is_string", s)) return untyped __php__("call_user_func_array(array($s, $method), $params)");
-		var s2 : String = s;
-		switch(method) {
-			case "toUpperCase": return untyped s2.toUpperCase();
-			case "toLowerCase": return untyped s2.toLowerCase();
-			case "charAt"     : return untyped s2.charAt(params[0]);
-			case "charCodeAt" : return untyped s2.charCodeAt(params[0]);
-			case "indexOf"    : return untyped s2.indexOf(params[0], params.length > 1 ? params[1] : null);
-			case "lastIndexOf": return untyped s2.lastIndexOf(params.length > 1 ? params[1] : null);
-			case "split"      : return untyped s2.split(params[0]);
-			case "substr"     : return untyped s2.substr(params[0], params.length > 1 ? params[1] : null);
-			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) {
-			case "concat"  : return untyped arr.concat(params[0]);
-			case "copy"    : return untyped arr.copy();
-			case "insert"  : return untyped arr.insert(params[0], params[1]);
-			case "iterator": return untyped arr.iterator();
-			case "join"    : return untyped arr.join(params[0]);
-			case "pop"     : return untyped arr.pop();
-			case "push"    : return untyped arr.push(params[0]);
-			case "remove"  : return untyped arr.remove(params[0]);
-			case "reverse" : return untyped arr.reverse();
-			case "shift"   : return untyped arr.shift();
-			case "slice"   : return untyped arr.slice(params[0], params.length > 1 ? params[1] : null);
-			case "sort"    : return untyped arr.sort(params[0]);
-			case "splice"  : return untyped arr.splice(params[0], params[1]);
-			case "unshift" : return untyped arr.unshift(params[0]);
-			default: throw "Invalid Operation: " + method;
-		}
-	}
-
-	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")) {
-				var b : String = o.tag;
-				if(!untyped __call__("empty", o.params)) {
-					s += "\t";
-					b += '(';
-					for( i in 0...untyped __call__("count", o.params) ) {
-						if(i > 0)
-							b += ', ' + __string_rec(o.params[i],s);
-						else
-							b += __string_rec(o.params[i],s);
-					}
-					b += ')';
-				}
-				return b;
-			} else if(untyped __php__("$o instanceof _hx_anonymous")) {
-				var rfl = untyped __php__("new ReflectionObject($o)");
-				var b = "{\n";
-				s += "\t";
-				var properties : Array<Dynamic> = rfl.getProperties();
-				for(prop in properties) {
-					var f : String = prop.getName();
-					if(b.length != 2)
-						b += ", \n";
-					b += s + f + " : " + __string_rec(prop.getValue(o), s);
-				}
-				s = s.substr(1);
-				b += "\n" + s + "}";
-				return b;
-			} else if(untyped __php__("$o instanceof _hx_type")) {
-				return untyped o.__qname__;
-			} else {
-				if(untyped __call__("is_callable", [o, "toString"]))
-					return untyped __php__("$o->toString()");
-				else if(untyped __call__("is_callable", [o, "__toString"]))
-					return o.__toString();
-				else
-					return "[" + __ttype(c) + "]";
-			}
-		}
-
-		if(untyped __call__("is_string", o)) {
-			if(untyped __call__("_hx_is_lambda", o)) return "«function»";
-			if(s.length > 0)
-				return '"'+untyped __call__("str_replace", '"', '\\"', o)+'"';
-			else
-				return o;
-		}
+	static var qtypes;
+	static var ttypes;
+	static var tpaths;
+	static var skip_constructor = false;
+	static function __init__() : Void {
+		untyped __php__("//error_reporting(0);
 
 
-		if(untyped __call__("is_array", o)) {
-			if(untyped __call__("is_callable", o)) return "«function»";
-			var str = "[";
-			s += "\t";
-			for( i in 0...untyped __call__("count", o) )
-				str += (if (i > 0) ", " else "")+__string_rec(untyped o[i],s);
-			str += "]";
-			return str;
-		}
+function _hx_register_type($t) {
+	php_Boot::$qtypes[$t->__qname__] = $t;
+	php_Boot::$ttypes[$t->__tname__] = $t;
+	if($t->__path__ !== null)
+		php_Boot::$tpaths[$t->__tname__] = $t->__path__;
+}
 
 
-		return '';
-	}
-	static public var skip_constructor = false;
+function _hx_qtype($n) {
+	return isset(php_Boot::$qtypes[$n]) ? php_Boot::$qtypes[$n] : null;
+}
 
 
-	static function __init__() untyped {
-		__php__("//error_reporting(0);
+function _hx_ttype($n) {
+	return isset(php_Boot::$ttypes[$n]) ? php_Boot::$ttypes[$n] : null;
+}
 
 
 function _hx_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
 function _hx_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
 	$msg = $errmsg . ' (errno: ' . $errno . ') in ' . $filename . ' at line #' . $linenum;
 	$msg = $errmsg . ' (errno: ' . $errno . ') in ' . $filename . ' at line #' . $linenum;
@@ -197,6 +57,61 @@ function _hx_instanceof($v, $t) {
 	}
 	}
 }
 }
 
 
+function _hx_deref(&$o) {
+	return $o;
+}
+
+function &_hx_array_get_ref(&$o, $index) {
+	$r = null;
+	if(isset($o[$index])) $r =& $o[$index];
+	return $r;
+}
+/*
+function _hx_res($n) {
+	$file = dirname(__FILE__).'/../../res/'.$n;
+	if(!file_exists($file))
+		throw new HException('Invalid Resource name: ' . $n);
+	return file_get_contents($file);
+}
+*/
+
+function _hx_string_call($s, $method, $params) {
+	if(!is_string($s)) return call_user_func_array(array($s, $method), $params);
+	switch($method) {
+		case 'toUpperCase': return strtoupper($s);
+		case 'toLowerCase': return strtolower($s);
+		case 'charAt'     : return substr($s, $params[0], 1);
+		case 'charCodeAt' : return _hx_char_code_at($s, $params[0]);
+		case 'indexOf'    : return _hx_index_of($s, $params[0], (_hx_len($params) > 1 ? $params[1] : null));
+		case 'lastIndexOf': return _hx_last_index_of($s, (_hx_len($params) > 1 ? $params[1] : null), null);
+		case 'split'      : return explode($params[0], $s);
+		case 'substr'     : return _hx_substr($s, $params[0], (_hx_len($params) > 1 ? $params[1] : null));
+		default           : throw new HException('Invalid Operation: ' . $method);
+	}
+}
+
+function _hx_array_call(&$arr, $method, $params) {
+	if(!is_array($arr)) return call_user_func_array(array($arr, $method), $params);
+	switch($method) {
+		case 'concat'  : return array_merge($arr, $params[0]);
+		case 'copy'    : return _hx_array_copy($arr);
+		case 'insert'  : return _hx_array_insert($arr, $params[0], $params[1]);
+		case 'iterator': return new _hx_array_iterator($arr);
+		case 'join'    : return join($params[0], $arr);
+		case 'pop'     : return array_pop($arr);
+		case 'push'    : return array_push($arr, $params[0]);
+		case 'remove'  : return _hx_array_remove($arr, $params[0]);
+		case 'reverse' : return _hx_array_reverse($arr);
+		case 'shift'   : return array_shift($arr);
+		case 'slice'   : return _hx_array_slice($arr, $params[0], (_hx_len($params) > 1 ? $params[1] : null));
+		case 'sort'    : return _hx_array_sort($arr, $params[0]);
+		case 'splice'  : return _hx_array_splice($arr, $params[0], $params[1]);
+		case 'unshift' : return array_unshift($arr, $params[0]);
+		default        : throw new HException('Invalid Operation: ' . $method);
+	}
+}
+
+
 function _hx_shift_right($v, $n) {
 function _hx_shift_right($v, $n) {
 	$z = 0x80000000;
 	$z = 0x80000000;
 	if ($z & $v) {
 	if ($z & $v) {
@@ -307,6 +222,78 @@ function _hx_field($o, $field) {
 	}
 	}
 }
 }
 
 
+function _hx_string_rec($o, $s) {
+	if($o === null)                return 'null';
+	if(strlen($s) >= 5)            return '<...>';
+	if(is_int($o) || is_float($o)) return $o;
+	if(is_bool($o))                return $o ? 'true' : 'false';
+	if(is_object($o)) {
+		$c = get_class($o);
+		if($o instanceof Enum) {
+			$b = $o->tag;
+			if(!empty($o->params)) {
+				$s .= \"\t\";
+				$b .= '(';
+				for($i = 0; $i < count($o->params); $i++) {
+					if($i > 0)
+						$b .= ', ' . _hx_string_rec($o->params[$i], $s);
+					else
+						$b .= _hx_string_rec($o->params[$i], $s);
+				}
+				$b .= ')';
+			}
+			return $b;
+		} else {
+			if($o instanceof _hx_anonymous) {
+				$rfl = new ReflectionObject($o);
+				$b2 = \"{\n\";
+				$s .= \"\t\";
+				$properties = $rfl->getProperties();
+
+				for($i = 0; $i < count($properties); $i++) {
+					$prop = $properties[$i];
+					$f = $prop->getName();
+					if(strlen($b2) !== 2)
+						$b2 .= \", \n\";
+					$b2 .= $s . $f . ' : ' . _hx_string_rec($prop->getValue($o), $s);
+				}
+				$s = substr($s, 1);
+				$b2 .= \"\n\" . $s . '}';
+				return $b2;
+			} else {
+				if($o instanceof _hx_type)
+					return $o->__qname__;
+				else {
+					if(is_callable(_hx_array($o, 'toString')))
+						return $o->toString();
+					else {
+						if(is_callable(_hx_array($o, '__toString')))
+							return $o->__toString();
+						else
+							return '[' . _hx_ttype($c) . ']';
+					}
+				}
+			}
+		}
+	}
+	if(is_string($o)) {
+		if(_hx_is_lambda($o)) return '«function»';
+		if(strlen($s) > 0)    return '\"' . str_replace('\"', '\\\"', $o) . '\"';
+		else                  return $o;
+	}
+	if(is_array($o)) {
+		if(is_callable($o)) return '«function»';
+		$str = '[';
+		$s .= \"\t\";
+		for($i = 0; $i < count($o); $i++)
+			$str .= ($i > 0 ? ', ' : '') . _hx_string_rec($o[$i], $s);
+		$str .= ']';
+		return $str;
+	}
+	return '';
+}
+
+
 function _hx_array_copy($a) {
 function _hx_array_copy($a) {
 	return $a;
 	return $a;
 }
 }
@@ -391,7 +378,7 @@ function _hx_anonymous($p = array()) {
 
 
 function _hx_trace($v, $i) {
 function _hx_trace($v, $i) {
 	$msg = $i !== null ? $i->fileName.':'.$i->lineNumber.': ' : '';
 	$msg = $i !== null ? $i->fileName.':'.$i->lineNumber.': ' : '';
-	echo $msg.php_Boot::__string_rec($v, '').\"\n\";
+	echo $msg._hx_string_rec($v, '').\"\n\";
 }
 }
 
 
 function _hx_len($o) {
 function _hx_len($o) {
@@ -567,12 +554,12 @@ class _hx_array_iterator {
 }
 }
 
 
 class HException extends Exception {
 class HException extends Exception {
-	public function __construct($e, $message = null, $code = null, $p = null) { if( !php_Boot::$skip_constructor ) {
-		$message = php_Boot::__string_rec($e, '') . $message;
+	public function __construct($e, $message = null, $code = null, $p = null) {
+		$message = _hx_string_rec($e, '') . $message;
 		parent::__construct($message,$code);
 		parent::__construct($message,$code);
 		$this->e = $e;
 		$this->e = $e;
 		$this->p = $p;
 		$this->p = $p;
-	}}
+	}
 	public $e;
 	public $e;
 	public $p;
 	public $p;
 	public function setLine($l) {
 	public function setLine($l) {
@@ -678,18 +665,19 @@ class Enum {
 	}
 	}
 }
 }
 
 
-php_Boot::$__qtypes = array();
-php_Boot::$__ttypes = array();
-php_Boot::$__tpaths = array();
-php_Boot::__register_type(new _hx_class('String',  'String'));
-php_Boot::__register_type(new _hx_class('Array',   'Array'));
-php_Boot::__register_type(new _hx_class('Int',     'Int'));
-php_Boot::__register_type(new _hx_class('Float',   'Float'));
-php_Boot::__register_type(new _hx_class('Class',   'Class'));
-php_Boot::__register_type(new _hx_class('Enum',    'Enum'));
-php_Boot::__register_type(new _hx_class('Dynamic', 'Dynamic'));
-php_Boot::__register_type(new _hx_enum('Bool',     'Bool'));
-php_Boot::__register_type(new _hx_enum('Void',     'Void'));
+php_Boot::$qtypes = array();
+php_Boot::$ttypes = array();
+php_Boot::$tpaths = array();
+
+_hx_register_type(new _hx_class('String',  'String'));
+_hx_register_type(new _hx_class('Array',   'Array'));
+_hx_register_type(new _hx_class('Int',     'Int'));
+_hx_register_type(new _hx_class('Float',   'Float'));
+_hx_register_type(new _hx_class('Class',   'Class'));
+_hx_register_type(new _hx_class('Enum',    'Enum'));
+_hx_register_type(new _hx_class('Dynamic', 'Dynamic'));
+_hx_register_type(new _hx_enum('Bool',     'Bool'));
+_hx_register_type(new _hx_enum('Void',     'Void'));
 
 
 
 
 $_hx_libdir = dirname(__FILE__) . '/..';
 $_hx_libdir = dirname(__FILE__) . '/..';
@@ -731,13 +719,13 @@ if(!file_exists($_hx_autload_cache_file)) {
 		closedir($h);
 		closedir($h);
 	}
 	}
 
 
+	$_hx_cache_content = '<?php\n\n';
 	$_hx_types_array = array();
 	$_hx_types_array = array();
 
 
 	_hx_build_paths($_hx_libdir, $_hx_types_array, array());
 	_hx_build_paths($_hx_libdir, $_hx_types_array, array());
 
 
-	$_hx_cache_content = '<?php\n\n';
 	for($i=0;$i<count($_hx_types_array);$i++) {
 	for($i=0;$i<count($_hx_types_array);$i++) {
-		$_hx_cache_content .= 'php_Boot::__register_type(new ';
+		$_hx_cache_content .= '_hx_register_type(new ';
 		$t = null;
 		$t = null;
 		if($_hx_types_array[$i]['type'] == 0) {
 		if($_hx_types_array[$i]['type'] == 0) {
 			$t = new _hx_class($_hx_types_array[$i]['phpname'], $_hx_types_array[$i]['qname'], $_hx_types_array[$i]['path']);
 			$t = new _hx_class($_hx_types_array[$i]['phpname'], $_hx_types_array[$i]['qname'], $_hx_types_array[$i]['path']);
@@ -752,21 +740,21 @@ if(!file_exists($_hx_autload_cache_file)) {
 			$t = new _hx_class($_hx_types_array[$i]['name'], $_hx_types_array[$i]['qname'], $_hx_types_array[$i]['path']);
 			$t = new _hx_class($_hx_types_array[$i]['name'], $_hx_types_array[$i]['qname'], $_hx_types_array[$i]['path']);
 			$_hx_cache_content .= '_hx_class';
 			$_hx_cache_content .= '_hx_class';
 		}
 		}
-		php_Boot::__register_type($t);
+		_hx_register_type($t);
 		$_hx_cache_content .= '(\\''.($_hx_types_array[$i]['type'] == 3 ? $_hx_types_array[$i]['name'] : $_hx_types_array[$i]['phpname']).'\\', \\''.$_hx_types_array[$i]['qname'].'\\', \\''.$_hx_types_array[$i]['path'].'\\'));\n';
 		$_hx_cache_content .= '(\\''.($_hx_types_array[$i]['type'] == 3 ? $_hx_types_array[$i]['name'] : $_hx_types_array[$i]['phpname']).'\\', \\''.$_hx_types_array[$i]['qname'].'\\', \\''.$_hx_types_array[$i]['path'].'\\'));\n';
 	}
 	}
-	unset($_hx_types_array);
 	try {
 	try {
 		file_put_contents($_hx_autload_cache_file, $_hx_cache_content);
 		file_put_contents($_hx_autload_cache_file, $_hx_cache_content);
-		unset($_hx_cache_content);
 	} catch(Exception $e) {}
 	} catch(Exception $e) {}
+	unset($_hx_types_array);
+	unset($_hx_cache_content);
 } else {
 } else {
 	require($_hx_autload_cache_file);
 	require($_hx_autload_cache_file);
 }
 }
 
 
 function _hx_autoload($name) {
 function _hx_autoload($name) {
-	if(!isset(php_Boot::$__tpaths[$name])) return false;
-	require_once php_Boot::$__tpaths[$name];
+	if(!isset(php_Boot::$tpaths[$name])) return false;
+	require_once(php_Boot::$tpaths[$name]);
 	return true;
 	return true;
 }
 }
 
 

+ 4 - 4
std/php/Lib.hx

@@ -83,10 +83,10 @@ class Lib {
 	public static function getClasses() {
 	public static function getClasses() {
 		var path : String = null;
 		var path : String = null;
 		var o = {};
 		var o = {};
-		untyped __call__('reset', php.Boot.__qtypes);
-		while((path = untyped __call__('key', php.Boot.__qtypes)) != null) {
-			appendType(o, path.split('.'), untyped php.Boot.__qtypes[path]);
-			untyped __call__('next', php.Boot.__qtypes);
+		untyped __call__('reset', __var__("_hx_qtypes"));
+		while((path = untyped __call__('key', __var__("_hx_qtypes"))) != null) {
+			appendType(o, path.split('.'), untyped __var__("_hx_qtypes", path));
+			untyped __call__('next',__var__("_hx_qtypes"));
 		}
 		}
 		return o;
 		return o;
 	}
 	}