Skip to content

Commit

Permalink
fix overflow on bigint platforms (close #42)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed May 6, 2017
1 parent ace61e5 commit 8b9b244
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 2 additions & 9 deletions Test.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,8 @@ class Test extends TestCase {
function test():Void {
assertScript("0",0);
assertScript("0xFF", 255);
#if !(php || python)
#if haxe3
assertScript("0xBFFFFFFF", 0xBFFFFFFF);
assertScript("0x7FFFFFFF", 0x7FFFFFFF);
#elseif !neko
assertScript("n(0xBFFFFFFF)", 0xBFFFFFFF, { n : haxe.Int32.toNativeInt });
assertScript("n(0x7FFFFFFF)", 0x7FFFFFFF, { n : haxe.Int32.toNativeInt } );
#end
#end
assertScript("0xBFFFFFFF", 0xBFFFFFFF);
assertScript("0x7FFFFFFF", 0x7FFFFFFF);
assertScript("-123",-123);
assertScript("- 123",-123);
assertScript("1.546",1.546);
Expand Down
4 changes: 2 additions & 2 deletions hscript/Parser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ class Parser {
// in case of '...'
if( exp == 10 && readChar() == 46 ) {
push(TOp("..."));
var i = Std.int(n);
var i = Std.int(n) & 0xFFFFFFFF;
return TConst( (i == n) ? CInt(i) : CFloat(n) );
}
invalidChar(char);
Expand All @@ -1006,7 +1006,7 @@ class Parser {
n = (n << 4) + (char - 87);
default:
this.char = char;
return TConst(CInt(n));
return TConst(CInt(n & 0xFFFFFFFF));
}
}
#else
Expand Down

0 comments on commit 8b9b244

Please sign in to comment.