Refactor to load lua chunks compiled with 8-byte size_t elements.

This commit is contained in:
James Roseborough
2012-09-11 04:35:30 +00:00
parent 382b3b998e
commit 84fec1ae67
5 changed files with 5 additions and 8 deletions

View File

@@ -203,7 +203,7 @@ public class LoadState {
* @return the {@link LuaString} value laoded.
**/
LuaString loadString() throws IOException {
int size = loadInt();
int size = this.luacSizeofSizeT == 8? (int) loadInt64(): loadInt();
if ( size == 0 )
return null;
byte[] bytes = new byte[size];

View File

@@ -155,9 +155,8 @@ public class MathLib extends OneArgFunction {
}
static final class ldexp extends BinaryOp {
protected double call(double x, double y) {
y += 1023.5;
long e = (long) ((0!=(1&((int)y)))? Math.floor(y): Math.ceil(y-1));
return x * Double.longBitsToDouble(e << 52);
// This is the behavior on os-x, windows differs in rounding behavior.
return x * Double.longBitsToDouble((((long) y) + 1023) << 52);
}
}
static final class pow extends BinaryOp {