diff --git a/README.md b/README.md
index d95a06a63..a56f09025 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ The easiest way to create a new TeaVM project is to type in the command line:
mvn -DarchetypeCatalog=local \
-DarchetypeGroupId=org.teavm \
-DarchetypeArtifactId=teavm-maven-webapp \
- -DarchetypeVersion=0.2.0 archetype:generate
+ -DarchetypeVersion=0.2.1 archetype:generate
Now you can execute `mvn clean package` and get the generated `war` file.
Deploy this `war` in Tomcat or another container, or simply unzip it and open the `index.html` page.
@@ -55,6 +55,9 @@ Live examples
Compare the speed of JavaScript produced by TeaVM and GWT here: http://teavm.org/live-examples/jbox2d-benchmark/
+Play [Geobot](http://teavm.org/live-examples/geobot/), a little physics-based puzzle game.
+Thanks to [joan789](http://joan789.deviantart.com/) for her great artwork!
+
Thanks to [Jaroslav Tulach](http://wiki.apidesign.org/wiki/User:JaroslavTulach), author of DukeScript, we have several
DukeScript example applications. One is the minesweeper game.
You can try its TeaVM-compiled version [here](http://xelfi.cz/minesweeper/teavm/), and then take a look at
@@ -65,3 +68,9 @@ Another example is avaialble [here](http://graphhopper.com/teavm/).
It uses [GraphHopper](https://github.com/graphhopper/graphhopper/) to build route in browser.
Unlike original GraphHopper example it works completely in browser instead of querying server.
Thanks to [Peter Karich](https://github.com/karussell).
+
+
+Feedback
+--------
+
+Ask your questions by email: info@teavm.org. Also you can report issues on a project's [issue tracker](https://github.com/konsoletyper/teavm/issues).
diff --git a/pom.xml b/pom.xml
index b2cdeb921..5fe03e8cd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
pom
TeaVM
@@ -66,7 +66,7 @@
UTF-8
https://oss.sonatype.org/content/repositories/snapshots/
- 0.9
+ 1.0
9.2.1.v20140609
1.7.7
@@ -120,7 +120,7 @@
org.ow2.asm
asm-debug-all
- 4.2
+ 5.0.3
org.apache.maven
@@ -192,6 +192,7 @@
protected
+ false
diff --git a/teavm-chrome-rdp/pom.xml b/teavm-chrome-rdp/pom.xml
index 2920df302..eadaab6a0 100644
--- a/teavm-chrome-rdp/pom.xml
+++ b/teavm-chrome-rdp/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-chrome-rdp
diff --git a/teavm-classlib/pom.xml b/teavm-classlib/pom.xml
index 947516eb9..ee7592aff 100644
--- a/teavm-classlib/pom.xml
+++ b/teavm-classlib/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-classlib
@@ -85,8 +85,6 @@
process-test-classes
false
- true
- true
en, en_US, en_GB, ru, ru_RU
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/impl/JCLPlugin.java b/teavm-classlib/src/main/java/org/teavm/classlib/impl/JCLPlugin.java
index 4f13a986d..4d3d853bb 100644
--- a/teavm-classlib/src/main/java/org/teavm/classlib/impl/JCLPlugin.java
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/impl/JCLPlugin.java
@@ -15,10 +15,9 @@
*/
package org.teavm.classlib.impl;
+import java.util.ServiceLoader;
import org.teavm.classlib.impl.unicode.CLDRReader;
-import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodReference;
-import org.teavm.model.ValueType;
import org.teavm.vm.spi.TeaVMHost;
import org.teavm.vm.spi.TeaVMPlugin;
@@ -36,9 +35,8 @@ public class JCLPlugin implements TeaVMPlugin {
host.add(new ObjectEnrichRenderer());
ServiceLoaderSupport serviceLoaderSupp = new ServiceLoaderSupport(host.getClassLoader());
host.add(serviceLoaderSupp);
- MethodReference loadServicesMethod = new MethodReference("java.util.ServiceLoader", new MethodDescriptor(
- "loadServices", ValueType.object("java.lang.Class"),
- ValueType.arrayOf(ValueType.object("java.lang.Object"))));
+ MethodReference loadServicesMethod = new MethodReference(ServiceLoader.class, "loadServices",
+ Class.class, Object[].class);
host.add(loadServicesMethod, serviceLoaderSupp);
JavacSupport javacSupport = new JavacSupport();
host.add(javacSupport);
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java b/teavm-classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java
index 6510d90c6..3e96d4208 100644
--- a/teavm-classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java
@@ -47,7 +47,7 @@ public class ServiceLoaderSupport implements Generator, DependencyListener {
public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException {
writer.append("if (!").appendClass("java.util.ServiceLoader").append(".$$services$$) {").indent()
.softNewLine();
- writer.appendClass("java.util.ServiceLoader").append("$$services$$ = true;").softNewLine();
+ writer.appendClass("java.util.ServiceLoader").append(".$$services$$ = true;").softNewLine();
for (Map.Entry> entry : serviceMap.entrySet()) {
writer.appendClass(entry.getKey()).append(".$$serviceList$$ = [");
List implementations = entry.getValue();
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TString.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TString.java
index b636dac46..a11ed0585 100644
--- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TString.java
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TString.java
@@ -162,6 +162,18 @@ public class TString extends TObject implements TSerializable, TComparable length() || ooffset + len > other.length()) {
+ return false;
+ }
+ for (int i = 0; i < len; ++i) {
+ char a = charAt(toffset++);
+ char b = other.charAt(ooffset++);
+ if (ignoreCase) {
+ a = TCharacter.toLowerCase(a);
+ b = TCharacter.toLowerCase(b);
+ }
+ if (a != b) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public boolean regionMatches(int toffset, TString other, int ooffset, int len) {
if (toffset < 0 || ooffset < 0 || toffset + len > length() || ooffset + len > other.length()) {
return false;
@@ -626,4 +656,12 @@ public class TString extends TObject implements TSerializable, TComparable
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-cli
diff --git a/teavm-core/pom.xml b/teavm-core/pom.xml
index e9185a16c..330d08ecc 100644
--- a/teavm-core/pom.xml
+++ b/teavm-core/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-core
diff --git a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java
index 06c351f80..db467814f 100644
--- a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java
+++ b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java
@@ -245,7 +245,7 @@ public class Decompiler {
if (node >= 0) {
generator.currentBlock = program.basicBlockAt(node);
int tmp = indexer.nodeAt(next);
- generator.nextBlock = next < indexer.size() ? program.basicBlockAt(tmp) : null;
+ generator.nextBlock = tmp >= 0 && next < indexer.size() ? program.basicBlockAt(tmp) : null;
generator.statements.clear();
InstructionLocation lastLocation = null;
NodeLocation nodeLocation = null;
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 eebdb2261..a7c2f917b 100644
--- a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java
+++ b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java
@@ -164,11 +164,11 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
}
private void renderRuntimeCls() throws IOException {
- writer.append("$rt_cls").ws().append("=").ws().append("function(clsProto)").ws().append("{")
+ writer.append("function $rt_cls").ws().append("(clsProto)").ws().append("{")
.indent().softNewLine();
String classClass = "java.lang.Class";
writer.append("var cls").ws().append("=").ws().append("clsProto.classObject;").softNewLine();
- writer.append("if").ws().append("(cls").ws().append("===").ws().append("undefined)").ws()
+ writer.append("if").ws().append("(typeof cls").ws().append("===").ws().append("'undefined')").ws()
.append("{").softNewLine().indent();
MethodReference createMethodRef = new MethodReference(classClass, "createNew", ValueType.object(classClass));
writer.append("cls").ws().append("=").ws().appendMethodBody(createMethodRef).append("();").softNewLine();
@@ -199,10 +199,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
}
private void renderRuntimeString() throws IOException {
- String stringClass = "java.lang.String";
- MethodReference stringCons = new MethodReference(stringClass, "",
- ValueType.arrayOf(ValueType.CHARACTER), ValueType.VOID);
- writer.append("$rt_str = function(str) {").indent().softNewLine();
+ MethodReference stringCons = new MethodReference(String.class, "", char[].class, void.class);
+ writer.append("function $rt_str(str) {").indent().softNewLine();
writer.append("var characters = $rt_createCharArray(str.length);").softNewLine();
writer.append("var charsBuffer = characters.data;").softNewLine();
writer.append("for (var i = 0; i < str.length; i = (i + 1) | 0) {").indent().softNewLine();
@@ -214,11 +212,10 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
}
private void renderRuntimeUnwrapString() throws IOException {
- String stringClass = "java.lang.String";
- MethodReference stringLen = new MethodReference(stringClass, "length", ValueType.INTEGER);
- MethodReference getChars = new MethodReference(stringClass, "getChars", ValueType.INTEGER, ValueType.INTEGER,
- ValueType.arrayOf(ValueType.CHARACTER), ValueType.INTEGER, ValueType.VOID);
- writer.append("$rt_ustr = function(str) {").indent().softNewLine();
+ MethodReference stringLen = new MethodReference(String.class, "length", int.class);
+ MethodReference getChars = new MethodReference(String.class, "getChars", int.class, int.class,
+ char[].class, int.class, void.class);
+ writer.append("function $rt_ustr(str) {").indent().softNewLine();
writer.append("var result = \"\";").softNewLine();
writer.append("var sz = ").appendMethodBody(stringLen).append("(str);").softNewLine();
writer.append("var array = $rt_createCharArray(sz);").softNewLine();
@@ -232,7 +229,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
private void renderRuntimeNullCheck() throws IOException {
String npe = "java.lang.NullPointerException";
- writer.append("$rt_nullCheck = function(val) {").indent().softNewLine();
+ writer.append("function $rt_nullCheck(val) {").indent().softNewLine();
writer.append("if (val === null) {").indent().softNewLine();
writer.append("$rt_throw(").appendClass(npe).append('.').appendMethod(npe, "", ValueType.VOID)
.append("());").softNewLine();
@@ -242,14 +239,14 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
}
private void renderRuntimeIntern() throws IOException {
- writer.append("$rt_intern = function(str) {").indent().softNewLine();
+ writer.append("function $rt_intern(str) {").indent().softNewLine();
writer.append("return ").appendMethodBody(new MethodReference(String.class, "intern", String.class))
.append("(str);").softNewLine();
writer.outdent().append("}").newLine();
}
private void renderRuntimeObjcls() throws IOException {
- writer.append("$rt_objcls = function() { return ").appendClass("java.lang.Object").append("; }").newLine();
+ writer.append("function $rt_objcls() { return ").appendClass("java.lang.Object").append("; }").newLine();
}
public void render(ClassNode cls) throws RenderingException {
@@ -543,16 +540,23 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
for (int var : method.getVariables()) {
variableCount = Math.max(variableCount, var + 1);
}
- boolean hasVars = variableCount > ref.parameterCount() + 1;
- if (hasVars) {
+ TryCatchFinder tryCatchFinder = new TryCatchFinder();
+ method.getBody().acceptVisitor(tryCatchFinder);
+ boolean hasTryCatch = tryCatchFinder.tryCatchFound;
+ List variableNames = new ArrayList<>();
+ for (int i = ref.parameterCount() + 1; i < variableCount; ++i) {
+ variableNames.add(variableName(i));
+ }
+ if (hasTryCatch) {
+ variableNames.add("$je");
+ }
+ if (!variableNames.isEmpty()) {
writer.append("var ");
- boolean first = true;
- for (int i = ref.parameterCount() + 1; i < variableCount; ++i) {
- if (!first) {
+ for (int i = 0; i < variableNames.size(); ++i) {
+ if (i > 0) {
writer.append(",").ws();
}
- first = false;
- writer.append(variableName(i));
+ writer.append(variableNames.get(i));
}
writer.append(";").softNewLine();
}
@@ -1252,6 +1256,12 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
if (c < ' ') {
sb.append("\\u00").append(Character.forDigit(c / 16, 16))
.append(Character.forDigit(c % 16, 16));
+ } else if (Character.isLowSurrogate(c) || Character.isHighSurrogate(c)) {
+ sb.append("\\u")
+ .append(Character.forDigit(c / 0x1000, 0x10))
+ .append(Character.forDigit((c / 0x100) % 0x10, 0x10))
+ .append(Character.forDigit((c / 0x10) % 0x10, 0x10))
+ .append(Character.forDigit(c % 0x10, 0x10));
} else {
sb.append(c);
}
diff --git a/teavm-core/src/main/java/org/teavm/javascript/TryCatchFinder.java b/teavm-core/src/main/java/org/teavm/javascript/TryCatchFinder.java
new file mode 100644
index 000000000..1c53f647f
--- /dev/null
+++ b/teavm-core/src/main/java/org/teavm/javascript/TryCatchFinder.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2014 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.javascript;
+
+import java.util.List;
+import org.teavm.javascript.ast.*;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+class TryCatchFinder implements StatementVisitor {
+ public boolean tryCatchFound;
+
+ @Override
+ public void visit(AssignmentStatement statement) {
+ }
+
+ private void visitSequence(List statements) {
+ if (tryCatchFound) {
+ return;
+ }
+ for (Statement statement : statements) {
+ statement.acceptVisitor(this);
+ if (tryCatchFound) {
+ return;
+ }
+ }
+ }
+
+ @Override
+ public void visit(SequentialStatement statement) {
+ if (tryCatchFound) {
+ return;
+ }
+ visitSequence(statement.getSequence());
+ }
+
+ @Override
+ public void visit(ConditionalStatement statement) {
+ if (tryCatchFound) {
+ return;
+ }
+ visitSequence(statement.getConsequent());
+ visitSequence(statement.getAlternative());
+ }
+
+ @Override
+ public void visit(SwitchStatement statement) {
+ if (tryCatchFound) {
+ return;
+ }
+ for (SwitchClause clause : statement.getClauses()) {
+ visitSequence(clause.getBody());
+ if (tryCatchFound) {
+ return;
+ }
+ }
+ visitSequence(statement.getDefaultClause());
+ }
+
+ @Override
+ public void visit(WhileStatement statement) {
+ if (!tryCatchFound) {
+ visitSequence(statement.getBody());
+ }
+ }
+
+ @Override
+ public void visit(BlockStatement statement) {
+ if (!tryCatchFound) {
+ visitSequence(statement.getBody());
+ }
+ }
+
+ @Override
+ public void visit(BreakStatement statement) {
+ }
+
+ @Override
+ public void visit(ContinueStatement statement) {
+ }
+
+ @Override
+ public void visit(ReturnStatement statement) {
+ }
+
+ @Override
+ public void visit(ThrowStatement statement) {
+ }
+
+ @Override
+ public void visit(InitClassStatement statement) {
+ }
+
+ @Override
+ public void visit(TryCatchStatement statement) {
+ tryCatchFound = true;
+ }
+}
diff --git a/teavm-core/src/main/java/org/teavm/model/util/InterferenceGraphBuilder.java b/teavm-core/src/main/java/org/teavm/model/util/InterferenceGraphBuilder.java
index e39480eaf..1ef421e12 100644
--- a/teavm-core/src/main/java/org/teavm/model/util/InterferenceGraphBuilder.java
+++ b/teavm-core/src/main/java/org/teavm/model/util/InterferenceGraphBuilder.java
@@ -41,6 +41,9 @@ class InterferenceGraphBuilder {
for (BasicBlock succ : succExtractor.getTargets()) {
liveOut.or(liveness.liveIn(succ.getIndex()));
}
+ for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) {
+ liveOut.or(liveness.liveIn(tryCatch.getHandler().getIndex()));
+ }
live.clear();
for (int j = 0; j < liveOut.length(); ++j) {
if (liveOut.get(j)) {
diff --git a/teavm-core/src/main/java/org/teavm/model/util/ProgramUtils.java b/teavm-core/src/main/java/org/teavm/model/util/ProgramUtils.java
index 6acc9c20c..e3ca78d8e 100644
--- a/teavm-core/src/main/java/org/teavm/model/util/ProgramUtils.java
+++ b/teavm-core/src/main/java/org/teavm/model/util/ProgramUtils.java
@@ -29,7 +29,7 @@ public final class ProgramUtils {
private ProgramUtils() {
}
- public static Graph buildControlFlowGraphWithoutTryCatch(Program program) {
+ public static Graph buildControlFlowGraph(Program program) {
GraphBuilder graphBuilder = new GraphBuilder(program.basicBlockCount());
InstructionTransitionExtractor transitionExtractor = new InstructionTransitionExtractor();
for (int i = 0; i < program.basicBlockCount(); ++i) {
@@ -43,11 +43,14 @@ public final class ProgramUtils {
}
}
}
+ for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) {
+ graphBuilder.addEdge(i, tryCatch.getHandler().getIndex());
+ }
}
return graphBuilder.build();
}
- public static Graph buildControlFlowGraph(Program program) {
+ public static Graph buildControlFlowGraphWithTryCatch(Program program) {
GraphBuilder graphBuilder = new GraphBuilder(program.basicBlockCount());
InstructionTransitionExtractor transitionExtractor = new InstructionTransitionExtractor();
for (int i = 0; i < program.basicBlockCount(); ++i) {
@@ -58,6 +61,9 @@ public final class ProgramUtils {
if (transitionExtractor.getTargets() != null) {
for (BasicBlock successor : transitionExtractor.getTargets()) {
graphBuilder.addEdge(i, successor.getIndex());
+ for (TryCatchBlock succTryCatch : successor.getTryCatchBlocks()) {
+ graphBuilder.addEdge(i, succTryCatch.getHandler().getIndex());
+ }
}
}
}
diff --git a/teavm-core/src/main/java/org/teavm/parsing/SSATransformer.java b/teavm-core/src/main/java/org/teavm/parsing/SSATransformer.java
index c61f74869..1060d5beb 100644
--- a/teavm-core/src/main/java/org/teavm/parsing/SSATransformer.java
+++ b/teavm-core/src/main/java/org/teavm/parsing/SSATransformer.java
@@ -49,7 +49,7 @@ public class SSATransformer {
this.variableDebugInfo = variableDebugInfo;
this.arguments = arguments;
variableDebugMap.clear();
- cfg = ProgramUtils.buildControlFlowGraphWithoutTryCatch(program);
+ cfg = ProgramUtils.buildControlFlowGraphWithTryCatch(program);
domTree = GraphUtils.buildDominatorTree(cfg);
domFrontiers = new int[cfg.size()][];
variableMap = new Variable[program.variableCount()];
diff --git a/teavm-core/src/main/java/org/teavm/vm/TeaVM.java b/teavm-core/src/main/java/org/teavm/vm/TeaVM.java
index 74dbfc46f..812a78191 100644
--- a/teavm-core/src/main/java/org/teavm/vm/TeaVM.java
+++ b/teavm-core/src/main/java/org/teavm/vm/TeaVM.java
@@ -54,7 +54,7 @@ import org.teavm.vm.spi.TeaVMPlugin;
*vm.setMinifying(false); // optionally disable obfuscation
*vm.installPlugins(); // install all default plugins
* // that are found in a classpath
- *vm.addEntryPoint("main", new MethodReference(
+ *vm.entryPoint("main", new MethodReference(
* "fully.qualified.ClassName", "main",
* ValueType.array(ValueType.object("java.lang.String")),
* ValueType.VOID));
@@ -437,6 +437,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
for (RendererListener listener : rendererListeners) {
listener.begin(renderer, target);
}
+ sourceWriter.append("\"use strict\";").newLine();
renderer.renderRuntime();
for (ClassNode clsNode : clsNodes) {
ClassReader cls = classSet.get(clsNode.getName());
@@ -450,12 +451,12 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
}
renderer.renderStringPool();
for (Map.Entry entry : entryPoints.entrySet()) {
- sourceWriter.append(entry.getKey()).ws().append("=").ws().appendMethodBody(entry.getValue().reference)
- .append(";").softNewLine();
+ sourceWriter.append("var ").append(entry.getKey()).ws().append("=").ws()
+ .appendMethodBody(entry.getValue().reference).append(";").softNewLine();
}
for (Map.Entry entry : exportedClasses.entrySet()) {
- sourceWriter.append(entry.getKey()).ws().append("=").ws().appendClass(entry.getValue()).append(";")
- .softNewLine();
+ sourceWriter.append("var ").append(entry.getKey()).ws().append("=").ws()
+ .appendClass(entry.getValue()).append(";").softNewLine();
}
for (RendererListener listener : rendererListeners) {
listener.complete();
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 9b7a826b8..9b5300490 100644
--- a/teavm-core/src/main/resources/org/teavm/javascript/runtime.js
+++ b/teavm-core/src/main/resources/org/teavm/javascript/runtime.js
@@ -13,17 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-$rt_lastObjectId = 0;
-$rt_nextId = function() {
+"use strict";
+var $rt_lastObjectId = 0;
+function $rt_nextId() {
return $rt_lastObjectId++;
}
-$rt_compare = function(a, b) {
+function $rt_compare(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
}
-$rt_isInstance = function(obj, cls) {
+function $rt_isInstance(obj, cls) {
return obj !== null && !!obj.constructor.$meta && $rt_isAssignable(obj.constructor, cls);
}
-$rt_isAssignable = function(from, to) {
+function $rt_isAssignable(from, to) {
if (from === to) {
return true;
}
@@ -35,7 +36,7 @@ $rt_isAssignable = function(from, to) {
}
return false;
}
-$rt_createArray = function(cls, sz) {
+function $rt_createArray(cls, sz) {
var data = new Array(sz);
var arr = new ($rt_arraycls(cls))(data);
for (var i = 0; i < sz; i = (i + 1) | 0) {
@@ -43,14 +44,14 @@ $rt_createArray = function(cls, sz) {
}
return arr;
}
-$rt_wrapArray = function(cls, data) {
+function $rt_wrapArray(cls, data) {
var arr = new ($rt_arraycls(cls))(data);
return arr;
}
-$rt_createUnfilledArray = function(cls, sz) {
+function $rt_createUnfilledArray(cls, sz) {
return new ($rt_arraycls(cls))(new Array(sz));
}
-$rt_createLongArray = function(sz) {
+function $rt_createLongArray(sz) {
var data = new Array(sz);
var arr = new ($rt_arraycls($rt_longcls()))(data);
for (var i = 0; i < sz; i = (i + 1) | 0) {
@@ -58,10 +59,21 @@ $rt_createLongArray = function(sz) {
}
return arr;
}
+var $rt_createNumericArray;
+var $rt_createCharArray;
+var $rt_createByteArray;
+var $rt_createShortArray;
+var $rt_createIntArray;
+var $rt_createBooleanArray;
+var $rt_createFloatArray;
+var $rt_createDoubleArray;
if (ArrayBuffer) {
$rt_createNumericArray = function(cls, nativeArray) {
return new ($rt_arraycls(cls))(nativeArray);
- }
+ };
+ $rt_createCharArray = function(sz) {
+ return $rt_createNumericArray($rt_charcls(), new Uint16Array(new ArrayBuffer(sz << 1)), 0);
+ };
$rt_createByteArray = function(sz) {
return $rt_createNumericArray($rt_bytecls(), new Int8Array(new ArrayBuffer(sz)), 0);
};
@@ -80,17 +92,14 @@ if (ArrayBuffer) {
$rt_createDoubleArray = function(sz) {
return $rt_createNumericArray($rt_doublecls(), new Float64Array(new ArrayBuffer(sz << 3)), 0);
};
- $rt_createCharArray = function(sz) {
- return $rt_createNumericArray($rt_charcls(), new Uint16Array(new ArrayBuffer(sz << 1)), 0);
- };
} else {
$rt_createNumericArray = function(cls, sz) {
- var data = new Array(sz);
- var arr = new ($rt_arraycls(cls))(data);
- for (var i = 0; i < sz; i = (i + 1) | 0) {
- data[i] = 0;
- }
- return arr;
+ var data = new Array(sz);
+ var arr = new ($rt_arraycls(cls))(data);
+ for (var i = 0; i < sz; i = (i + 1) | 0) {
+ data[i] = 0;
+ }
+ return arr;
}
$rt_createByteArray = function(sz) { return $rt_createNumericArray($rt_bytecls(), sz); }
$rt_createShortArray = function(sz) { return $rt_createNumericArray($rt_shortcls(), sz); }
@@ -100,8 +109,8 @@ if (ArrayBuffer) {
$rt_createDoubleArray = function(sz) { return $rt_createNumericArray($rt_doublecls(), sz); }
$rt_createCharArray = function(sz) { return $rt_createNumericArray($rt_charcls(), sz); }
}
-$rt_arraycls = function(cls) {
- if (cls.$array == undefined) {
+function $rt_arraycls(cls) {
+ if (typeof cls.$array === 'undefined') {
var arraycls = function(data) {
this.data = data;
this.$id = $rt_nextId();
@@ -124,51 +133,51 @@ $rt_arraycls = function(cls) {
}
return cls.$array;
}
-$rt_createcls = function() {
+function $rt_createcls() {
return {
$meta : {
supertypes : []
}
};
}
-$rt_booleanclsCache = null;
-$rt_booleancls = function() {
- if ($rt_booleanclsCache == null) {
+var $rt_booleanclsCache = null;
+function $rt_booleancls() {
+ if ($rt_booleanclsCache === null) {
$rt_booleanclsCache = $rt_createcls();
$rt_booleanclsCache.primitive = true;
$rt_booleanclsCache.name = "boolean";
}
return $rt_booleanclsCache;
}
-$rt_charclsCache = null;
-$rt_charcls = function() {
- if ($rt_charclsCache == null) {
+var $rt_charclsCache = null;
+function $rt_charcls() {
+ if ($rt_charclsCache === null) {
$rt_charclsCache = $rt_createcls();
$rt_charclsCache.primitive = true;
$rt_charclsCache.name = "char";
}
return $rt_charclsCache;
}
-$rt_byteclsCache = null;
-$rt_bytecls = function() {
- if ($rt_byteclsCache == null) {
+var $rt_byteclsCache = null;
+function $rt_bytecls() {
+ if ($rt_byteclsCache === null) {
$rt_byteclsCache = $rt_createcls();
$rt_byteclsCache.primitive = true;
$rt_byteclsCache.name = "byte";
}
return $rt_byteclsCache;
}
-$rt_shortclsCache = null;
-$rt_shortcls = function() {
- if ($rt_shortclsCache == null) {
+var $rt_shortclsCache = null;
+function $rt_shortcls() {
+ if ($rt_shortclsCache === null) {
$rt_shortclsCache = $rt_createcls();
$rt_shortclsCache.primitive = true;
$rt_shortclsCache.name = "short";
}
return $rt_shortclsCache;
}
-$rt_intclsCache = null;
-$rt_intcls = function() {
+var $rt_intclsCache = null;
+function $rt_intcls() {
if ($rt_intclsCache === null) {
$rt_intclsCache = $rt_createcls();
$rt_intclsCache.primitive = true;
@@ -176,8 +185,8 @@ $rt_intcls = function() {
}
return $rt_intclsCache;
}
-$rt_longclsCache = null;
-$rt_longcls = function() {
+var $rt_longclsCache = null;
+function $rt_longcls() {
if ($rt_longclsCache === null) {
$rt_longclsCache = $rt_createcls();
$rt_longclsCache.primitive = true;
@@ -185,8 +194,8 @@ $rt_longcls = function() {
}
return $rt_longclsCache;
}
-$rt_floatclsCache = null;
-$rt_floatcls = function() {
+var $rt_floatclsCache = null;
+function $rt_floatcls() {
if ($rt_floatclsCache === null) {
$rt_floatclsCache = $rt_createcls();
$rt_floatclsCache.primitive = true;
@@ -194,8 +203,8 @@ $rt_floatcls = function() {
}
return $rt_floatclsCache;
}
-$rt_doubleclsCache = null;
-$rt_doublecls = function() {
+var $rt_doubleclsCache = null;
+function $rt_doublecls() {
if ($rt_doubleclsCache === null) {
$rt_doubleclsCache = $rt_createcls();
$rt_doubleclsCache.primitive = true;
@@ -203,8 +212,8 @@ $rt_doublecls = function() {
}
return $rt_doubleclsCache;
}
-$rt_voidclsCache = null;
-$rt_voidcls = function() {
+var $rt_voidclsCache = null;
+function $rt_voidcls() {
if ($rt_voidclsCache === null) {
$rt_voidclsCache = $rt_createcls();
$rt_voidclsCache.primitive = true;
@@ -212,7 +221,7 @@ $rt_voidcls = function() {
}
return $rt_voidclsCache;
}
-$rt_clinit = function(cls) {
+function $rt_clinit(cls) {
if (cls.$clinit) {
var f = cls.$clinit;
delete cls.$clinit;
@@ -220,12 +229,12 @@ $rt_clinit = function(cls) {
}
return cls;
}
-$rt_init = function(cls, constructor, args) {
+function $rt_init(cls, constructor, args) {
var obj = new cls();
cls.prototype[constructor].apply(obj, args);
return obj;
}
-$rt_throw = function(ex) {
+function $rt_throw(ex) {
var err = ex.$jsException;
if (!err) {
var err = new Error("Java exception thrown");
@@ -234,7 +243,7 @@ $rt_throw = function(ex) {
}
throw err;
}
-$rt_createMultiArray = function(cls, dimensions) {
+function $rt_createMultiArray(cls, dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 0) {
@@ -242,7 +251,7 @@ $rt_createMultiArray = function(cls, dimensions) {
}
return $rt_createMultiArrayImpl(cls, arrays, dimensions);
}
-$rt_createByteMultiArray = function(dimensions) {
+function $rt_createByteMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 0) {
@@ -250,7 +259,7 @@ $rt_createByteMultiArray = function(dimensions) {
}
return $rt_createMultiArrayImpl($rt_bytecls(), arrays, dimensions);
}
-$rt_createBooleanMultiArray = function(dimensions) {
+function $rt_createBooleanMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 0) {
@@ -258,7 +267,7 @@ $rt_createBooleanMultiArray = function(dimensions) {
}
return $rt_createMultiArrayImpl($rt_booleancls(), arrays, dimensions);
}
-$rt_createShortMultiArray = function(dimensions) {
+function $rt_createShortMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 0) {
@@ -266,7 +275,7 @@ $rt_createShortMultiArray = function(dimensions) {
}
return $rt_createMultiArrayImpl($rt_shortcls(), arrays, dimensions);
}
-$rt_createIntMultiArray = function(dimensions) {
+function $rt_createIntMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 0) {
@@ -274,7 +283,7 @@ $rt_createIntMultiArray = function(dimensions) {
}
return $rt_createMultiArrayImpl($rt_intcls(), arrays, dimensions);
}
-$rt_createLongMultiArray = function(dimensions) {
+function $rt_createLongMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 0) {
@@ -282,7 +291,7 @@ $rt_createLongMultiArray = function(dimensions) {
}
return $rt_createMultiArrayImpl($rt_longcls(), arrays, dimensions);
}
-$rt_createFloatMultiArray = function(dimensions) {
+function $rt_createFloatMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 0) {
@@ -290,7 +299,7 @@ $rt_createFloatMultiArray = function(dimensions) {
}
return $rt_createMultiArrayImpl($rt_floatcls(), arrays, dimensions);
}
-$rt_createDoubleMultiArray = function(dimensions) {
+function $rt_createDoubleMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 0) {
@@ -298,14 +307,14 @@ $rt_createDoubleMultiArray = function(dimensions) {
}
return $rt_createMultiArrayImpl($rt_doublecls(), arrays, dimensions);
}
-$rt_primitiveArrayCount = function(dimensions) {
+function $rt_primitiveArrayCount(dimensions) {
var val = dimensions[1] | 0;
for (var i = 2 | 0; i < dimensions.length; i = (i + 1) | 0) {
val = (val * (dimensions[i] | 0)) | 0;
}
return val;
}
-$rt_createMultiArrayImpl = function(cls, arrays, dimensions) {
+function $rt_createMultiArrayImpl(cls, arrays, dimensions) {
var limit = arrays.length;
for (var i = 1 | 0; i < dimensions.length; i = (i + 1) | 0) {
cls = $rt_arraycls(cls);
@@ -325,13 +334,13 @@ $rt_createMultiArrayImpl = function(cls, arrays, dimensions) {
}
return arrays[0];
}
-$rt_assertNotNaN = function(value) {
- if (typeof value == 'number' && isNaN(value)) {
+function $rt_assertNotNaN(value) {
+ if (typeof value === 'number' && isNaN(value)) {
throw "NaN";
}
return value;
}
-$rt_methodStubs = function(clinit, names) {
+function $rt_methodStubs(clinit, names) {
for (var i = 0; i < names.length; i = (i + 1) | 0) {
window[names[i]] = (function(name) {
return function() {
@@ -341,9 +350,9 @@ $rt_methodStubs = function(clinit, names) {
})(names[i]);
}
}
-$rt_stdoutBuffer = "";
-$rt_putStdout = function(ch) {
- if (ch === 0xA) {
+var $rt_stdoutBuffer = "";
+function $rt_putStdout(ch) {
+ if (ch == 0xA) {
if (console) {
console.info($rt_stdoutBuffer);
}
@@ -352,9 +361,9 @@ $rt_putStdout = function(ch) {
$rt_stdoutBuffer += String.fromCharCode(ch);
}
}
-$rt_stderrBuffer = "";
-$rt_putStderr = function(ch) {
- if (ch === 0xA) {
+var $rt_stderrBuffer = "";
+function $rt_putStderr(ch) {
+ if (ch == 0xA) {
if (console) {
console.info($rt_stderrBuffer);
}
@@ -364,7 +373,6 @@ $rt_putStderr = function(ch) {
}
}
function $rt_declClass(cls, data) {
- cls.name = data.name;
cls.$meta = {};
cls.$meta.superclass = data.superclass;
cls.$meta.supertypes = data.interfaces ? data.interfaces.slice() : [];
@@ -383,7 +391,7 @@ function $rt_virtualMethods(cls) {
for (var i = 1; i < arguments.length; i += 2) {
var name = arguments[i];
var func = arguments[i + 1];
- if (typeof name == 'string') {
+ if (typeof name === 'string') {
cls.prototype[name] = func;
} else {
for (var j = 0; j < name.length; ++j) {
@@ -392,6 +400,7 @@ function $rt_virtualMethods(cls) {
}
}
}
+var $rt_stringPool_instance;
function $rt_stringPool(strings) {
$rt_stringPool_instance = new Array(strings.length);
for (var i = 0; i < strings.length; ++i) {
@@ -441,7 +450,7 @@ function $dbg_class(obj) {
return clsName;
}
-Long = function(lo, hi) {
+function Long(lo, hi) {
this.lo = lo | 0;
this.hi = hi | 0;
}
@@ -461,18 +470,18 @@ Long.prototype.toString = function() {
result = result.reverse().join('');
return positive ? result : "-" + result;
}
-Long_ZERO = new Long(0, 0);
-Long_fromInt = function(val) {
+var Long_ZERO = new Long(0, 0);
+function Long_fromInt(val) {
return val >= 0 ? new Long(val, 0) : new Long(val, -1);
}
-Long_fromNumber = function(val) {
+function Long_fromNumber(val) {
if (val >= 0) {
return new Long(val | 0, (val / 0x100000000) | 0);
} else {
return new Long(val | 0, (-(Math.abs(val) / 0x100000000) - 1) | 0);
}
}
-Long_toNumber = function(val) {
+function Long_toNumber(val) {
var lo = val.lo;
var hi = val.hi;
if (lo < 0) {
@@ -480,7 +489,7 @@ Long_toNumber = function(val) {
}
return 0x100000000 * hi + lo;
}
-Long_add = function(a, b) {
+function Long_add(a, b) {
var a_lolo = a.lo & 0xFFFF;
var a_lohi = a.lo >>> 16;
var a_hilo = a.hi & 0xFFFF;
@@ -496,7 +505,7 @@ Long_add = function(a, b) {
var hihi = (a_hihi + b_hihi + (hilo >> 16)) | 0;
return new Long((lolo & 0xFFFF) | ((lohi & 0xFFFF) << 16), (hilo & 0xFFFF) | ((hihi & 0xFFFF) << 16));
}
-Long_inc = function(a) {
+function Long_inc(a) {
var lo = (a.lo + 1) | 0;
var hi = a.hi;
if (lo === 0) {
@@ -504,7 +513,7 @@ Long_inc = function(a) {
}
return new Long(lo, hi);
}
-Long_dec = function(a) {
+function Long_dec(a) {
var lo = (a.lo - 1) | 0;
var hi = a.hi;
if (lo === -1) {
@@ -512,10 +521,10 @@ Long_dec = function(a) {
}
return new Long(lo, hi);
}
-Long_neg = function(a) {
+function Long_neg(a) {
return Long_inc(new Long(a.lo ^ 0xFFFFFFFF, a.hi ^ 0xFFFFFFFF));
}
-Long_sub = function(a, b) {
+function Long_sub(a, b) {
var a_lolo = a.lo & 0xFFFF;
var a_lohi = a.lo >>> 16;
var a_hilo = a.hi & 0xFFFF;
@@ -531,7 +540,7 @@ Long_sub = function(a, b) {
var hihi = (a_hihi - b_hihi + (hilo >> 16)) | 0;
return new Long((lolo & 0xFFFF) | ((lohi & 0xFFFF) << 16), (hilo & 0xFFFF) | ((hihi & 0xFFFF) << 16));
}
-Long_compare = function(a, b) {
+function Long_compare(a, b) {
var r = a.hi - b.hi;
if (r !== 0) {
return r;
@@ -542,13 +551,13 @@ Long_compare = function(a, b) {
}
return (a.lo & 1) - (b.lo & 1);
}
-Long_isPositive = function(a) {
+function Long_isPositive(a) {
return (a.hi & 0x80000000) === 0;
}
-Long_isNegative = function(a) {
+function Long_isNegative(a) {
return (a.hi & 0x80000000) !== 0;
}
-Long_mul = function(a, b) {
+function Long_mul(a, b) {
var positive = Long_isNegative(a) === Long_isNegative(b);
if (Long_isNegative(a)) {
a = Long_neg(a);
@@ -586,13 +595,13 @@ Long_mul = function(a, b) {
var result = new Long((lolo & 0xFFFF) | (lohi << 16), (hilo & 0xFFFF) | (hihi << 16));
return positive ? result : Long_neg(result);
}
-Long_div = function(a, b) {
+function Long_div(a, b) {
return Long_divRem(a, b)[0];
}
-Long_rem = function(a, b) {
+function Long_rem(a, b) {
return Long_divRem(a, b)[1];
}
-Long_divRem = function(a, b) {
+function Long_divRem(a, b) {
var positive = Long_isNegative(a) === Long_isNegative(b);
if (Long_isNegative(a)) {
a = Long_neg(a);
@@ -607,22 +616,22 @@ Long_divRem = function(a, b) {
q = new Long(q.lo, q.hi);
return positive ? [q, a] : [Long_neg(q), Long_neg(a)];
}
-Long_shiftLeft16 = function(a) {
+function Long_shiftLeft16(a) {
return new Long(a.lo << 16, (a.lo >>> 16) | (a.hi << 16));
}
-Long_shiftRight16 = function(a) {
+function Long_shiftRight16(a) {
return new Long((a.lo >>> 16) | (a.hi << 16), a.hi >>> 16);
}
-Long_and = function(a, b) {
+function Long_and(a, b) {
return new Long(a.lo & b.lo, a.hi & b.hi);
}
-Long_or = function(a, b) {
+function Long_or(a, b) {
return new Long(a.lo | b.lo, a.hi | b.hi);
}
-Long_xor = function(a, b) {
+function Long_xor(a, b) {
return new Long(a.lo ^ b.lo, a.hi ^ b.hi);
}
-Long_shl = function(a, b) {
+function Long_shl(a, b) {
b &= 63;
if (b == 0) {
return a;
@@ -634,7 +643,7 @@ Long_shl = function(a, b) {
return new Long(0, a.lo << (b - 32));
}
}
-Long_shr = function(a, b) {
+function Long_shr(a, b) {
b &= 63;
if (b == 0) {
return a;
@@ -646,7 +655,7 @@ Long_shr = function(a, b) {
return new Long((a.hi >> (b - 32)), a.hi >> 31);
}
}
-Long_shru = function(a, b) {
+function Long_shru(a, b) {
b &= 63;
if (b == 0) {
return a;
@@ -660,12 +669,12 @@ Long_shru = function(a, b) {
}
// Represents a mutable 80-bit unsigned integer
-LongInt = function(lo, hi, sup) {
+function LongInt(lo, hi, sup) {
this.lo = lo;
this.hi = hi;
this.sup = sup;
}
-LongInt_mul = function(a, b) {
+function LongInt_mul(a, b) {
var a_lolo = ((a.lo & 0xFFFF) * b) | 0;
var a_lohi = ((a.lo >>> 16) * b) | 0;
var a_hilo = ((a.hi & 0xFFFF) * b) | 0;
@@ -680,7 +689,7 @@ LongInt_mul = function(a, b) {
a.hi = (a_hilo & 0xFFFF) | (a_hihi << 16);
a.sup = sup & 0xFFFF;
}
-LongInt_sub = function(a, b) {
+function LongInt_sub(a, b) {
var a_lolo = a.lo & 0xFFFF;
var a_lohi = a.lo >>> 16;
var a_hilo = a.hi & 0xFFFF;
@@ -694,12 +703,12 @@ LongInt_sub = function(a, b) {
a_lohi = (a_lohi - b_lohi + (a_lolo >> 16)) | 0;
a_hilo = (a_hilo - b_hilo + (a_lohi >> 16)) | 0;
a_hihi = (a_hihi - b_hihi + (a_hilo >> 16)) | 0;
- sup = (a.sup - b.sup + (a_hihi >> 16)) | 0;
+ var sup = (a.sup - b.sup + (a_hihi >> 16)) | 0;
a.lo = (a_lolo & 0xFFFF) | (a_lohi << 16);
a.hi = (a_hilo & 0xFFFF) | (a_hihi << 16);
a.sup = sup;
}
-LongInt_add = function(a, b) {
+function LongInt_add(a, b) {
var a_lolo = a.lo & 0xFFFF;
var a_lohi = a.lo >>> 16;
var a_hilo = a.hi & 0xFFFF;
@@ -713,12 +722,12 @@ LongInt_add = function(a, b) {
a_lohi = (a_lohi + b_lohi + (a_lolo >> 16)) | 0;
a_hilo = (a_hilo + b_hilo + (a_lohi >> 16)) | 0;
a_hihi = (a_hihi + b_hihi + (a_hilo >> 16)) | 0;
- sup = (a.sup + b.sup + (a_hihi >> 16)) | 0;
+ var sup = (a.sup + b.sup + (a_hihi >> 16)) | 0;
a.lo = (a_lolo & 0xFFFF) | (a_lohi << 16);
a.hi = (a_hilo & 0xFFFF) | (a_hihi << 16);
a.sup = sup;
}
-LongInt_inc = function(a) {
+function LongInt_inc(a) {
a.lo = (a.lo + 1) | 0;
if (a.lo == 0) {
a.hi = (a.hi + 1) | 0;
@@ -727,7 +736,7 @@ LongInt_inc = function(a) {
}
}
}
-LongInt_dec = function(a) {
+function LongInt_dec(a) {
a.lo = (a.lo - 1) | 0;
if (a.lo == -1) {
a.hi = (a.hi - 1) | 0;
@@ -736,7 +745,7 @@ LongInt_dec = function(a) {
}
}
}
-LongInt_ucompare = function(a, b) {
+function LongInt_ucompare(a, b) {
var r = (a.sup - b.sup);
if (r != 0) {
return r;
@@ -755,7 +764,7 @@ LongInt_ucompare = function(a, b) {
}
return (a.lo & 1) - (b.lo & 1);
}
-LongInt_numOfLeadingZeroBits = function(a) {
+function LongInt_numOfLeadingZeroBits(a) {
var n = 0;
var d = 16;
while (d > 0) {
@@ -767,14 +776,14 @@ LongInt_numOfLeadingZeroBits = function(a) {
}
return 31 - n;
}
-LongInt_shl = function(a, b) {
- if (b === 0) {
+function LongInt_shl(a, b) {
+ if (b == 0) {
return;
} else if (b < 32) {
a.sup = ((a.hi >>> (32 - b)) | (a.sup << b)) & 0xFFFF;
a.hi = (a.lo >>> (32 - b)) | (a.hi << b);
a.lo <<= b;
- } else if (b === 32) {
+ } else if (b == 32) {
a.sup = a.hi & 0xFFFF;
a.hi = a.lo;
a.lo = 0;
@@ -782,7 +791,7 @@ LongInt_shl = function(a, b) {
a.sup = ((a.lo >>> (64 - b)) | (a.hi << (b - 32))) & 0xFFFF;
a.hi = a.lo << b;
a.lo = 0;
- } else if (b === 64) {
+ } else if (b == 64) {
a.sup = a.lo & 0xFFFF;
a.hi = 0;
a.lo = 0;
@@ -792,10 +801,10 @@ LongInt_shl = function(a, b) {
a.lo = 0;
}
}
-LongInt_shr = function(a, b) {
- if (b === 0) {
+function LongInt_shr(a, b) {
+ if (b == 0) {
return;
- } else if (b === 32) {
+ } else if (b == 32) {
a.lo = a.hi;
a.hi = a.sup;
a.sup = 0;
@@ -803,7 +812,7 @@ LongInt_shr = function(a, b) {
a.lo = (a.lo >>> b) | (a.hi << (32 - b));
a.hi = (a.hi >>> b) | (a.sup << (32 - b));
a.sup >>>= b;
- } else if (b === 64) {
+ } else if (b == 64) {
a.lo = a.sup;
a.hi = 0;
a.sup = 0;
@@ -817,17 +826,17 @@ LongInt_shr = function(a, b) {
a.sup = 0;
}
}
-LongInt_copy = function(a) {
+function LongInt_copy(a) {
return new LongInt(a.lo, a.hi, a.sup);
}
-LongInt_div = function(a, b) {
+function LongInt_div(a, b) {
// Normalize divisor
var bits = b.hi !== 0 ? LongInt_numOfLeadingZeroBits(b.hi) : LongInt_numOfLeadingZeroBits(b.lo) + 32;
var sz = 1 + ((bits / 16) | 0);
var dividentBits = bits % 16;
LongInt_shl(b, bits);
LongInt_shl(a, dividentBits);
- q = new LongInt(0, 0, 0);
+ var q = new LongInt(0, 0, 0);
while (sz-- > 0) {
LongInt_shl(q, 16);
// Calculate approximate q
diff --git a/teavm-dom/pom.xml b/teavm-dom/pom.xml
index 1970229e3..ae58d1524 100644
--- a/teavm-dom/pom.xml
+++ b/teavm-dom/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-dom
diff --git a/teavm-eclipse/pom.xml b/teavm-eclipse/pom.xml
index a07bf89cb..d9c63a149 100644
--- a/teavm-eclipse/pom.xml
+++ b/teavm-eclipse/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-eclipse
pom
diff --git a/teavm-eclipse/teavm-eclipse-core-plugin/META-INF/MANIFEST.MF b/teavm-eclipse/teavm-eclipse-core-plugin/META-INF/MANIFEST.MF
index abf0c56d2..dba35773e 100644
--- a/teavm-eclipse/teavm-eclipse-core-plugin/META-INF/MANIFEST.MF
+++ b/teavm-eclipse/teavm-eclipse-core-plugin/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: TeaVM plugin for Eclipse
Bundle-SymbolicName: teavm-eclipse-core-plugin;singleton:=true
-Bundle-Version: 0.2.0.qualifer
+Bundle-Version: 0.3.0.qualifer
Bundle-Vendor: Alexey Andreev
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: .,
@@ -40,8 +40,8 @@ Bundle-ClassPath: .,
lib/org.apache.aries.spifly.weaver-internal-1.0.1.jar,
lib/org.apache.aries.util-1.0.0.jar,
lib/slf4j-api-1.7.7.jar,
- lib/teavm-chrome-rdp-0.2-SNAPSHOT.jar,
- lib/teavm-core-0.2-SNAPSHOT.jar,
+ lib/teavm-chrome-rdp-0.3.0-SNAPSHOT.jar,
+ lib/teavm-core-0.3.0-SNAPSHOT.jar,
lib/websocket-api-9.2.1.v20140609.jar,
lib/websocket-client-9.2.1.v20140609.jar,
lib/websocket-common-9.2.1.v20140609.jar,
diff --git a/teavm-eclipse/teavm-eclipse-core-plugin/build.properties b/teavm-eclipse/teavm-eclipse-core-plugin/build.properties
index e41e7c47c..253bf8f08 100644
--- a/teavm-eclipse/teavm-eclipse-core-plugin/build.properties
+++ b/teavm-eclipse/teavm-eclipse-core-plugin/build.properties
@@ -37,8 +37,8 @@ bin.includes = META-INF/,\
lib/org.apache.aries.spifly.weaver-internal-1.0.1.jar,\
lib/org.apache.aries.util-1.0.0.jar,\
lib/slf4j-api-1.7.7.jar,\
- lib/teavm-chrome-rdp-0.2-SNAPSHOT.jar,\
- lib/teavm-core-0.2-SNAPSHOT.jar,\
+ lib/teavm-chrome-rdp-0.3.0-SNAPSHOT.jar,\
+ lib/teavm-core-0.3.0-SNAPSHOT.jar,\
lib/websocket-api-9.2.1.v20140609.jar,\
lib/websocket-client-9.2.1.v20140609.jar,\
lib/websocket-common-9.2.1.v20140609.jar,\
diff --git a/teavm-eclipse/teavm-eclipse-core-plugin/dep-pom.xml b/teavm-eclipse/teavm-eclipse-core-plugin/dep-pom.xml
index f38cf9659..7d15d8482 100644
--- a/teavm-eclipse/teavm-eclipse-core-plugin/dep-pom.xml
+++ b/teavm-eclipse/teavm-eclipse-core-plugin/dep-pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
../..
teavm-eclipse-core-deps
diff --git a/teavm-eclipse/teavm-eclipse-core-plugin/pom.xml b/teavm-eclipse/teavm-eclipse-core-plugin/pom.xml
index 4fb101900..9b8ceffbf 100644
--- a/teavm-eclipse/teavm-eclipse-core-plugin/pom.xml
+++ b/teavm-eclipse/teavm-eclipse-core-plugin/pom.xml
@@ -20,10 +20,9 @@
org.teavm
teavm-eclipse
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-eclipse-core-plugin
- 0.2.0-SNAPSHOT
eclipse-plugin
TeaVM core packages for Eclipse
diff --git a/teavm-eclipse/teavm-eclipse-feature/feature.xml b/teavm-eclipse/teavm-eclipse-feature/feature.xml
index f5b2cb237..e214241ae 100644
--- a/teavm-eclipse/teavm-eclipse-feature/feature.xml
+++ b/teavm-eclipse/teavm-eclipse-feature/feature.xml
@@ -2,7 +2,7 @@
diff --git a/teavm-eclipse/teavm-eclipse-feature/pom.xml b/teavm-eclipse/teavm-eclipse-feature/pom.xml
index a40434345..7a5ec77d6 100644
--- a/teavm-eclipse/teavm-eclipse-feature/pom.xml
+++ b/teavm-eclipse/teavm-eclipse-feature/pom.xml
@@ -21,10 +21,9 @@
org.teavm
teavm-eclipse
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-eclipse-feature
- 0.2.0-SNAPSHOT
eclipse-feature
diff --git a/teavm-eclipse/teavm-eclipse-m2e-feature/feature.xml b/teavm-eclipse/teavm-eclipse-m2e-feature/feature.xml
index 3d9b7b606..30c08f07f 100644
--- a/teavm-eclipse/teavm-eclipse-m2e-feature/feature.xml
+++ b/teavm-eclipse/teavm-eclipse-m2e-feature/feature.xml
@@ -2,7 +2,7 @@
@@ -230,7 +230,7 @@
-
+
org.teavm
teavm-eclipse
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-eclipse-m2e-feature
- 0.2.0-SNAPSHOT
eclipse-feature
diff --git a/teavm-eclipse/teavm-eclipse-m2e-plugin/META-INF/MANIFEST.MF b/teavm-eclipse/teavm-eclipse-m2e-plugin/META-INF/MANIFEST.MF
index 84eab2029..2f64d783a 100644
--- a/teavm-eclipse/teavm-eclipse-m2e-plugin/META-INF/MANIFEST.MF
+++ b/teavm-eclipse/teavm-eclipse-m2e-plugin/META-INF/MANIFEST.MF
@@ -2,10 +2,10 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: TeaVM plugin for m2e
Bundle-SymbolicName: teavm-eclipse-m2e-plugin;singleton:=true
-Bundle-Version: 0.2.0.qualifier
+Bundle-Version: 0.3.0.qualifier
Bundle-Vendor: Alexey Andreev
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Require-Bundle: teavm-eclipse-plugin;bundle-version="[0.2,0.3)",
+Require-Bundle: teavm-eclipse-plugin;bundle-version="[0.3.0,0.4.0)",
org.eclipse.m2e.core;bundle-version="[1.3,2)",
org.eclipse.core.runtime;bundle-version="[3.8,4.0)",
org.eclipse.m2e.maven.runtime;bundle-version="[1.3,2)",
diff --git a/teavm-eclipse/teavm-eclipse-m2e-plugin/lifecycle-mapping-metadata.xml b/teavm-eclipse/teavm-eclipse-m2e-plugin/lifecycle-mapping-metadata.xml
index 141c937e7..928092661 100644
--- a/teavm-eclipse/teavm-eclipse-m2e-plugin/lifecycle-mapping-metadata.xml
+++ b/teavm-eclipse/teavm-eclipse-m2e-plugin/lifecycle-mapping-metadata.xml
@@ -5,7 +5,7 @@
org.teavm
teavm-maven-plugin
- 0.2.0-SNAPSHOT
+ 0.3.0-SNAPSHOT
build-javascript
diff --git a/teavm-eclipse/teavm-eclipse-m2e-plugin/pom.xml b/teavm-eclipse/teavm-eclipse-m2e-plugin/pom.xml
index 1c8bf7d05..bbdbfed2c 100644
--- a/teavm-eclipse/teavm-eclipse-m2e-plugin/pom.xml
+++ b/teavm-eclipse/teavm-eclipse-m2e-plugin/pom.xml
@@ -21,10 +21,9 @@
org.teavm
teavm-eclipse
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-eclipse-m2e-plugin
- 0.2.0-SNAPSHOT
eclipse-plugin
diff --git a/teavm-eclipse/teavm-eclipse-m2e-plugin/src/main/java/org/teavm/eclipse/m2e/TeaVMProjectConfigurator.java b/teavm-eclipse/teavm-eclipse-m2e-plugin/src/main/java/org/teavm/eclipse/m2e/TeaVMProjectConfigurator.java
index 49d9c9df2..cfb3076c5 100644
--- a/teavm-eclipse/teavm-eclipse-m2e-plugin/src/main/java/org/teavm/eclipse/m2e/TeaVMProjectConfigurator.java
+++ b/teavm-eclipse/teavm-eclipse-m2e-plugin/src/main/java/org/teavm/eclipse/m2e/TeaVMProjectConfigurator.java
@@ -1,5 +1,6 @@
package org.teavm.eclipse.m2e;
+import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
@@ -57,8 +58,11 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
}
monitor.beginTask("Configuring TeaVM builder", sz * 1000);
TeaVMProjectSettings settings = teaVMPlugin.getSettings(project);
- settings.load();
try {
+ if (!hasNature) {
+ teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
+ }
+ settings.load();
Set coveredProfiles = new HashSet<>();
for (MojoExecution execution : executions) {
if (monitor.isCanceled()) {
@@ -82,9 +86,6 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
settings.deleteProfile(profile);
}
}
- if (!hasNature) {
- teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
- }
settings.save();
} finally {
monitor.done();
@@ -179,24 +180,20 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
}
private String absolutePathToWorkspacePath(String path) {
- try {
- IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IContainer[] containers = root.findContainersForLocationURI(new URI("file://" + path));
- if (containers.length == 0) {
- return null;
- }
- IContainer container = containers[0];
- String suffix = "";
- while (!(container instanceof IProject)) {
- suffix = "/" + container.getName() + suffix;
- container = container.getParent();
- }
- path = container.getFullPath().toString();
- return varManager.generateVariableExpression("workspace_loc", path) + suffix;
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
+ IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IContainer[] containers = root.findContainersForLocationURI(new File(path).toURI());
+ if (containers.length == 0) {
+ return null;
}
+ IContainer container = containers[0];
+ String suffix = "";
+ while (!(container instanceof IProject)) {
+ suffix = "/" + container.getName() + suffix;
+ container = container.getParent();
+ }
+ path = container.getFullPath().toString();
+ return varManager.generateVariableExpression("workspace_loc", path) + suffix;
}
private TeaVMRuntimeMode getRuntimeMode(String name) {
diff --git a/teavm-eclipse/teavm-eclipse-plugin/META-INF/MANIFEST.MF b/teavm-eclipse/teavm-eclipse-plugin/META-INF/MANIFEST.MF
index 0cc159647..cf89a7d99 100644
--- a/teavm-eclipse/teavm-eclipse-plugin/META-INF/MANIFEST.MF
+++ b/teavm-eclipse/teavm-eclipse-plugin/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: TeaVM plugin for Eclipse
Bundle-SymbolicName: teavm-eclipse-plugin;singleton:=true
-Bundle-Version: 0.2.0.qualifer
+Bundle-Version: 0.3.0.qualifer
Bundle-Vendor: Alexey Andreev
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Activator: org.teavm.eclipse.TeaVMEclipsePlugin
@@ -22,6 +22,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0)",
org.eclipse.core.variables;bundle-version="[3.2.600,4)",
org.eclipse.core.databinding.observable;bundle-version="[1.4.1,2)",
org.eclipse.jface.databinding;bundle-version="[1.6.0,2)",
- teavm-eclipse-core-plugin;bundle-version="0.2.0"
+ teavm-eclipse-core-plugin;bundle-version="0.3.0"
Export-Package: org.teavm.eclipse.debugger,org.teavm.eclipse
Bundle-ActivationPolicy: lazy
diff --git a/teavm-eclipse/teavm-eclipse-plugin/pom.xml b/teavm-eclipse/teavm-eclipse-plugin/pom.xml
index ac5a0331d..39779e83a 100644
--- a/teavm-eclipse/teavm-eclipse-plugin/pom.xml
+++ b/teavm-eclipse/teavm-eclipse-plugin/pom.xml
@@ -21,10 +21,9 @@
org.teavm
teavm-eclipse
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-eclipse-plugin
- 0.2.0-SNAPSHOT
eclipse-plugin
diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java
index b9537bdab..eba86cd1f 100644
--- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java
+++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java
@@ -53,8 +53,11 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
private String projectName;
public PreferencesBasedTeaVMProjectSettings(IProject project) {
- ProjectScope scope = new ProjectScope(project);
- globalPreferences = scope.getNode(TeaVMEclipsePlugin.ID);
+ this(project, new ProjectScope(project).getNode(TeaVMEclipsePlugin.ID));
+ }
+
+ public PreferencesBasedTeaVMProjectSettings(IProject project, IEclipsePreferences preferences) {
+ globalPreferences = preferences;
projectName = project.getName();
}
diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMEclipsePlugin.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMEclipsePlugin.java
index 6a7ca4852..9e2074a6a 100644
--- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMEclipsePlugin.java
+++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMEclipsePlugin.java
@@ -16,18 +16,21 @@
package org.teavm.eclipse;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
+import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.service.prefs.BackingStoreException;
/**
*
@@ -90,6 +93,14 @@ public class TeaVMEclipsePlugin extends AbstractUIPlugin {
}
public void addNature(IProgressMonitor progressMonitor, IProject project) throws CoreException {
+ ProjectScope scope = new ProjectScope(project);
+ try {
+ IEclipsePreferences prefs = scope.getNode(TeaVMEclipsePlugin.ID);
+ prefs.flush();
+ settingsMap.put(project, new PreferencesBasedTeaVMProjectSettings(project, prefs));
+ } catch (BackingStoreException e) {
+ throw new RuntimeException("Error creating preferences", e);
+ }
IProjectDescription projectDescription = project.getDescription();
String[] natureIds = projectDescription.getNatureIds();
natureIds = Arrays.copyOf(natureIds, natureIds.length + 1);
diff --git a/teavm-eclipse/teavm-eclipse-updatesite/category.xml b/teavm-eclipse/teavm-eclipse-updatesite/category.xml
index c93989af7..564c1f863 100644
--- a/teavm-eclipse/teavm-eclipse-updatesite/category.xml
+++ b/teavm-eclipse/teavm-eclipse-updatesite/category.xml
@@ -1,11 +1,11 @@
-
+
-
+
diff --git a/teavm-eclipse/teavm-eclipse-updatesite/pom.xml b/teavm-eclipse/teavm-eclipse-updatesite/pom.xml
index fa69636e5..310e0956f 100644
--- a/teavm-eclipse/teavm-eclipse-updatesite/pom.xml
+++ b/teavm-eclipse/teavm-eclipse-updatesite/pom.xml
@@ -21,10 +21,10 @@
org.teavm
teavm-eclipse
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-eclipse-updatesite
- 0.2.0-SNAPSHOT
+
eclipse-repository
diff --git a/teavm-eclipse/teavm-eclipse-updatesite/site.xml b/teavm-eclipse/teavm-eclipse-updatesite/site.xml
index 370f369b0..f464a0420 100644
--- a/teavm-eclipse/teavm-eclipse-updatesite/site.xml
+++ b/teavm-eclipse/teavm-eclipse-updatesite/site.xml
@@ -3,10 +3,10 @@
TeaVM update site
-
+
-
+
diff --git a/teavm-html4j/pom.xml b/teavm-html4j/pom.xml
index bf777cb34..64f1472d9 100644
--- a/teavm-html4j/pom.xml
+++ b/teavm-html4j/pom.xml
@@ -19,7 +19,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-html4j
diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java
index a4939ea46..d8787da89 100644
--- a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java
+++ b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java
@@ -138,7 +138,7 @@ public class JavaScriptBodyDependency implements DependencyListener {
if (!methodDep.isMissing()) {
if (reader.hasModifier(ElementModifier.STATIC) || reader.hasModifier(ElementModifier.FINAL)) {
methodDep.use();
- for (int i = 0; i <= methodDep.getParameterCount(); ++i) {
+ for (int i = 0; i < methodDep.getParameterCount(); ++i) {
allClassesNode.connect(methodDep.getVariable(i));
}
} else {
diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyGenerator.java b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyGenerator.java
index 917acaafc..50fb1e828 100644
--- a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyGenerator.java
+++ b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyGenerator.java
@@ -85,9 +85,15 @@ public class JavaScriptBodyGenerator implements Generator {
MethodDescriptor desc = MethodDescriptor.parse(method + params + "V");
MethodReader reader = findMethod(fqn, desc);
StringBuilder sb = new StringBuilder();
- sb.append("(function($this");
+ sb.append("(function(");
+ if (ident != null) {
+ sb.append("$this");
+ }
for (int i = 0; i < reader.parameterCount(); ++i) {
- sb.append(", ").append("p").append(i);
+ if (ident != null || i > 0) {
+ sb.append(", ");
+ }
+ sb.append("p").append(i);
}
sb.append(") { return ").append(naming.getFullNameFor(JavaScriptConvGenerator.toJsMethod)).append("(");
if (ident == null) {
@@ -105,7 +111,9 @@ public class JavaScriptBodyGenerator implements Generator {
.append(Renderer.typeToClsString(naming, reader.parameterType(i))).append(")");
}
sb.append(")); })(");
- sb.append(ident == null ? "null" : ident);
+ if (ident != null) {
+ sb.append(ident);
+ }
return sb.toString();
}
private MethodReader findMethod(String clsName, MethodDescriptor desc) {
diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptConvGenerator.java b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptConvGenerator.java
index e68d243ed..5a9743509 100644
--- a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptConvGenerator.java
+++ b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptConvGenerator.java
@@ -26,28 +26,22 @@ import org.teavm.model.*;
* @author Alexey Andreev
*/
public class JavaScriptConvGenerator implements Generator {
- private static final String convCls = JavaScriptConv.class.getName();
- static final MethodReference intValueMethod = new MethodReference("java.lang.Integer",
- new MethodDescriptor("intValue", ValueType.INTEGER));
- static final MethodReference booleanValueMethod = new MethodReference("java.lang.Boolean",
- new MethodDescriptor("booleanValue", ValueType.BOOLEAN));
- static final MethodReference doubleValueMethod = new MethodReference("java.lang.Double",
- new MethodDescriptor("doubleValue", ValueType.DOUBLE));
- static final MethodReference charValueMethod = new MethodReference("java.lang.Character",
- new MethodDescriptor("charValue", ValueType.CHARACTER));
- static final MethodReference valueOfIntMethod = new MethodReference("java.lang.Integer",
- new MethodDescriptor("valueOf", ValueType.INTEGER, ValueType.object("java.lang.Integer")));
- static final MethodReference valueOfBooleanMethod = new MethodReference("java.lang.Boolean",
- new MethodDescriptor("valueOf", ValueType.BOOLEAN, ValueType.object("java.lang.Boolean")));
- static final MethodReference valueOfDoubleMethod = new MethodReference("java.lang.Double",
- new MethodDescriptor("valueOf", ValueType.DOUBLE, ValueType.object("java.lang.Double")));
- static final MethodReference valueOfCharMethod = new MethodReference("java.lang.Character",
- new MethodDescriptor("valueOf", ValueType.CHARACTER, ValueType.object("java.lang.Character")));
- private static final ValueType objType = ValueType.object("java.lang.Object");
- static final MethodReference toJsMethod = new MethodReference(convCls, new MethodDescriptor(
- "toJavaScript", objType, objType));
- static final MethodReference fromJsMethod = new MethodReference(convCls, new MethodDescriptor(
- "fromJavaScript", objType, objType, objType));
+ static final MethodReference intValueMethod = new MethodReference(Integer.class, "intValue", int.class);
+ static final MethodReference booleanValueMethod = new MethodReference(Boolean.class, "booleanValue", boolean.class);
+ static final MethodReference doubleValueMethod = new MethodReference(Double.class, "doubleValue", double.class);
+ static final MethodReference charValueMethod = new MethodReference(Character.class, "charValue", char.class);
+ static final MethodReference valueOfIntMethod = new MethodReference(Integer.class, "valueOf",
+ int.class, Integer.class);
+ static final MethodReference valueOfBooleanMethod = new MethodReference(Boolean.class, "valueOf",
+ boolean.class, Boolean.class);
+ static final MethodReference valueOfDoubleMethod = new MethodReference(Double.class, "valueOf",
+ double.class, Double.class);
+ static final MethodReference valueOfCharMethod = new MethodReference(Character.class, "valueOf",
+ char.class, Character.class);
+ static final MethodReference toJsMethod = new MethodReference(JavaScriptConv.class, "toJavaScript",
+ Object.class, Object.class);
+ static final MethodReference fromJsMethod = new MethodReference(JavaScriptConv.class, "fromJavaScript",
+ Object.class, Object.class, Object.class);
@Override
public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException {
diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/JsCallback.java b/teavm-html4j/src/main/java/org/teavm/html4j/JsCallback.java
index 2ca89f7cf..45ff283bc 100644
--- a/teavm-html4j/src/main/java/org/teavm/html4j/JsCallback.java
+++ b/teavm-html4j/src/main/java/org/teavm/html4j/JsCallback.java
@@ -107,7 +107,7 @@ abstract class JsCallback {
}
sb.append(callMethod(refId, fqn, method, params));
- if (body.charAt(paramBeg + 1) != (')')) {
+ if (body.charAt(paramBeg + 1) != ')') {
sb.append(",");
}
pos = paramBeg + 1;
diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/testing/KOTestAdapter.java b/teavm-html4j/src/main/java/org/teavm/html4j/testing/KOTestAdapter.java
index d684ec611..60f874e97 100644
--- a/teavm-html4j/src/main/java/org/teavm/html4j/testing/KOTestAdapter.java
+++ b/teavm-html4j/src/main/java/org/teavm/html4j/testing/KOTestAdapter.java
@@ -18,7 +18,7 @@ package org.teavm.html4j.testing;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Collections;
-import org.apidesign.html.json.tck.KOTest;
+import org.netbeans.html.json.tck.KOTest;
import org.teavm.model.MethodReader;
import org.teavm.testing.TestAdapter;
diff --git a/teavm-html4j/src/test/java/org/teavm/html4j/test/KnockoutFXTest.java b/teavm-html4j/src/test/java/org/teavm/html4j/test/KnockoutFXTest.java
index 11b29035e..f2d2d1547 100644
--- a/teavm-html4j/src/test/java/org/teavm/html4j/test/KnockoutFXTest.java
+++ b/teavm-html4j/src/test/java/org/teavm/html4j/test/KnockoutFXTest.java
@@ -51,12 +51,12 @@ import java.util.HashMap;
import java.util.Map;
import net.java.html.BrwsrCtx;
import net.java.html.js.JavaScriptBody;
-import org.apidesign.html.boot.spi.Fn;
-import org.apidesign.html.context.spi.Contexts;
-import org.apidesign.html.json.spi.JSONCall;
-import org.apidesign.html.json.spi.Technology;
-import org.apidesign.html.json.spi.Transfer;
-import org.apidesign.html.json.tck.KnockoutTCK;
+import org.netbeans.html.boot.spi.Fn;
+import org.netbeans.html.context.spi.Contexts;
+import org.netbeans.html.json.spi.JSONCall;
+import org.netbeans.html.json.spi.Technology;
+import org.netbeans.html.json.spi.Transfer;
+import org.netbeans.html.json.tck.KnockoutTCK;
import org.netbeans.html.ko4j.KO4J;
import org.testng.Assert;
diff --git a/teavm-html4j/src/test/resources/META-INF/services/org.apidesign.html.json.tck.KnockoutTCK b/teavm-html4j/src/test/resources/META-INF/services/org.netbeans.html.json.tck.KnockoutTCK
similarity index 100%
rename from teavm-html4j/src/test/resources/META-INF/services/org.apidesign.html.json.tck.KnockoutTCK
rename to teavm-html4j/src/test/resources/META-INF/services/org.netbeans.html.json.tck.KnockoutTCK
diff --git a/teavm-jso/pom.xml b/teavm-jso/pom.xml
index ec7159c83..5e7e7a986 100644
--- a/teavm-jso/pom.xml
+++ b/teavm-jso/pom.xml
@@ -20,7 +20,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-jso
diff --git a/teavm-maven/pom.xml b/teavm-maven/pom.xml
index fd4fd7e55..ca27b6a53 100644
--- a/teavm-maven/pom.xml
+++ b/teavm-maven/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-maven
diff --git a/teavm-maven/teavm-maven-plugin/pom.xml b/teavm-maven/teavm-maven-plugin/pom.xml
index f689cc002..d7682a086 100644
--- a/teavm-maven/teavm-maven-plugin/pom.xml
+++ b/teavm-maven/teavm-maven-plugin/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm-maven
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-maven-plugin
maven-plugin
diff --git a/teavm-maven/teavm-maven-webapp/pom.xml b/teavm-maven/teavm-maven-webapp/pom.xml
index 1a03701cc..d444170eb 100644
--- a/teavm-maven/teavm-maven-webapp/pom.xml
+++ b/teavm-maven/teavm-maven-webapp/pom.xml
@@ -1,4 +1,3 @@
-
4.0.0
@@ -6,7 +5,7 @@
org.teavm
teavm-maven
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-maven-webapp
TeaVM maven web application archetype
diff --git a/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml b/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml
index 936c60dcd..e6a5199c7 100644
--- a/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml
+++ b/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml
@@ -9,7 +9,7 @@
1.7
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
UTF-8
@@ -19,6 +19,7 @@
org.teavm
teavm-classlib
${teavm.version}
+ provided
@@ -26,6 +27,7 @@
org.teavm
teavm-jso
${teavm.version}
+ provided
@@ -33,6 +35,7 @@
org.teavm
teavm-dom
${teavm.version}
+ provided
diff --git a/teavm-platform/pom.xml b/teavm-platform/pom.xml
index 0405a6cbb..9388726fa 100644
--- a/teavm-platform/pom.xml
+++ b/teavm-platform/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-platform
diff --git a/teavm-platform/src/main/java/org/teavm/platform/plugin/MetadataProviderNativeGenerator.java b/teavm-platform/src/main/java/org/teavm/platform/plugin/MetadataProviderNativeGenerator.java
index da0dd8740..6ddda44ca 100644
--- a/teavm-platform/src/main/java/org/teavm/platform/plugin/MetadataProviderNativeGenerator.java
+++ b/teavm-platform/src/main/java/org/teavm/platform/plugin/MetadataProviderNativeGenerator.java
@@ -77,7 +77,7 @@ public class MetadataProviderNativeGenerator implements Generator {
Resource resource = generator.generateMetadata(metadataContext, methodRef);
writer.append("if (!window.hasOwnProperty(\"").appendMethodBody(methodRef).append("$$resource\")) {")
.indent().softNewLine();
- writer.appendMethodBody(methodRef).append("$$resource = ");
+ writer.append("window.").appendMethodBody(methodRef).append("$$resource = ");
ResourceWriterHelper.write(writer, resource);
writer.append(';').softNewLine();
writer.outdent().append('}').softNewLine();
diff --git a/teavm-samples/pom.xml b/teavm-samples/pom.xml
index 8b607bec3..1b9dc40c4 100644
--- a/teavm-samples/pom.xml
+++ b/teavm-samples/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-samples
diff --git a/teavm-samples/teavm-samples-benchmark/pom.xml b/teavm-samples/teavm-samples-benchmark/pom.xml
index 369f784ba..4afc765b3 100644
--- a/teavm-samples/teavm-samples-benchmark/pom.xml
+++ b/teavm-samples/teavm-samples-benchmark/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm-samples
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-samples-benchmark
war
@@ -91,7 +91,7 @@
${project.build.directory}/generated/js/teavm
org.teavm.samples.benchmark.teavm.BenchmarkStarter
SEPARATE
- true
+ false
true
diff --git a/teavm-samples/teavm-samples-hello/pom.xml b/teavm-samples/teavm-samples-hello/pom.xml
index d1183f430..6bdababac 100644
--- a/teavm-samples/teavm-samples-hello/pom.xml
+++ b/teavm-samples/teavm-samples-hello/pom.xml
@@ -20,7 +20,7 @@
org.teavm
teavm-samples
- 0.2-SNAPSHOT
+ 0.3.0-SNAPSHOT
teavm-samples-hello