Browse Source

fixed protected vars.

Nicolas Cannasse 19 years ago
parent
commit
d130e443c4
2 changed files with 20 additions and 18 deletions
  1. 6 6
      genswf8.ml
  2. 14 12
      std/flash/Boot.hx

+ 6 - 6
genswf8.ml

@@ -178,7 +178,7 @@ let is_protected_name path ext =
 	match path with
 	| ["flash"] , "Boot" | ["flash"] , "Lib" -> false
 	| "flash" :: _ , _ -> ext
-	| [] , "Array" | [] , "Math" | [] , "Date" | [] , "String" | [] , "Bool" -> true
+	| [] , "Array" | [] , "Math" | [] , "Date" | [] , "String" -> true
 	| _ -> false
 
 let rec is_protected ctx t check_mt =
@@ -299,7 +299,7 @@ let getvar ctx = function
 	| VarStr -> write ctx AEval
 	| VarObj -> write ctx AObjGet
 	| VarClosure ->
-		push ctx [VInt 2; VStr ("@closure",true)];
+		push ctx [VInt 2; VStr ("@closure",false)];
 		call ctx VarStr 2
 
 let gen_path ctx (p,t) is_extern =
@@ -605,7 +605,7 @@ and gen_try_catch ctx retval e catchs =
 		| None ->
 			end_throw := false;
 			(* @exc.pop() *)
-			push ctx [VInt 0;VStr ("@exc",true)];
+			push ctx [VInt 0;VStr ("@exc",false)];
 			write ctx AEval;
 			push ctx [VStr ("pop",true)];
 			call ctx VarObj 0;
@@ -619,12 +619,12 @@ and gen_try_catch ctx retval e catchs =
 			(fun() -> ())
 		| Some t ->
 			getvar ctx (gen_access ctx false (mk (TType t) (mk_mono()) e.epos));
-			push ctx [VReg 0; VInt 2; VStr ("@instanceof",true)];
+			push ctx [VReg 0; VInt 2; VStr ("@instanceof",false)];
 			call ctx VarStr 2;
 			write ctx ANot;
 			let c = cjmp ctx in
 			(* @exc.pop() *)
-			push ctx [VInt 0;VStr ("@exc",true)];
+			push ctx [VInt 0;VStr ("@exc",false)];
 			write ctx AEval;
 			push ctx [VStr ("pop",true)];
 			call ctx VarObj 0;
@@ -1033,7 +1033,7 @@ and gen_expr_2 ctx retval e =
 		(* call @exc.push(e) *)
 		gen_expr ctx true e;
 		write ctx (ASetReg 0);
-		push ctx [VInt 1; VStr ("@exc",true)];
+		push ctx [VInt 1; VStr ("@exc",false)];
 		write ctx AEval;
 		push ctx [VStr ("push",true)];
 		call ctx VarObj 1;

+ 14 - 12
std/flash/Boot.hx

@@ -176,17 +176,19 @@ class Boot {
 		}
 	}
 
-	private static function __init(current) untyped {
+	private static function __init(current : Dynamic) untyped {
 		// only if not set yet
-		if( !_global.haxeInitDone ) {
+		var g : Dynamic = _global;
+		if( !g.haxeInitDone ) {
 			var obj = _global.Object;
-			_global.haxeInitDone = true;
-			_global.Int = __new__(obj);
-			_global.Bool = __new__(obj);
-			_global.Dynamic = __new__(obj);
-			_global.Bool["true"] = true;
-			_global.Bool["false"] = false;
-			_global.Float = _global.Number;
+			g.haxeInitDone = true;
+			g.Int = __new__(obj);
+			g.Bool = __new__(obj);
+			g.Dynamic = __new__(obj);
+			g.Bool = __new__(obj);
+			g.Bool[__unprotect__("true")] = true;
+			g.Bool[__unprotect__("false")] = false;
+			g.Float = _global.Number;
 			Array.prototype.copy = Array.prototype.slice;
 			Array.prototype.insert = function(i,x) {
 				this["splice"](i,0,x);
@@ -231,9 +233,9 @@ class Boot {
 		current.flash.Lib._root = _root;
 		current.flash.Lib.current = current;
 		// prevent closure creation by setting untyped
-		current["@instanceof"] = untyped __instanceof;
-		current["@closure"] = untyped __closure;
-		current["@exc"] = exc;
+		current[__unprotect__("@instanceof")] = untyped __instanceof;
+		current[__unprotect__("@closure")] = untyped __closure;
+		current[__unprotect__("@exc")] = exc;
 		// fix firefox default alignement
 		if( flash.Stage.align == "" )
 			flash.Stage.align = "LT";