зеркало из https://github.com/mozilla/pluotsorbet.git
fix long constants
This commit is contained in:
Родитель
06e9345335
Коммит
d8b4d71369
|
@ -142,7 +142,7 @@ var getClassImage = function(classBytes) {
|
|||
++i;
|
||||
break;
|
||||
case TAGS.CONSTANT_Long:
|
||||
classImage.constant_pool.push({ tag: tag, bits: reader.readLong() });
|
||||
classImage.constant_pool.push({ tag: tag, highBits: reader.readInteger(), lowBits: reader.readInteger() });
|
||||
classImage.constant_pool.push(null);
|
||||
++i;
|
||||
break;
|
||||
|
|
|
@ -42,13 +42,6 @@ Reader.prototype.readFloat = function() {
|
|||
return data;
|
||||
}
|
||||
|
||||
Reader.prototype.readLong = function() {
|
||||
var data = new Int32Array(2);
|
||||
data[0] = this.readInteger();
|
||||
data[1] = this.readInteger();
|
||||
return data;
|
||||
}
|
||||
|
||||
Reader.prototype.readDouble = function() {
|
||||
var data = this.bytes.getFloat64(this.offset, false);
|
||||
this.offset += 8;
|
||||
|
|
|
@ -3,7 +3,12 @@ package tests;
|
|||
public class TestLong {
|
||||
static long a = 0x0123456789abcdefL;
|
||||
|
||||
public static long x(long a, long b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(0x12345678);
|
||||
if (x(1L, 2L) == 3L)
|
||||
System.out.println("OK");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ public class TestOps {
|
|||
return a % b;
|
||||
}
|
||||
|
||||
static long ladd(long a, long b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Assert("Do asserts work", true);
|
||||
Assert("add two ints", iadd(1, 2) == 3);
|
||||
|
@ -55,5 +59,6 @@ public class TestOps {
|
|||
Assert("float neg", fneg(1.0f) == -1.0f);
|
||||
Assert("float mul", fmul(2.0f, 3.0f) == 6.0f);
|
||||
Assert("float div", fdiv(6.0f, 2.0f) == 3.0f);
|
||||
Assert("long add", ladd(1L, 2L) == 3L);
|
||||
}
|
||||
}
|
||||
|
|
2
vm.js
2
vm.js
|
@ -77,7 +77,7 @@ VM.execute = function(frame) {
|
|||
var constant = cp[frame.read16()];
|
||||
switch(constant.tag) {
|
||||
case TAGS.CONSTANT_Long:
|
||||
stack.push2(Long.fromBits(constant.bits[0], constant.bits[1]));
|
||||
stack.push2(Long.fromBits(constant.lowBits, constant.highBits));
|
||||
break;
|
||||
case TAGS.CONSTANT_Double:
|
||||
stack.push2(constant.double);
|
||||
|
|
Загрузка…
Ссылка в новой задаче