diff --git a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java index debf53bda..8fef2ed31 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java @@ -882,14 +882,14 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext writer.append(')'); break; case BYTE_TO_INT: - writer.append("$rt_byteToInt("); + writer.append("(("); expr.getOperand().acceptVisitor(this); - writer.append(')'); + writer.ws().append("<<").ws().append("24)").ws().append(">>").ws().append("24)"); break; case SHORT_TO_INT: - writer.append("$rt_shortToInt("); + writer.append("(("); expr.getOperand().acceptVisitor(this); - writer.append(')'); + writer.ws().append("<<").ws().append("16)").ws().append(">>").ws().append("16)"); break; case NULL_CHECK: writer.append("$rt_nullCheck("); diff --git a/teavm-core/src/main/resources/org/teavm/javascript/runtime.js b/teavm-core/src/main/resources/org/teavm/javascript/runtime.js index 02d572197..90151adde 100644 --- a/teavm-core/src/main/resources/org/teavm/javascript/runtime.js +++ b/teavm-core/src/main/resources/org/teavm/javascript/runtime.js @@ -201,19 +201,6 @@ $rt_voidcls = function() { } return $rt_voidclsCache; } -$rt_equals = function(a, b) { - if (a === b) { - return true; - } - if (a === null || b === null) { - return false; - } - if (typeof(a) == 'object') { - return a.equals(b); - } else { - return false; - } -} $rt_clinit = function(cls) { if (cls.$clinit) { var f = cls.$clinit; @@ -236,12 +223,6 @@ $rt_throw = function(ex) { } throw err; } -$rt_byteToInt = function(value) { - return value > 0xFF ? value | 0xFFFFFF00 : value; -} -$rt_shortToInt = function(value) { - return value > 0xFFFF ? value | 0xFFFF0000 : value; -} $rt_createMultiArray = function(cls, dimensions) { var arrays = new Array($rt_primitiveArrayCount(dimensions)); var firstDim = dimensions[0] | 0; @@ -546,6 +527,7 @@ Long_xor = function(a, b) { return new Long(a.lo ^ b.lo, a.hi ^ b.hi); } Long_shl = function(a, b) { + b &= 63; if (b < 32) { return new Long(a.lo << b, (a.lo >>> (32 - b)) | (a.hi << b)); } else { @@ -553,10 +535,11 @@ Long_shl = function(a, b) { } } Long_shr = function(a, b) { + b &= 63; if (b < 32) { return new Long((a.lo >>> b) | (a.hi << (32 - b)), a.hi >> b); } else { - return new Long((a.hi >> (b - 32)), -1); + return new Long((a.hi >> (b - 32)), a.hi >> 31); } } Long_shru = function(a, b) {