From 808b0d9468f9e0f354f856d11f63d6c41ebd6f0c Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Fri, 13 Dec 2013 17:28:30 +0400 Subject: [PATCH] Fixes bugs --- .../classlib/java/lang/TAbstractStringBuilder.java | 2 +- .../java/org/teavm/dependency/DependencyChecker.java | 1 + .../src/main/java/org/teavm/javascript/Renderer.java | 2 +- .../org/teavm/model/resource/ClassRefsRenamer.java | 4 ++++ .../main/java/org/teavm/parsing/ProgramParser.java | 11 ++++++----- .../main/resources/org/teavm/javascript/runtime.js | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java index 305fbceb8..7687fae1e 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java @@ -82,7 +82,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ } buffer[length++] = (char)('0' + value); } else { - int pos = 10; + long pos = 10; int sz = 1; while (pos < 1000000000000000000L && pos * 10 <= value) { pos *= 10; diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java index fa7d198d3..a5c8aa0c2 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java @@ -133,6 +133,7 @@ public class DependencyChecker { if (e != null) { throw exceptionOccured.get(); } + executor.shutdown(); } void achieveClass(String className) { 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 547c4b9ed..f0505a5b0 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java @@ -701,7 +701,7 @@ public class Renderer implements ExprVisitor, StatementVisitor { } else if ((int)value == value) { return "Long_fromInt(" + value + ")"; } else { - return "new Long(" + (value & 0xFFFFFFFF) + ", " + (value >>> 32) + ")"; + return "new Long(" + (value & 0xFFFFFFFFL) + ", " + (value >>> 32) + ")"; } } else { return cst.toString(); diff --git a/teavm-core/src/main/java/org/teavm/model/resource/ClassRefsRenamer.java b/teavm-core/src/main/java/org/teavm/model/resource/ClassRefsRenamer.java index 93d3af609..33259996a 100644 --- a/teavm-core/src/main/java/org/teavm/model/resource/ClassRefsRenamer.java +++ b/teavm-core/src/main/java/org/teavm/model/resource/ClassRefsRenamer.java @@ -2,6 +2,7 @@ package org.teavm.model.resource; import java.util.Map; import org.teavm.common.Mapper; +import org.teavm.javascript.ni.Remove; import org.teavm.javascript.ni.Rename; import org.teavm.javascript.ni.Superclass; import org.teavm.model.*; @@ -32,6 +33,9 @@ class ClassRefsRenamer implements InstructionVisitor { } renamedCls.setParent(parent != null ? classNameMapper.map(parent) : null); for (MethodHolder method : cls.getMethods()) { + if (method.getAnnotations().get(Remove.class.getName()) != null) { + continue; + } renamedCls.addMethod(rename(method)); } for (FieldHolder field : cls.getFields().toArray(new FieldHolder[0])) { diff --git a/teavm-core/src/main/java/org/teavm/parsing/ProgramParser.java b/teavm-core/src/main/java/org/teavm/parsing/ProgramParser.java index c7a6c10e3..47c811b30 100644 --- a/teavm-core/src/main/java/org/teavm/parsing/ProgramParser.java +++ b/teavm-core/src/main/java/org/teavm/parsing/ProgramParser.java @@ -69,21 +69,22 @@ public class ProgramParser { private void prepareParameters(MethodNode method) { int var = 0; + int offset = 0; if ((method.access & Opcodes.ACC_STATIC) == 0) { getVariable(var++); + ++offset; } ValueType[] desc = MethodDescriptor.parse(method.desc).getParameterTypes(); - int mappedLocal = 0; - localsMap = new int[desc.length * 2]; + localsMap = new int[desc.length * 2 + 1]; for (int i = 0; i < desc.length; ++i) { ValueType paramType = desc[i]; - localsMap[mappedLocal++] = i; + localsMap[var] = i + offset; getVariable(var++); if (paramType instanceof ValueType.Primitive) { switch (((ValueType.Primitive)paramType).getKind()) { case LONG: case DOUBLE: - localsMap[mappedLocal++] = i; + localsMap[var] = i + offset; getVariable(var++); break; default: @@ -91,7 +92,7 @@ public class ProgramParser { } } } - localsMap = Arrays.copyOf(localsMap, mappedLocal); + localsMap = Arrays.copyOf(localsMap, var); } private void prepare(MethodNode method) { 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 78f364f22..76a6f872b 100644 --- a/teavm-core/src/main/resources/org/teavm/javascript/runtime.js +++ b/teavm-core/src/main/resources/org/teavm/javascript/runtime.js @@ -255,7 +255,7 @@ Long = function(lo, hi) { } Long_ZERO = new Long(0, 0); Long_fromInt = function(val) { - return new Long(val, 0); + return val >= 0 ? new Long(val, 0) : new Long(val, -1); } Long_fromNumber = function(val) { return new Long(val | 0, (val / 0x100000000) | 0);