Sfoglia il codice sorgente

changes in flash9 __global__

Nicolas Cannasse 19 anni fa
parent
commit
222ddb90ad
5 ha cambiato i file con 24 aggiunte e 18 eliminazioni
  1. 4 6
      genswf9.ml
  2. 5 5
      std/Math.hx
  3. 2 2
      std/Std.hx
  4. 4 0
      std/flash9/Lib.hx
  5. 9 5
      std/haxe/Timer.hx

+ 4 - 6
genswf9.ml

@@ -577,10 +577,6 @@ let rec gen_expr_content ctx retval e =
 
 and gen_call ctx e el =
 	match e.eexpr , el with
-	| TField ({ eexpr = TLocal "__global__" },f) , el ->
-		write ctx (A3GetInf (ident ctx f));
-		List.iter (gen_expr ctx true) el;
-		write ctx (A3Call (ident ctx f,List.length el))
 	| TLocal "__is__" , [e;t] ->
 		gen_expr ctx true e;
 		gen_expr ctx true t;
@@ -613,8 +609,6 @@ and gen_access ctx e =
 	match e.eexpr with
 	| TLocal i ->
 		VReg (try PMap.find i ctx.locals with Not_found -> error e.epos)
-	| TField ({ eexpr = TLocal "__global__" },f) ->
-		VGlobal (ident ctx f)
 	| TField ({ eexpr = TLocal "__native__" },f) ->
 		let nameid = string ctx f in
 		let adobeid = string ctx "http://adobe.com/AS3/2006/builtin" in
@@ -628,6 +622,10 @@ and gen_access ctx e =
 		| TConst TThis when not ctx.in_static -> write ctx (A3GetInf id)
 		| _ -> gen_expr ctx true e);
 		VId id
+	| TArray ({ eexpr = TLocal "__global__" },{ eexpr = TConst (TString s) }) ->
+		let path = (match List.rev (ExtString.String.nsplit s ".") with [] -> assert false | x :: l -> List.rev l, x) in
+		let id = type_path ctx path in
+		VGlobal id
 	| TArray (e,eindex) ->
 		gen_expr ctx true e;
 		gen_expr ctx true eindex;

+ 5 - 5
std/Math.hx

@@ -57,9 +57,9 @@ extern class Math
 		Math = neko.NekoMath__;
 	#else true
 		#if flash9
-		NaN = __global__.Number.NaN;
-		NEGATIVE_INFINITY = __global__.Number.NEGATIVE_INFINITY;
-		POSITIVE_INFINITY = __global__.Number.POSITIVE_INFINITY;
+		NaN = __global__["Number"].NaN;
+		NEGATIVE_INFINITY = __global__["Number"].NEGATIVE_INFINITY;
+		POSITIVE_INFINITY = __global__["Number"].POSITIVE_INFINITY;
 		#else true
 		NaN = Number["NaN"];
 		NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];
@@ -68,7 +68,7 @@ extern class Math
 		isFinite = function(i) {
 			return
 			#if flash9
-			__global__.isFinite(i);
+			__global__["isFinite"](i);
 			#else flash
 			_global["isFinite"](i);
 			#else js
@@ -79,7 +79,7 @@ extern class Math
 		isNaN = function(i) {
 			return
 			#if flash9
-			__global__.isNaN(i);
+			__global__["isNaN"](i);
 			#else flash
 			_global["isNaN"](i);
 			#else js

+ 2 - 2
std/Std.hx

@@ -78,7 +78,7 @@ class Std {
 	public static function parseInt( x : String ) : Int {
 		untyped {
 		#if flash9
-		var v = __global__.parseInt(x);
+		var v = __global__["parseInt"](x);
 		if( Math.isNaN(v) )
 			return null;
 		return v;
@@ -112,7 +112,7 @@ class Std {
 	public static function parseFloat( x : String ) : Float {
 		return untyped
 		#if flash9
-		__global__.parseFloat(x);
+		__global__["parseFloat"](x);
 		#else flash
 		_global["parseFloat"](x);
 		#else neko

+ 4 - 0
std/flash9/Lib.hx

@@ -28,6 +28,10 @@ class Lib {
 
 	public static var current : flash.display.MovieClip;
 
+	public static function getTimer() : Float {
+		return untyped __global__["flash.utils.getTimer"]();
+	}
+
 }
 
 

+ 9 - 5
std/haxe/Timer.hx

@@ -33,7 +33,9 @@ class Timer {
 	#end
 
 	public function new( time : Int ){
-		#if flash
+		#if flash9
+			throw "Not implemented";
+		#else flash
 			var me = this;
 			id = untyped _global["setInterval"](function() { me.run(); },time);
 		#else js
@@ -46,7 +48,9 @@ class Timer {
 	}
 
 	public function stop(){
-		#if flash
+		#if flash9
+			throw "Not implemented";
+		#else flash
 			untyped _global["clearInterval"](id);
 			id = null;
 		#else js
@@ -57,7 +61,7 @@ class Timer {
 
 	public function run(){
 	}
-
+/*
 	public static function delayed( f : Void -> Void, time : Int ) : Void -> Void {
 		return function() {
 			var t = new haxe.Timer(time);
@@ -77,9 +81,9 @@ class Timer {
 			};
 		};
 	}
-
+*/
 	public static function stamp() : Float {
-		#if flash
+		#if flash9
 		return flash.Lib.getTimer() / 1000;
 		#else neko
 		return neko.Sys.time();