haxe3 support
This commit is contained in:
@@ -16,10 +16,15 @@ class Test {
|
||||
static function main() {
|
||||
test("0",0);
|
||||
test("0xFF", 255);
|
||||
#if haxe3
|
||||
test("n(0xBFFFFFFF)",0xBFFFFFFF);
|
||||
test("n(0x7FFFFFFF)", 0x7FFFFFFF);
|
||||
#else
|
||||
#if !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);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<project name="hscript" url="http://haxe.org/com/libs/hscript" license="GPL">
|
||||
<user name="ncannasse"/>
|
||||
<tag v="cross"/>
|
||||
<description>haXe Script is a scripting engine for a subset of the haXe language</description>
|
||||
<version name="1.7">minor fixes</version>
|
||||
<description>Haxe Script is a scripting engine for a subset of the haXe language</description>
|
||||
<version name="1.7.1">minor fixes</version>
|
||||
</project>
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
-swf9 hscript.swf
|
||||
-swf hscript.swf
|
||||
-swf-header 800:600:30:FFFFFF
|
||||
--flash-strict
|
||||
-swf-version 9
|
||||
-main Test
|
||||
|
||||
+6
-2
@@ -87,13 +87,15 @@ class Bytes {
|
||||
bout.addByte((v >> 16) & 0xFF);
|
||||
bout.addByte(v >>> 24);
|
||||
}
|
||||
#if !haxe3
|
||||
case CInt32(v):
|
||||
bout.addByte(4);
|
||||
var mid = haxe.Int32.toInt(haxe.Int32.and(v,haxe.Int32.ofInt(0xFFFFFF)));
|
||||
bout.addByte(mid & 0xFF);
|
||||
bout.addByte((mid >> 8) & 0xFF);
|
||||
bout.addByte(mid >> 16);
|
||||
bout.addByte(haxe.Int32.toInt(haxe.Int32.ushr(v,24)));
|
||||
bout.addByte(haxe.Int32.toInt(haxe.Int32.ushr(v, 24)));
|
||||
#end
|
||||
case CFloat(f):
|
||||
bout.addByte(2);
|
||||
doEncodeString(Std.string(f));
|
||||
@@ -115,11 +117,13 @@ class Bytes {
|
||||
CFloat( Std.parseFloat(doDecodeString()) );
|
||||
case 3:
|
||||
CString( doDecodeString() );
|
||||
#if !haxe3
|
||||
case 4:
|
||||
var i = bin.get(pin) | (bin.get(pin+1) << 8) | (bin.get(pin+2) << 16);
|
||||
var j = bin.get(pin+3);
|
||||
pin += 4;
|
||||
CInt32(haxe.Int32.or(haxe.Int32.ofInt(i),haxe.Int32.shl(haxe.Int32.ofInt(j),24)));
|
||||
CInt32(haxe.Int32.or(haxe.Int32.ofInt(i), haxe.Int32.shl(haxe.Int32.ofInt(j), 24)));
|
||||
#end
|
||||
default:
|
||||
throw "Invalid code "+bin.get(pin-1);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ enum Const {
|
||||
CInt( v : Int );
|
||||
CFloat( f : Float );
|
||||
CString( s : String );
|
||||
#if !haxe3
|
||||
CInt32( v : haxe.Int32 );
|
||||
#end
|
||||
}
|
||||
|
||||
#if hscriptPos
|
||||
|
||||
+3
-1
@@ -206,9 +206,11 @@ class Interp {
|
||||
case EConst(c):
|
||||
switch( c ) {
|
||||
case CInt(v): return v;
|
||||
case CInt32(v): return v;
|
||||
case CFloat(f): return f;
|
||||
case CString(s): return s;
|
||||
#if !haxe3
|
||||
case CInt32(v): return v;
|
||||
#end
|
||||
}
|
||||
case EIdent(id):
|
||||
var l = locals.get(id);
|
||||
|
||||
+21
-1
@@ -839,6 +839,23 @@ class Parser {
|
||||
if( n > 0 || exp > 0 )
|
||||
invalidChar(char);
|
||||
// read hexa
|
||||
#if haxe3
|
||||
var n = 0;
|
||||
while( true ) {
|
||||
char = readChar();
|
||||
switch( char ) {
|
||||
case 48,49,50,51,52,53,54,55,56,57: // 0-9
|
||||
n = (n << 4) + char - 48;
|
||||
case 65,66,67,68,69,70: // A-F
|
||||
n = (n << 4) + (char - 55);
|
||||
case 97,98,99,100,101,102: // a-f
|
||||
n = (n << 4) + (char - 87);
|
||||
default:
|
||||
this.char = char;
|
||||
return TConst(CInt(n));
|
||||
}
|
||||
}
|
||||
#else
|
||||
var n = haxe.Int32.ofInt(0);
|
||||
while( true ) {
|
||||
char = readChar();
|
||||
@@ -858,6 +875,7 @@ class Parser {
|
||||
return TConst(v);
|
||||
}
|
||||
}
|
||||
#end
|
||||
default:
|
||||
this.char = char;
|
||||
var i = Std.int(n);
|
||||
@@ -975,9 +993,11 @@ class Parser {
|
||||
function constString( c ) {
|
||||
return switch(c) {
|
||||
case CInt(v): Std.string(v);
|
||||
case CInt32(v): Std.string(v);
|
||||
case CFloat(f): Std.string(f);
|
||||
case CString(s): s; // TODO : escape + quote
|
||||
#if !haxe3
|
||||
case CInt32(v): Std.string(v);
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user