diff --git a/Test.hx b/Test.hx
index 2fc7465..db7e585 100644
--- a/Test.hx
+++ b/Test.hx
@@ -17,14 +17,12 @@ class Test {
test("0",0);
test("0xFF", 255);
#if haxe3
- test("n(0xBFFFFFFF)",0xBFFFFFFF);
- test("n(0x7FFFFFFF)", 0x7FFFFFFF);
- #else
- #if !neko
+ test("0xBFFFFFFF",0xBFFFFFFF);
+ test("0x7FFFFFFF", 0x7FFFFFFF);
+ #elseif !neko
test("n(0xBFFFFFFF)",0xBFFFFFFF,{ n : haxe.Int32.toNativeInt });
test("n(0x7FFFFFFF)", 0x7FFFFFFF, { n : haxe.Int32.toNativeInt } );
#end
- #end
test("-123",-123);
test("- 123",-123);
test("1.546",1.546);
@@ -70,8 +68,12 @@ class Test {
test("(function(a,b) return a + b)(4,5)",9);
test("var y = 0; var add = function(a) y += a; add(5); add(3); y", 8);
test("var a = [1,[2,[3,[4,null]]]]; var t = 0; while( a != null ) { t += a[0]; a = a[1]; }; t",10);
- test("var t = 0; for( x in 1...10 ) t += x; t",45);
- test("var t = 0; for( x in new IntIter(1,10) ) t +=x; t",45,{ IntIter : #if (haxe3 || haxe_211) IntIterator #else IntIter #end });
+ test("var t = 0; for( x in 1...10 ) t += x; t", 45);
+ #if haxe3
+ test("var t = 0; for( x in new IntIterator(1,10) ) t +=x; t", 45);
+ #else
+ test("var t = 0; for( x in new IntIter(1,10) ) t +=x; t", 45);
+ #end
test("var x = 1; try { var x = 66; throw 789; } catch( e : Dynamic ) e + x",790);
test("var x = 1; var f = function(x) throw x; try f(55) catch( e : Dynamic ) e + x",56);
test("var i=2; if( true ) --i; i",1);
diff --git a/hscript.hxml b/hscript.hxml
index 1106017..2df61ff 100644
--- a/hscript.hxml
+++ b/hscript.hxml
@@ -3,3 +3,4 @@
--flash-strict
-swf-version 9
-main Test
+-dce no
diff --git a/hscript.hxproj b/hscript.hxproj
index c1bda34..bea2adc 100644
--- a/hscript.hxproj
+++ b/hscript.hxproj
@@ -23,7 +23,7 @@
-
+
diff --git a/hscript/Interp.hx b/hscript/Interp.hx
index 063fe3b..79c3019 100644
--- a/hscript/Interp.hx
+++ b/hscript/Interp.hx
@@ -224,6 +224,16 @@ class Interp {
locals.set(d.n,d.old);
}
}
+
+ function resolve( id : String ) : Dynamic {
+ var l = locals.get(id);
+ if( l != null )
+ return l.r;
+ var v = variables.get(id);
+ if( v == null && !variables.exists(id) )
+ throw Error.EUnknownVariable(id);
+ return v;
+ }
public function expr( e : Expr ) : Dynamic {
switch( e ) {
@@ -237,13 +247,7 @@ class Interp {
#end
}
case EIdent(id):
- var l = locals.get(id);
- if( l != null )
- return l.r;
- var v = variables.get(id);
- if( v == null && !variables.exists(id) )
- throw Error.EUnknownVariable(id);
- return v;
+ return resolve(id);
case EVar(n,_,e):
declared.push({ n : n, old : locals.get(n) });
locals.set(n,{ r : (e == null)?null:expr(e) });
@@ -439,7 +443,9 @@ class Interp {
}
function cnew( cl : String, args : Array ) : Dynamic {
- return Type.createInstance(Type.resolveClass(cl),args);
+ var c = Type.resolveClass(cl);
+ if( c == null ) c = resolve(cl);
+ return Type.createInstance(c,args);
}
}
\ No newline at end of file