haxe3 support
This commit is contained in:
+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