Merge branch 'master' into nio

This commit is contained in:
konsoletyper 2014-10-25 12:40:40 +04:00
commit ae9e38efd4
51 changed files with 397 additions and 258 deletions

View File

@ -55,6 +55,9 @@ Live examples
Compare the speed of JavaScript produced by TeaVM and GWT here: http://teavm.org/live-examples/jbox2d-benchmark/ 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 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. 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 You can try its TeaVM-compiled version [here](http://xelfi.cz/minesweeper/teavm/), and then take a look at

View File

@ -20,7 +20,7 @@
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>TeaVM</name> <name>TeaVM</name>
@ -66,7 +66,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonatypeOssDistMgmtSnapshotsUrl>https://oss.sonatype.org/content/repositories/snapshots/</sonatypeOssDistMgmtSnapshotsUrl> <sonatypeOssDistMgmtSnapshotsUrl>https://oss.sonatype.org/content/repositories/snapshots/</sonatypeOssDistMgmtSnapshotsUrl>
<html4j.version>0.9</html4j.version> <html4j.version>1.0</html4j.version>
<jetty.version>9.2.1.v20140609</jetty.version> <jetty.version>9.2.1.v20140609</jetty.version>
<slf4j.version>1.7.7</slf4j.version> <slf4j.version>1.7.7</slf4j.version>
</properties> </properties>
@ -120,7 +120,7 @@
<dependency> <dependency>
<groupId>org.ow2.asm</groupId> <groupId>org.ow2.asm</groupId>
<artifactId>asm-debug-all</artifactId> <artifactId>asm-debug-all</artifactId>
<version>4.2</version> <version>5.0.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
@ -192,6 +192,7 @@
</executions> </executions>
<configuration> <configuration>
<show>protected</show> <show>protected</show>
<failOnError>false</failOnError>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-chrome-rdp</artifactId> <artifactId>teavm-chrome-rdp</artifactId>

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-classlib</artifactId> <artifactId>teavm-classlib</artifactId>

View File

@ -15,10 +15,9 @@
*/ */
package org.teavm.classlib.impl; package org.teavm.classlib.impl;
import java.util.ServiceLoader;
import org.teavm.classlib.impl.unicode.CLDRReader; import org.teavm.classlib.impl.unicode.CLDRReader;
import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.ValueType;
import org.teavm.vm.spi.TeaVMHost; import org.teavm.vm.spi.TeaVMHost;
import org.teavm.vm.spi.TeaVMPlugin; import org.teavm.vm.spi.TeaVMPlugin;
@ -36,9 +35,8 @@ public class JCLPlugin implements TeaVMPlugin {
host.add(new ObjectEnrichRenderer()); host.add(new ObjectEnrichRenderer());
ServiceLoaderSupport serviceLoaderSupp = new ServiceLoaderSupport(host.getClassLoader()); ServiceLoaderSupport serviceLoaderSupp = new ServiceLoaderSupport(host.getClassLoader());
host.add(serviceLoaderSupp); host.add(serviceLoaderSupp);
MethodReference loadServicesMethod = new MethodReference("java.util.ServiceLoader", new MethodDescriptor( MethodReference loadServicesMethod = new MethodReference(ServiceLoader.class, "loadServices",
"loadServices", ValueType.object("java.lang.Class"), Class.class, Object[].class);
ValueType.arrayOf(ValueType.object("java.lang.Object"))));
host.add(loadServicesMethod, serviceLoaderSupp); host.add(loadServicesMethod, serviceLoaderSupp);
JavacSupport javacSupport = new JavacSupport(); JavacSupport javacSupport = new JavacSupport();
host.add(javacSupport); host.add(javacSupport);

View File

@ -47,7 +47,7 @@ public class ServiceLoaderSupport implements Generator, DependencyListener {
public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException { public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException {
writer.append("if (!").appendClass("java.util.ServiceLoader").append(".$$services$$) {").indent() writer.append("if (!").appendClass("java.util.ServiceLoader").append(".$$services$$) {").indent()
.softNewLine(); .softNewLine();
writer.appendClass("java.util.ServiceLoader").append("$$services$$ = true;").softNewLine(); writer.appendClass("java.util.ServiceLoader").append(".$$services$$ = true;").softNewLine();
for (Map.Entry<String, List<String>> entry : serviceMap.entrySet()) { for (Map.Entry<String, List<String>> entry : serviceMap.entrySet()) {
writer.appendClass(entry.getKey()).append(".$$serviceList$$ = ["); writer.appendClass(entry.getKey()).append(".$$serviceList$$ = [");
List<String> implementations = entry.getValue(); List<String> implementations = entry.getValue();

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-cli</artifactId> <artifactId>teavm-cli</artifactId>

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-core</artifactId> <artifactId>teavm-core</artifactId>

View File

@ -164,11 +164,11 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
} }
private void renderRuntimeCls() throws IOException { 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(); .indent().softNewLine();
String classClass = "java.lang.Class"; String classClass = "java.lang.Class";
writer.append("var cls").ws().append("=").ws().append("clsProto.classObject;").softNewLine(); 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(); .append("{").softNewLine().indent();
MethodReference createMethodRef = new MethodReference(classClass, "createNew", ValueType.object(classClass)); MethodReference createMethodRef = new MethodReference(classClass, "createNew", ValueType.object(classClass));
writer.append("cls").ws().append("=").ws().appendMethodBody(createMethodRef).append("();").softNewLine(); 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 { private void renderRuntimeString() throws IOException {
String stringClass = "java.lang.String"; MethodReference stringCons = new MethodReference(String.class, "<init>", char[].class, void.class);
MethodReference stringCons = new MethodReference(stringClass, "<init>", writer.append("function $rt_str(str) {").indent().softNewLine();
ValueType.arrayOf(ValueType.CHARACTER), ValueType.VOID);
writer.append("$rt_str = function(str) {").indent().softNewLine();
writer.append("var characters = $rt_createCharArray(str.length);").softNewLine(); writer.append("var characters = $rt_createCharArray(str.length);").softNewLine();
writer.append("var charsBuffer = characters.data;").softNewLine(); writer.append("var charsBuffer = characters.data;").softNewLine();
writer.append("for (var i = 0; i < str.length; i = (i + 1) | 0) {").indent().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 { private void renderRuntimeUnwrapString() throws IOException {
String stringClass = "java.lang.String"; MethodReference stringLen = new MethodReference(String.class, "length", int.class);
MethodReference stringLen = new MethodReference(stringClass, "length", ValueType.INTEGER); MethodReference getChars = new MethodReference(String.class, "getChars", int.class, int.class,
MethodReference getChars = new MethodReference(stringClass, "getChars", ValueType.INTEGER, ValueType.INTEGER, char[].class, int.class, void.class);
ValueType.arrayOf(ValueType.CHARACTER), ValueType.INTEGER, ValueType.VOID); writer.append("function $rt_ustr(str) {").indent().softNewLine();
writer.append("$rt_ustr = function(str) {").indent().softNewLine();
writer.append("var result = \"\";").softNewLine(); writer.append("var result = \"\";").softNewLine();
writer.append("var sz = ").appendMethodBody(stringLen).append("(str);").softNewLine(); writer.append("var sz = ").appendMethodBody(stringLen).append("(str);").softNewLine();
writer.append("var array = $rt_createCharArray(sz);").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 { private void renderRuntimeNullCheck() throws IOException {
String npe = "java.lang.NullPointerException"; 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("if (val === null) {").indent().softNewLine();
writer.append("$rt_throw(").appendClass(npe).append('.').appendMethod(npe, "<init>", ValueType.VOID) writer.append("$rt_throw(").appendClass(npe).append('.').appendMethod(npe, "<init>", ValueType.VOID)
.append("());").softNewLine(); .append("());").softNewLine();
@ -242,14 +239,14 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
} }
private void renderRuntimeIntern() throws IOException { 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)) writer.append("return ").appendMethodBody(new MethodReference(String.class, "intern", String.class))
.append("(str);").softNewLine(); .append("(str);").softNewLine();
writer.outdent().append("}").newLine(); writer.outdent().append("}").newLine();
} }
private void renderRuntimeObjcls() throws IOException { 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 { public void render(ClassNode cls) throws RenderingException {
@ -543,16 +540,23 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
for (int var : method.getVariables()) { for (int var : method.getVariables()) {
variableCount = Math.max(variableCount, var + 1); variableCount = Math.max(variableCount, var + 1);
} }
boolean hasVars = variableCount > ref.parameterCount() + 1; TryCatchFinder tryCatchFinder = new TryCatchFinder();
if (hasVars) { method.getBody().acceptVisitor(tryCatchFinder);
writer.append("var "); boolean hasTryCatch = tryCatchFinder.tryCatchFound;
boolean first = true; List<String> variableNames = new ArrayList<>();
for (int i = ref.parameterCount() + 1; i < variableCount; ++i) { for (int i = ref.parameterCount() + 1; i < variableCount; ++i) {
if (!first) { variableNames.add(variableName(i));
}
if (hasTryCatch) {
variableNames.add("$je");
}
if (!variableNames.isEmpty()) {
writer.append("var ");
for (int i = 0; i < variableNames.size(); ++i) {
if (i > 0) {
writer.append(",").ws(); writer.append(",").ws();
} }
first = false; writer.append(variableNames.get(i));
writer.append(variableName(i));
} }
writer.append(";").softNewLine(); writer.append(";").softNewLine();
} }

View File

@ -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 <konsoletyper@gmail.com>
*/
class TryCatchFinder implements StatementVisitor {
public boolean tryCatchFound;
@Override
public void visit(AssignmentStatement statement) {
}
private void visitSequence(List<Statement> 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;
}
}

View File

@ -54,7 +54,7 @@ import org.teavm.vm.spi.TeaVMPlugin;
*vm.setMinifying(false); // optionally disable obfuscation *vm.setMinifying(false); // optionally disable obfuscation
*vm.installPlugins(); // install all default plugins *vm.installPlugins(); // install all default plugins
* // that are found in a classpath * // that are found in a classpath
*vm.addEntryPoint("main", new MethodReference( *vm.entryPoint("main", new MethodReference(
* "fully.qualified.ClassName", "main", * "fully.qualified.ClassName", "main",
* ValueType.array(ValueType.object("java.lang.String")), * ValueType.array(ValueType.object("java.lang.String")),
* ValueType.VOID)); * ValueType.VOID));
@ -437,6 +437,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
for (RendererListener listener : rendererListeners) { for (RendererListener listener : rendererListeners) {
listener.begin(renderer, target); listener.begin(renderer, target);
} }
sourceWriter.append("\"use strict\";").newLine();
renderer.renderRuntime(); renderer.renderRuntime();
for (ClassNode clsNode : clsNodes) { for (ClassNode clsNode : clsNodes) {
ClassReader cls = classSet.get(clsNode.getName()); ClassReader cls = classSet.get(clsNode.getName());
@ -450,12 +451,12 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
} }
renderer.renderStringPool(); renderer.renderStringPool();
for (Map.Entry<String, TeaVMEntryPoint> entry : entryPoints.entrySet()) { for (Map.Entry<String, TeaVMEntryPoint> entry : entryPoints.entrySet()) {
sourceWriter.append(entry.getKey()).ws().append("=").ws().appendMethodBody(entry.getValue().reference) sourceWriter.append("var ").append(entry.getKey()).ws().append("=").ws()
.append(";").softNewLine(); .appendMethodBody(entry.getValue().reference).append(";").softNewLine();
} }
for (Map.Entry<String, String> entry : exportedClasses.entrySet()) { for (Map.Entry<String, String> entry : exportedClasses.entrySet()) {
sourceWriter.append(entry.getKey()).ws().append("=").ws().appendClass(entry.getValue()).append(";") sourceWriter.append("var ").append(entry.getKey()).ws().append("=").ws()
.softNewLine(); .appendClass(entry.getValue()).append(";").softNewLine();
} }
for (RendererListener listener : rendererListeners) { for (RendererListener listener : rendererListeners) {
listener.complete(); listener.complete();

View File

@ -13,17 +13,18 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
$rt_lastObjectId = 0; "use strict";
$rt_nextId = function() { var $rt_lastObjectId = 0;
function $rt_nextId() {
return $rt_lastObjectId++; return $rt_lastObjectId++;
} }
$rt_compare = function(a, b) { function $rt_compare(a, b) {
return a > b ? 1 : a < b ? -1 : 0; 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); return obj !== null && !!obj.constructor.$meta && $rt_isAssignable(obj.constructor, cls);
} }
$rt_isAssignable = function(from, to) { function $rt_isAssignable(from, to) {
if (from === to) { if (from === to) {
return true; return true;
} }
@ -35,7 +36,7 @@ $rt_isAssignable = function(from, to) {
} }
return false; return false;
} }
$rt_createArray = function(cls, sz) { function $rt_createArray(cls, sz) {
var data = new Array(sz); var data = new Array(sz);
var arr = new ($rt_arraycls(cls))(data); var arr = new ($rt_arraycls(cls))(data);
for (var i = 0; i < sz; i = (i + 1) | 0) { for (var i = 0; i < sz; i = (i + 1) | 0) {
@ -43,14 +44,14 @@ $rt_createArray = function(cls, sz) {
} }
return arr; return arr;
} }
$rt_wrapArray = function(cls, data) { function $rt_wrapArray(cls, data) {
var arr = new ($rt_arraycls(cls))(data); var arr = new ($rt_arraycls(cls))(data);
return arr; return arr;
} }
$rt_createUnfilledArray = function(cls, sz) { function $rt_createUnfilledArray(cls, sz) {
return new ($rt_arraycls(cls))(new Array(sz)); return new ($rt_arraycls(cls))(new Array(sz));
} }
$rt_createLongArray = function(sz) { function $rt_createLongArray(sz) {
var data = new Array(sz); var data = new Array(sz);
var arr = new ($rt_arraycls($rt_longcls()))(data); var arr = new ($rt_arraycls($rt_longcls()))(data);
for (var i = 0; i < sz; i = (i + 1) | 0) { for (var i = 0; i < sz; i = (i + 1) | 0) {
@ -58,10 +59,21 @@ $rt_createLongArray = function(sz) {
} }
return arr; 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) { if (ArrayBuffer) {
$rt_createNumericArray = function(cls, nativeArray) { $rt_createNumericArray = function(cls, nativeArray) {
return new ($rt_arraycls(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) { $rt_createByteArray = function(sz) {
return $rt_createNumericArray($rt_bytecls(), new Int8Array(new ArrayBuffer(sz)), 0); return $rt_createNumericArray($rt_bytecls(), new Int8Array(new ArrayBuffer(sz)), 0);
}; };
@ -80,9 +92,6 @@ if (ArrayBuffer) {
$rt_createDoubleArray = function(sz) { $rt_createDoubleArray = function(sz) {
return $rt_createNumericArray($rt_doublecls(), new Float64Array(new ArrayBuffer(sz << 3)), 0); 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 { } else {
$rt_createNumericArray = function(cls, sz) { $rt_createNumericArray = function(cls, sz) {
var data = new Array(sz); var data = new Array(sz);
@ -100,8 +109,8 @@ if (ArrayBuffer) {
$rt_createDoubleArray = function(sz) { return $rt_createNumericArray($rt_doublecls(), sz); } $rt_createDoubleArray = function(sz) { return $rt_createNumericArray($rt_doublecls(), sz); }
$rt_createCharArray = function(sz) { return $rt_createNumericArray($rt_charcls(), sz); } $rt_createCharArray = function(sz) { return $rt_createNumericArray($rt_charcls(), sz); }
} }
$rt_arraycls = function(cls) { function $rt_arraycls(cls) {
if (cls.$array == undefined) { if (typeof cls.$array === 'undefined') {
var arraycls = function(data) { var arraycls = function(data) {
this.data = data; this.data = data;
this.$id = $rt_nextId(); this.$id = $rt_nextId();
@ -124,51 +133,51 @@ $rt_arraycls = function(cls) {
} }
return cls.$array; return cls.$array;
} }
$rt_createcls = function() { function $rt_createcls() {
return { return {
$meta : { $meta : {
supertypes : [] supertypes : []
} }
}; };
} }
$rt_booleanclsCache = null; var $rt_booleanclsCache = null;
$rt_booleancls = function() { function $rt_booleancls() {
if ($rt_booleanclsCache == null) { if ($rt_booleanclsCache === null) {
$rt_booleanclsCache = $rt_createcls(); $rt_booleanclsCache = $rt_createcls();
$rt_booleanclsCache.primitive = true; $rt_booleanclsCache.primitive = true;
$rt_booleanclsCache.name = "boolean"; $rt_booleanclsCache.name = "boolean";
} }
return $rt_booleanclsCache; return $rt_booleanclsCache;
} }
$rt_charclsCache = null; var $rt_charclsCache = null;
$rt_charcls = function() { function $rt_charcls() {
if ($rt_charclsCache == null) { if ($rt_charclsCache === null) {
$rt_charclsCache = $rt_createcls(); $rt_charclsCache = $rt_createcls();
$rt_charclsCache.primitive = true; $rt_charclsCache.primitive = true;
$rt_charclsCache.name = "char"; $rt_charclsCache.name = "char";
} }
return $rt_charclsCache; return $rt_charclsCache;
} }
$rt_byteclsCache = null; var $rt_byteclsCache = null;
$rt_bytecls = function() { function $rt_bytecls() {
if ($rt_byteclsCache == null) { if ($rt_byteclsCache === null) {
$rt_byteclsCache = $rt_createcls(); $rt_byteclsCache = $rt_createcls();
$rt_byteclsCache.primitive = true; $rt_byteclsCache.primitive = true;
$rt_byteclsCache.name = "byte"; $rt_byteclsCache.name = "byte";
} }
return $rt_byteclsCache; return $rt_byteclsCache;
} }
$rt_shortclsCache = null; var $rt_shortclsCache = null;
$rt_shortcls = function() { function $rt_shortcls() {
if ($rt_shortclsCache == null) { if ($rt_shortclsCache === null) {
$rt_shortclsCache = $rt_createcls(); $rt_shortclsCache = $rt_createcls();
$rt_shortclsCache.primitive = true; $rt_shortclsCache.primitive = true;
$rt_shortclsCache.name = "short"; $rt_shortclsCache.name = "short";
} }
return $rt_shortclsCache; return $rt_shortclsCache;
} }
$rt_intclsCache = null; var $rt_intclsCache = null;
$rt_intcls = function() { function $rt_intcls() {
if ($rt_intclsCache === null) { if ($rt_intclsCache === null) {
$rt_intclsCache = $rt_createcls(); $rt_intclsCache = $rt_createcls();
$rt_intclsCache.primitive = true; $rt_intclsCache.primitive = true;
@ -176,8 +185,8 @@ $rt_intcls = function() {
} }
return $rt_intclsCache; return $rt_intclsCache;
} }
$rt_longclsCache = null; var $rt_longclsCache = null;
$rt_longcls = function() { function $rt_longcls() {
if ($rt_longclsCache === null) { if ($rt_longclsCache === null) {
$rt_longclsCache = $rt_createcls(); $rt_longclsCache = $rt_createcls();
$rt_longclsCache.primitive = true; $rt_longclsCache.primitive = true;
@ -185,8 +194,8 @@ $rt_longcls = function() {
} }
return $rt_longclsCache; return $rt_longclsCache;
} }
$rt_floatclsCache = null; var $rt_floatclsCache = null;
$rt_floatcls = function() { function $rt_floatcls() {
if ($rt_floatclsCache === null) { if ($rt_floatclsCache === null) {
$rt_floatclsCache = $rt_createcls(); $rt_floatclsCache = $rt_createcls();
$rt_floatclsCache.primitive = true; $rt_floatclsCache.primitive = true;
@ -194,8 +203,8 @@ $rt_floatcls = function() {
} }
return $rt_floatclsCache; return $rt_floatclsCache;
} }
$rt_doubleclsCache = null; var $rt_doubleclsCache = null;
$rt_doublecls = function() { function $rt_doublecls() {
if ($rt_doubleclsCache === null) { if ($rt_doubleclsCache === null) {
$rt_doubleclsCache = $rt_createcls(); $rt_doubleclsCache = $rt_createcls();
$rt_doubleclsCache.primitive = true; $rt_doubleclsCache.primitive = true;
@ -203,8 +212,8 @@ $rt_doublecls = function() {
} }
return $rt_doubleclsCache; return $rt_doubleclsCache;
} }
$rt_voidclsCache = null; var $rt_voidclsCache = null;
$rt_voidcls = function() { function $rt_voidcls() {
if ($rt_voidclsCache === null) { if ($rt_voidclsCache === null) {
$rt_voidclsCache = $rt_createcls(); $rt_voidclsCache = $rt_createcls();
$rt_voidclsCache.primitive = true; $rt_voidclsCache.primitive = true;
@ -212,7 +221,7 @@ $rt_voidcls = function() {
} }
return $rt_voidclsCache; return $rt_voidclsCache;
} }
$rt_clinit = function(cls) { function $rt_clinit(cls) {
if (cls.$clinit) { if (cls.$clinit) {
var f = cls.$clinit; var f = cls.$clinit;
delete cls.$clinit; delete cls.$clinit;
@ -220,12 +229,12 @@ $rt_clinit = function(cls) {
} }
return cls; return cls;
} }
$rt_init = function(cls, constructor, args) { function $rt_init(cls, constructor, args) {
var obj = new cls(); var obj = new cls();
cls.prototype[constructor].apply(obj, args); cls.prototype[constructor].apply(obj, args);
return obj; return obj;
} }
$rt_throw = function(ex) { function $rt_throw(ex) {
var err = ex.$jsException; var err = ex.$jsException;
if (!err) { if (!err) {
var err = new Error("Java exception thrown"); var err = new Error("Java exception thrown");
@ -234,7 +243,7 @@ $rt_throw = function(ex) {
} }
throw err; throw err;
} }
$rt_createMultiArray = function(cls, dimensions) { function $rt_createMultiArray(cls, dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions)); var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0; var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 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); return $rt_createMultiArrayImpl(cls, arrays, dimensions);
} }
$rt_createByteMultiArray = function(dimensions) { function $rt_createByteMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions)); var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0; var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 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); return $rt_createMultiArrayImpl($rt_bytecls(), arrays, dimensions);
} }
$rt_createBooleanMultiArray = function(dimensions) { function $rt_createBooleanMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions)); var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0; var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 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); return $rt_createMultiArrayImpl($rt_booleancls(), arrays, dimensions);
} }
$rt_createShortMultiArray = function(dimensions) { function $rt_createShortMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions)); var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0; var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 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); return $rt_createMultiArrayImpl($rt_shortcls(), arrays, dimensions);
} }
$rt_createIntMultiArray = function(dimensions) { function $rt_createIntMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions)); var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0; var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 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); return $rt_createMultiArrayImpl($rt_intcls(), arrays, dimensions);
} }
$rt_createLongMultiArray = function(dimensions) { function $rt_createLongMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions)); var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0; var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 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); return $rt_createMultiArrayImpl($rt_longcls(), arrays, dimensions);
} }
$rt_createFloatMultiArray = function(dimensions) { function $rt_createFloatMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions)); var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0; var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 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); return $rt_createMultiArrayImpl($rt_floatcls(), arrays, dimensions);
} }
$rt_createDoubleMultiArray = function(dimensions) { function $rt_createDoubleMultiArray(dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions)); var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0; var firstDim = dimensions[0] | 0;
for (var i = 0 | 0; i < arrays.length; i = (i + 1) | 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); return $rt_createMultiArrayImpl($rt_doublecls(), arrays, dimensions);
} }
$rt_primitiveArrayCount = function(dimensions) { function $rt_primitiveArrayCount(dimensions) {
var val = dimensions[1] | 0; var val = dimensions[1] | 0;
for (var i = 2 | 0; i < dimensions.length; i = (i + 1) | 0) { for (var i = 2 | 0; i < dimensions.length; i = (i + 1) | 0) {
val = (val * (dimensions[i] | 0)) | 0; val = (val * (dimensions[i] | 0)) | 0;
} }
return val; return val;
} }
$rt_createMultiArrayImpl = function(cls, arrays, dimensions) { function $rt_createMultiArrayImpl(cls, arrays, dimensions) {
var limit = arrays.length; var limit = arrays.length;
for (var i = 1 | 0; i < dimensions.length; i = (i + 1) | 0) { for (var i = 1 | 0; i < dimensions.length; i = (i + 1) | 0) {
cls = $rt_arraycls(cls); cls = $rt_arraycls(cls);
@ -325,13 +334,13 @@ $rt_createMultiArrayImpl = function(cls, arrays, dimensions) {
} }
return arrays[0]; return arrays[0];
} }
$rt_assertNotNaN = function(value) { function $rt_assertNotNaN(value) {
if (typeof value == 'number' && isNaN(value)) { if (typeof value === 'number' && isNaN(value)) {
throw "NaN"; throw "NaN";
} }
return value; return value;
} }
$rt_methodStubs = function(clinit, names) { function $rt_methodStubs(clinit, names) {
for (var i = 0; i < names.length; i = (i + 1) | 0) { for (var i = 0; i < names.length; i = (i + 1) | 0) {
window[names[i]] = (function(name) { window[names[i]] = (function(name) {
return function() { return function() {
@ -341,9 +350,9 @@ $rt_methodStubs = function(clinit, names) {
})(names[i]); })(names[i]);
} }
} }
$rt_stdoutBuffer = ""; var $rt_stdoutBuffer = "";
$rt_putStdout = function(ch) { function $rt_putStdout(ch) {
if (ch === 0xA) { if (ch == 0xA) {
if (console) { if (console) {
console.info($rt_stdoutBuffer); console.info($rt_stdoutBuffer);
} }
@ -352,9 +361,9 @@ $rt_putStdout = function(ch) {
$rt_stdoutBuffer += String.fromCharCode(ch); $rt_stdoutBuffer += String.fromCharCode(ch);
} }
} }
$rt_stderrBuffer = ""; var $rt_stderrBuffer = "";
$rt_putStderr = function(ch) { function $rt_putStderr(ch) {
if (ch === 0xA) { if (ch == 0xA) {
if (console) { if (console) {
console.info($rt_stderrBuffer); console.info($rt_stderrBuffer);
} }
@ -364,7 +373,6 @@ $rt_putStderr = function(ch) {
} }
} }
function $rt_declClass(cls, data) { function $rt_declClass(cls, data) {
cls.name = data.name;
cls.$meta = {}; cls.$meta = {};
cls.$meta.superclass = data.superclass; cls.$meta.superclass = data.superclass;
cls.$meta.supertypes = data.interfaces ? data.interfaces.slice() : []; 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) { for (var i = 1; i < arguments.length; i += 2) {
var name = arguments[i]; var name = arguments[i];
var func = arguments[i + 1]; var func = arguments[i + 1];
if (typeof name == 'string') { if (typeof name === 'string') {
cls.prototype[name] = func; cls.prototype[name] = func;
} else { } else {
for (var j = 0; j < name.length; ++j) { for (var j = 0; j < name.length; ++j) {
@ -392,6 +400,7 @@ function $rt_virtualMethods(cls) {
} }
} }
} }
var $rt_stringPool_instance;
function $rt_stringPool(strings) { function $rt_stringPool(strings) {
$rt_stringPool_instance = new Array(strings.length); $rt_stringPool_instance = new Array(strings.length);
for (var i = 0; i < strings.length; ++i) { for (var i = 0; i < strings.length; ++i) {
@ -441,7 +450,7 @@ function $dbg_class(obj) {
return clsName; return clsName;
} }
Long = function(lo, hi) { function Long(lo, hi) {
this.lo = lo | 0; this.lo = lo | 0;
this.hi = hi | 0; this.hi = hi | 0;
} }
@ -461,18 +470,18 @@ Long.prototype.toString = function() {
result = result.reverse().join(''); result = result.reverse().join('');
return positive ? result : "-" + result; return positive ? result : "-" + result;
} }
Long_ZERO = new Long(0, 0); var Long_ZERO = new Long(0, 0);
Long_fromInt = function(val) { function Long_fromInt(val) {
return val >= 0 ? new Long(val, 0) : new Long(val, -1); return val >= 0 ? new Long(val, 0) : new Long(val, -1);
} }
Long_fromNumber = function(val) { function Long_fromNumber(val) {
if (val >= 0) { if (val >= 0) {
return new Long(val | 0, (val / 0x100000000) | 0); return new Long(val | 0, (val / 0x100000000) | 0);
} else { } else {
return new Long(val | 0, (-(Math.abs(val) / 0x100000000) - 1) | 0); return new Long(val | 0, (-(Math.abs(val) / 0x100000000) - 1) | 0);
} }
} }
Long_toNumber = function(val) { function Long_toNumber(val) {
var lo = val.lo; var lo = val.lo;
var hi = val.hi; var hi = val.hi;
if (lo < 0) { if (lo < 0) {
@ -480,7 +489,7 @@ Long_toNumber = function(val) {
} }
return 0x100000000 * hi + lo; return 0x100000000 * hi + lo;
} }
Long_add = function(a, b) { function Long_add(a, b) {
var a_lolo = a.lo & 0xFFFF; var a_lolo = a.lo & 0xFFFF;
var a_lohi = a.lo >>> 16; var a_lohi = a.lo >>> 16;
var a_hilo = a.hi & 0xFFFF; var a_hilo = a.hi & 0xFFFF;
@ -496,7 +505,7 @@ Long_add = function(a, b) {
var hihi = (a_hihi + b_hihi + (hilo >> 16)) | 0; var hihi = (a_hihi + b_hihi + (hilo >> 16)) | 0;
return new Long((lolo & 0xFFFF) | ((lohi & 0xFFFF) << 16), (hilo & 0xFFFF) | ((hihi & 0xFFFF) << 16)); 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 lo = (a.lo + 1) | 0;
var hi = a.hi; var hi = a.hi;
if (lo === 0) { if (lo === 0) {
@ -504,7 +513,7 @@ Long_inc = function(a) {
} }
return new Long(lo, hi); return new Long(lo, hi);
} }
Long_dec = function(a) { function Long_dec(a) {
var lo = (a.lo - 1) | 0; var lo = (a.lo - 1) | 0;
var hi = a.hi; var hi = a.hi;
if (lo === -1) { if (lo === -1) {
@ -512,10 +521,10 @@ Long_dec = function(a) {
} }
return new Long(lo, hi); return new Long(lo, hi);
} }
Long_neg = function(a) { function Long_neg(a) {
return Long_inc(new Long(a.lo ^ 0xFFFFFFFF, a.hi ^ 0xFFFFFFFF)); 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_lolo = a.lo & 0xFFFF;
var a_lohi = a.lo >>> 16; var a_lohi = a.lo >>> 16;
var a_hilo = a.hi & 0xFFFF; var a_hilo = a.hi & 0xFFFF;
@ -531,7 +540,7 @@ Long_sub = function(a, b) {
var hihi = (a_hihi - b_hihi + (hilo >> 16)) | 0; var hihi = (a_hihi - b_hihi + (hilo >> 16)) | 0;
return new Long((lolo & 0xFFFF) | ((lohi & 0xFFFF) << 16), (hilo & 0xFFFF) | ((hihi & 0xFFFF) << 16)); 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; var r = a.hi - b.hi;
if (r !== 0) { if (r !== 0) {
return r; return r;
@ -542,13 +551,13 @@ Long_compare = function(a, b) {
} }
return (a.lo & 1) - (b.lo & 1); return (a.lo & 1) - (b.lo & 1);
} }
Long_isPositive = function(a) { function Long_isPositive(a) {
return (a.hi & 0x80000000) === 0; return (a.hi & 0x80000000) === 0;
} }
Long_isNegative = function(a) { function Long_isNegative(a) {
return (a.hi & 0x80000000) !== 0; return (a.hi & 0x80000000) !== 0;
} }
Long_mul = function(a, b) { function Long_mul(a, b) {
var positive = Long_isNegative(a) === Long_isNegative(b); var positive = Long_isNegative(a) === Long_isNegative(b);
if (Long_isNegative(a)) { if (Long_isNegative(a)) {
a = Long_neg(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)); var result = new Long((lolo & 0xFFFF) | (lohi << 16), (hilo & 0xFFFF) | (hihi << 16));
return positive ? result : Long_neg(result); return positive ? result : Long_neg(result);
} }
Long_div = function(a, b) { function Long_div(a, b) {
return Long_divRem(a, b)[0]; return Long_divRem(a, b)[0];
} }
Long_rem = function(a, b) { function Long_rem(a, b) {
return Long_divRem(a, b)[1]; return Long_divRem(a, b)[1];
} }
Long_divRem = function(a, b) { function Long_divRem(a, b) {
var positive = Long_isNegative(a) === Long_isNegative(b); var positive = Long_isNegative(a) === Long_isNegative(b);
if (Long_isNegative(a)) { if (Long_isNegative(a)) {
a = Long_neg(a); a = Long_neg(a);
@ -607,22 +616,22 @@ Long_divRem = function(a, b) {
q = new Long(q.lo, q.hi); q = new Long(q.lo, q.hi);
return positive ? [q, a] : [Long_neg(q), Long_neg(a)]; 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)); 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); 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); 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); 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); return new Long(a.lo ^ b.lo, a.hi ^ b.hi);
} }
Long_shl = function(a, b) { function Long_shl(a, b) {
b &= 63; b &= 63;
if (b == 0) { if (b == 0) {
return a; return a;
@ -634,7 +643,7 @@ Long_shl = function(a, b) {
return new Long(0, a.lo << (b - 32)); return new Long(0, a.lo << (b - 32));
} }
} }
Long_shr = function(a, b) { function Long_shr(a, b) {
b &= 63; b &= 63;
if (b == 0) { if (b == 0) {
return a; return a;
@ -646,7 +655,7 @@ Long_shr = function(a, b) {
return new Long((a.hi >> (b - 32)), a.hi >> 31); return new Long((a.hi >> (b - 32)), a.hi >> 31);
} }
} }
Long_shru = function(a, b) { function Long_shru(a, b) {
b &= 63; b &= 63;
if (b == 0) { if (b == 0) {
return a; return a;
@ -660,12 +669,12 @@ Long_shru = function(a, b) {
} }
// Represents a mutable 80-bit unsigned integer // Represents a mutable 80-bit unsigned integer
LongInt = function(lo, hi, sup) { function LongInt(lo, hi, sup) {
this.lo = lo; this.lo = lo;
this.hi = hi; this.hi = hi;
this.sup = sup; this.sup = sup;
} }
LongInt_mul = function(a, b) { function LongInt_mul(a, b) {
var a_lolo = ((a.lo & 0xFFFF) * b) | 0; var a_lolo = ((a.lo & 0xFFFF) * b) | 0;
var a_lohi = ((a.lo >>> 16) * b) | 0; var a_lohi = ((a.lo >>> 16) * b) | 0;
var a_hilo = ((a.hi & 0xFFFF) * 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.hi = (a_hilo & 0xFFFF) | (a_hihi << 16);
a.sup = sup & 0xFFFF; a.sup = sup & 0xFFFF;
} }
LongInt_sub = function(a, b) { function LongInt_sub(a, b) {
var a_lolo = a.lo & 0xFFFF; var a_lolo = a.lo & 0xFFFF;
var a_lohi = a.lo >>> 16; var a_lohi = a.lo >>> 16;
var a_hilo = a.hi & 0xFFFF; 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_lohi = (a_lohi - b_lohi + (a_lolo >> 16)) | 0;
a_hilo = (a_hilo - b_hilo + (a_lohi >> 16)) | 0; a_hilo = (a_hilo - b_hilo + (a_lohi >> 16)) | 0;
a_hihi = (a_hihi - b_hihi + (a_hilo >> 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.lo = (a_lolo & 0xFFFF) | (a_lohi << 16);
a.hi = (a_hilo & 0xFFFF) | (a_hihi << 16); a.hi = (a_hilo & 0xFFFF) | (a_hihi << 16);
a.sup = sup; a.sup = sup;
} }
LongInt_add = function(a, b) { function LongInt_add(a, b) {
var a_lolo = a.lo & 0xFFFF; var a_lolo = a.lo & 0xFFFF;
var a_lohi = a.lo >>> 16; var a_lohi = a.lo >>> 16;
var a_hilo = a.hi & 0xFFFF; 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_lohi = (a_lohi + b_lohi + (a_lolo >> 16)) | 0;
a_hilo = (a_hilo + b_hilo + (a_lohi >> 16)) | 0; a_hilo = (a_hilo + b_hilo + (a_lohi >> 16)) | 0;
a_hihi = (a_hihi + b_hihi + (a_hilo >> 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.lo = (a_lolo & 0xFFFF) | (a_lohi << 16);
a.hi = (a_hilo & 0xFFFF) | (a_hihi << 16); a.hi = (a_hilo & 0xFFFF) | (a_hihi << 16);
a.sup = sup; a.sup = sup;
} }
LongInt_inc = function(a) { function LongInt_inc(a) {
a.lo = (a.lo + 1) | 0; a.lo = (a.lo + 1) | 0;
if (a.lo == 0) { if (a.lo == 0) {
a.hi = (a.hi + 1) | 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; a.lo = (a.lo - 1) | 0;
if (a.lo == -1) { if (a.lo == -1) {
a.hi = (a.hi - 1) | 0; 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); var r = (a.sup - b.sup);
if (r != 0) { if (r != 0) {
return r; return r;
@ -755,7 +764,7 @@ LongInt_ucompare = function(a, b) {
} }
return (a.lo & 1) - (b.lo & 1); return (a.lo & 1) - (b.lo & 1);
} }
LongInt_numOfLeadingZeroBits = function(a) { function LongInt_numOfLeadingZeroBits(a) {
var n = 0; var n = 0;
var d = 16; var d = 16;
while (d > 0) { while (d > 0) {
@ -767,14 +776,14 @@ LongInt_numOfLeadingZeroBits = function(a) {
} }
return 31 - n; return 31 - n;
} }
LongInt_shl = function(a, b) { function LongInt_shl(a, b) {
if (b === 0) { if (b == 0) {
return; return;
} else if (b < 32) { } else if (b < 32) {
a.sup = ((a.hi >>> (32 - b)) | (a.sup << b)) & 0xFFFF; a.sup = ((a.hi >>> (32 - b)) | (a.sup << b)) & 0xFFFF;
a.hi = (a.lo >>> (32 - b)) | (a.hi << b); a.hi = (a.lo >>> (32 - b)) | (a.hi << b);
a.lo <<= b; a.lo <<= b;
} else if (b === 32) { } else if (b == 32) {
a.sup = a.hi & 0xFFFF; a.sup = a.hi & 0xFFFF;
a.hi = a.lo; a.hi = a.lo;
a.lo = 0; a.lo = 0;
@ -782,7 +791,7 @@ LongInt_shl = function(a, b) {
a.sup = ((a.lo >>> (64 - b)) | (a.hi << (b - 32))) & 0xFFFF; a.sup = ((a.lo >>> (64 - b)) | (a.hi << (b - 32))) & 0xFFFF;
a.hi = a.lo << b; a.hi = a.lo << b;
a.lo = 0; a.lo = 0;
} else if (b === 64) { } else if (b == 64) {
a.sup = a.lo & 0xFFFF; a.sup = a.lo & 0xFFFF;
a.hi = 0; a.hi = 0;
a.lo = 0; a.lo = 0;
@ -792,10 +801,10 @@ LongInt_shl = function(a, b) {
a.lo = 0; a.lo = 0;
} }
} }
LongInt_shr = function(a, b) { function LongInt_shr(a, b) {
if (b === 0) { if (b == 0) {
return; return;
} else if (b === 32) { } else if (b == 32) {
a.lo = a.hi; a.lo = a.hi;
a.hi = a.sup; a.hi = a.sup;
a.sup = 0; a.sup = 0;
@ -803,7 +812,7 @@ LongInt_shr = function(a, b) {
a.lo = (a.lo >>> b) | (a.hi << (32 - b)); a.lo = (a.lo >>> b) | (a.hi << (32 - b));
a.hi = (a.hi >>> b) | (a.sup << (32 - b)); a.hi = (a.hi >>> b) | (a.sup << (32 - b));
a.sup >>>= b; a.sup >>>= b;
} else if (b === 64) { } else if (b == 64) {
a.lo = a.sup; a.lo = a.sup;
a.hi = 0; a.hi = 0;
a.sup = 0; a.sup = 0;
@ -817,17 +826,17 @@ LongInt_shr = function(a, b) {
a.sup = 0; a.sup = 0;
} }
} }
LongInt_copy = function(a) { function LongInt_copy(a) {
return new LongInt(a.lo, a.hi, a.sup); return new LongInt(a.lo, a.hi, a.sup);
} }
LongInt_div = function(a, b) { function LongInt_div(a, b) {
// Normalize divisor // Normalize divisor
var bits = b.hi !== 0 ? LongInt_numOfLeadingZeroBits(b.hi) : LongInt_numOfLeadingZeroBits(b.lo) + 32; var bits = b.hi !== 0 ? LongInt_numOfLeadingZeroBits(b.hi) : LongInt_numOfLeadingZeroBits(b.lo) + 32;
var sz = 1 + ((bits / 16) | 0); var sz = 1 + ((bits / 16) | 0);
var dividentBits = bits % 16; var dividentBits = bits % 16;
LongInt_shl(b, bits); LongInt_shl(b, bits);
LongInt_shl(a, dividentBits); LongInt_shl(a, dividentBits);
q = new LongInt(0, 0, 0); var q = new LongInt(0, 0, 0);
while (sz-- > 0) { while (sz-- > 0) {
LongInt_shl(q, 16); LongInt_shl(q, 16);
// Calculate approximate q // Calculate approximate q

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-dom</artifactId> <artifactId>teavm-dom</artifactId>

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-eclipse</artifactId> <artifactId>teavm-eclipse</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: TeaVM plugin for Eclipse Bundle-Name: TeaVM plugin for Eclipse
Bundle-SymbolicName: teavm-eclipse-core-plugin;singleton:=true Bundle-SymbolicName: teavm-eclipse-core-plugin;singleton:=true
Bundle-Version: 0.2.0.qualifer Bundle-Version: 0.3.0.qualifer
Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com> Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com>
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: ., Bundle-ClassPath: .,
@ -40,8 +40,8 @@ Bundle-ClassPath: .,
lib/org.apache.aries.spifly.weaver-internal-1.0.1.jar, lib/org.apache.aries.spifly.weaver-internal-1.0.1.jar,
lib/org.apache.aries.util-1.0.0.jar, lib/org.apache.aries.util-1.0.0.jar,
lib/slf4j-api-1.7.7.jar, lib/slf4j-api-1.7.7.jar,
lib/teavm-chrome-rdp-0.2-SNAPSHOT.jar, lib/teavm-chrome-rdp-0.3.0-SNAPSHOT.jar,
lib/teavm-core-0.2-SNAPSHOT.jar, lib/teavm-core-0.3.0-SNAPSHOT.jar,
lib/websocket-api-9.2.1.v20140609.jar, lib/websocket-api-9.2.1.v20140609.jar,
lib/websocket-client-9.2.1.v20140609.jar, lib/websocket-client-9.2.1.v20140609.jar,
lib/websocket-common-9.2.1.v20140609.jar, lib/websocket-common-9.2.1.v20140609.jar,

View File

@ -37,8 +37,8 @@ bin.includes = META-INF/,\
lib/org.apache.aries.spifly.weaver-internal-1.0.1.jar,\ lib/org.apache.aries.spifly.weaver-internal-1.0.1.jar,\
lib/org.apache.aries.util-1.0.0.jar,\ lib/org.apache.aries.util-1.0.0.jar,\
lib/slf4j-api-1.7.7.jar,\ lib/slf4j-api-1.7.7.jar,\
lib/teavm-chrome-rdp-0.2-SNAPSHOT.jar,\ lib/teavm-chrome-rdp-0.3.0-SNAPSHOT.jar,\
lib/teavm-core-0.2-SNAPSHOT.jar,\ lib/teavm-core-0.3.0-SNAPSHOT.jar,\
lib/websocket-api-9.2.1.v20140609.jar,\ lib/websocket-api-9.2.1.v20140609.jar,\
lib/websocket-client-9.2.1.v20140609.jar,\ lib/websocket-client-9.2.1.v20140609.jar,\
lib/websocket-common-9.2.1.v20140609.jar,\ lib/websocket-common-9.2.1.v20140609.jar,\

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<artifactId>teavm-eclipse-core-deps</artifactId> <artifactId>teavm-eclipse-core-deps</artifactId>

View File

@ -20,10 +20,9 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-eclipse</artifactId> <artifactId>teavm-eclipse</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-eclipse-core-plugin</artifactId> <artifactId>teavm-eclipse-core-plugin</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
<name>TeaVM core packages for Eclipse</name> <name>TeaVM core packages for Eclipse</name>

View File

@ -2,7 +2,7 @@
<feature <feature
id="teavm-eclipse-feature" id="teavm-eclipse-feature"
label="TeaVM Eclipse support" label="TeaVM Eclipse support"
version="0.2.0.qualifier" version="0.3.0.qualifier"
provider-name="Alexey Andreev &lt;konsoletyper@gmail.com&gt;"> provider-name="Alexey Andreev &lt;konsoletyper@gmail.com&gt;">
<description url="http://www.example.com/description"> <description url="http://www.example.com/description">

View File

@ -21,10 +21,9 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-eclipse</artifactId> <artifactId>teavm-eclipse</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-eclipse-feature</artifactId> <artifactId>teavm-eclipse-feature</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging> <packaging>eclipse-feature</packaging>

View File

@ -2,7 +2,7 @@
<feature <feature
id="teavm-eclipse-m2e-feature" id="teavm-eclipse-m2e-feature"
label="TeaVM maven configuration support" label="TeaVM maven configuration support"
version="0.2.0.qualifier" version="0.3.0.qualifier"
provider-name="Alexey Andreev &lt;konsoletyper@gmail.com&gt;"> provider-name="Alexey Andreev &lt;konsoletyper@gmail.com&gt;">
<description url="http://www.example.com/description"> <description url="http://www.example.com/description">
@ -230,7 +230,7 @@
</license> </license>
<requires> <requires>
<import feature="teavm-eclipse-feature" version="0.2.0.qualifier"/> <import feature="teavm-eclipse-feature" version="0.3.0.qualifier"/>
</requires> </requires>
<plugin <plugin

View File

@ -21,10 +21,9 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-eclipse</artifactId> <artifactId>teavm-eclipse</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-eclipse-m2e-feature</artifactId> <artifactId>teavm-eclipse-m2e-feature</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging> <packaging>eclipse-feature</packaging>

View File

@ -2,10 +2,10 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: TeaVM plugin for m2e Bundle-Name: TeaVM plugin for m2e
Bundle-SymbolicName: teavm-eclipse-m2e-plugin;singleton:=true Bundle-SymbolicName: teavm-eclipse-m2e-plugin;singleton:=true
Bundle-Version: 0.2.0.qualifier Bundle-Version: 0.3.0.qualifier
Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com> Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com>
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 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.m2e.core;bundle-version="[1.3,2)",
org.eclipse.core.runtime;bundle-version="[3.8,4.0)", org.eclipse.core.runtime;bundle-version="[3.8,4.0)",
org.eclipse.m2e.maven.runtime;bundle-version="[1.3,2)", org.eclipse.m2e.maven.runtime;bundle-version="[1.3,2)",

View File

@ -5,7 +5,7 @@
<pluginExecutionFilter> <pluginExecutionFilter>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-maven-plugin</artifactId> <artifactId>teavm-maven-plugin</artifactId>
<versionRange>0.2.0-SNAPSHOT</versionRange> <versionRange>0.3.0-SNAPSHOT</versionRange>
<goals> <goals>
<goal>build-javascript</goal> <goal>build-javascript</goal>
</goals> </goals>

View File

@ -21,10 +21,9 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-eclipse</artifactId> <artifactId>teavm-eclipse</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-eclipse-m2e-plugin</artifactId> <artifactId>teavm-eclipse-m2e-plugin</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>

View File

@ -1,5 +1,6 @@
package org.teavm.eclipse.m2e; package org.teavm.eclipse.m2e;
import java.io.File;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.*; import java.util.*;
@ -57,8 +58,11 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
} }
monitor.beginTask("Configuring TeaVM builder", sz * 1000); monitor.beginTask("Configuring TeaVM builder", sz * 1000);
TeaVMProjectSettings settings = teaVMPlugin.getSettings(project); TeaVMProjectSettings settings = teaVMPlugin.getSettings(project);
settings.load();
try { try {
if (!hasNature) {
teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
}
settings.load();
Set<String> coveredProfiles = new HashSet<>(); Set<String> coveredProfiles = new HashSet<>();
for (MojoExecution execution : executions) { for (MojoExecution execution : executions) {
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
@ -82,9 +86,6 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
settings.deleteProfile(profile); settings.deleteProfile(profile);
} }
} }
if (!hasNature) {
teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
}
settings.save(); settings.save();
} finally { } finally {
monitor.done(); monitor.done();
@ -179,10 +180,9 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
} }
private String absolutePathToWorkspacePath(String path) { private String absolutePathToWorkspacePath(String path) {
try {
IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager(); IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IContainer[] containers = root.findContainersForLocationURI(new URI("file://" + path)); IContainer[] containers = root.findContainersForLocationURI(new File(path).toURI());
if (containers.length == 0) { if (containers.length == 0) {
return null; return null;
} }
@ -194,9 +194,6 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
} }
path = container.getFullPath().toString(); path = container.getFullPath().toString();
return varManager.generateVariableExpression("workspace_loc", path) + suffix; return varManager.generateVariableExpression("workspace_loc", path) + suffix;
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
} }
private TeaVMRuntimeMode getRuntimeMode(String name) { private TeaVMRuntimeMode getRuntimeMode(String name) {

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: TeaVM plugin for Eclipse Bundle-Name: TeaVM plugin for Eclipse
Bundle-SymbolicName: teavm-eclipse-plugin;singleton:=true Bundle-SymbolicName: teavm-eclipse-plugin;singleton:=true
Bundle-Version: 0.2.0.qualifer Bundle-Version: 0.3.0.qualifer
Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com> Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com>
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Activator: org.teavm.eclipse.TeaVMEclipsePlugin 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.variables;bundle-version="[3.2.600,4)",
org.eclipse.core.databinding.observable;bundle-version="[1.4.1,2)", org.eclipse.core.databinding.observable;bundle-version="[1.4.1,2)",
org.eclipse.jface.databinding;bundle-version="[1.6.0,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 Export-Package: org.teavm.eclipse.debugger,org.teavm.eclipse
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy

View File

@ -21,10 +21,9 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-eclipse</artifactId> <artifactId>teavm-eclipse</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-eclipse-plugin</artifactId> <artifactId>teavm-eclipse-plugin</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>

View File

@ -53,8 +53,11 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
private String projectName; private String projectName;
public PreferencesBasedTeaVMProjectSettings(IProject project) { public PreferencesBasedTeaVMProjectSettings(IProject project) {
ProjectScope scope = new ProjectScope(project); this(project, new ProjectScope(project).getNode(TeaVMEclipsePlugin.ID));
globalPreferences = scope.getNode(TeaVMEclipsePlugin.ID); }
public PreferencesBasedTeaVMProjectSettings(IProject project, IEclipsePreferences preferences) {
globalPreferences = preferences;
projectName = project.getName(); projectName = project.getName();
} }

View File

@ -16,18 +16,21 @@
package org.teavm.eclipse; package org.teavm.eclipse;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.*; import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.plugin.AbstractUIPlugin; 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 { 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(); IProjectDescription projectDescription = project.getDescription();
String[] natureIds = projectDescription.getNatureIds(); String[] natureIds = projectDescription.getNatureIds();
natureIds = Arrays.copyOf(natureIds, natureIds.length + 1); natureIds = Arrays.copyOf(natureIds, natureIds.length + 1);

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<site> <site>
<feature url="features/teavm-eclipse-feature_0.2.0.qualifier.jar" id="teavm-eclipse-feature" <feature url="features/teavm-eclipse-feature_0.3.0.qualifier.jar" id="teavm-eclipse-feature"
version="0.2.0.qualifier"> version="0.3.0.qualifier">
<category name="teavm-category"/> <category name="teavm-category"/>
</feature> </feature>
<feature url="features/teavm-eclipse-m2e-feature_0.2.0.qualifier.jar" id="teavm-eclipse-m2e-feature" <feature url="features/teavm-eclipse-m2e-feature_0.3.0.qualifier.jar" id="teavm-eclipse-m2e-feature"
version="0.2.0.qualifier"> version="0.3.0.qualifier">
<category name="teavm-category"/> <category name="teavm-category"/>
</feature> </feature>
<category-def name="teavm-category" label="TeaVM"/> <category-def name="teavm-category" label="TeaVM"/>

View File

@ -21,10 +21,10 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-eclipse</artifactId> <artifactId>teavm-eclipse</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-eclipse-updatesite</artifactId> <artifactId>teavm-eclipse-updatesite</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-repository</packaging> <packaging>eclipse-repository</packaging>
<dependencies> <dependencies>

View File

@ -3,10 +3,10 @@
<description name="TeaVM update site"> <description name="TeaVM update site">
TeaVM update site TeaVM update site
</description> </description>
<feature url="features/teavm-eclipse-feature_0.2.0.qualifier.jar" id="teavm-eclipse-feature" version="0.0.0"> <feature url="features/teavm-eclipse-feature_0.3.0.qualifier.jar" id="teavm-eclipse-feature" version="0.0.0">
<category name="teavm-eclipse-caregory"/> <category name="teavm-eclipse-caregory"/>
</feature> </feature>
<feature url="features/teavm-eclipse-m2e-feature_0.2.0.qualifier.jar" id="teavm-eclipse-m2e-feature" version="0.0.0"> <feature url="features/teavm-eclipse-m2e-feature_0.3.0.qualifier.jar" id="teavm-eclipse-m2e-feature" version="0.0.0">
<category name="teavm-eclipse-caregory"/> <category name="teavm-eclipse-caregory"/>
</feature> </feature>
<category-def name="teavm-eclipse-caregory" label="TeaVM"/> <category-def name="teavm-eclipse-caregory" label="TeaVM"/>

View File

@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-html4j</artifactId> <artifactId>teavm-html4j</artifactId>

View File

@ -138,7 +138,7 @@ public class JavaScriptBodyDependency implements DependencyListener {
if (!methodDep.isMissing()) { if (!methodDep.isMissing()) {
if (reader.hasModifier(ElementModifier.STATIC) || reader.hasModifier(ElementModifier.FINAL)) { if (reader.hasModifier(ElementModifier.STATIC) || reader.hasModifier(ElementModifier.FINAL)) {
methodDep.use(); methodDep.use();
for (int i = 0; i <= methodDep.getParameterCount(); ++i) { for (int i = 0; i < methodDep.getParameterCount(); ++i) {
allClassesNode.connect(methodDep.getVariable(i)); allClassesNode.connect(methodDep.getVariable(i));
} }
} else { } else {

View File

@ -85,9 +85,15 @@ public class JavaScriptBodyGenerator implements Generator {
MethodDescriptor desc = MethodDescriptor.parse(method + params + "V"); MethodDescriptor desc = MethodDescriptor.parse(method + params + "V");
MethodReader reader = findMethod(fqn, desc); MethodReader reader = findMethod(fqn, desc);
StringBuilder sb = new StringBuilder(); 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) { 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("("); sb.append(") { return ").append(naming.getFullNameFor(JavaScriptConvGenerator.toJsMethod)).append("(");
if (ident == null) { if (ident == null) {
@ -105,7 +111,9 @@ public class JavaScriptBodyGenerator implements Generator {
.append(Renderer.typeToClsString(naming, reader.parameterType(i))).append(")"); .append(Renderer.typeToClsString(naming, reader.parameterType(i))).append(")");
} }
sb.append(")); })("); sb.append(")); })(");
sb.append(ident == null ? "null" : ident); if (ident != null) {
sb.append(ident);
}
return sb.toString(); return sb.toString();
} }
private MethodReader findMethod(String clsName, MethodDescriptor desc) { private MethodReader findMethod(String clsName, MethodDescriptor desc) {

View File

@ -26,28 +26,22 @@ import org.teavm.model.*;
* @author Alexey Andreev <konsoletyper@gmail.com> * @author Alexey Andreev <konsoletyper@gmail.com>
*/ */
public class JavaScriptConvGenerator implements Generator { public class JavaScriptConvGenerator implements Generator {
private static final String convCls = JavaScriptConv.class.getName(); static final MethodReference intValueMethod = new MethodReference(Integer.class, "intValue", int.class);
static final MethodReference intValueMethod = new MethodReference("java.lang.Integer", static final MethodReference booleanValueMethod = new MethodReference(Boolean.class, "booleanValue", boolean.class);
new MethodDescriptor("intValue", ValueType.INTEGER)); static final MethodReference doubleValueMethod = new MethodReference(Double.class, "doubleValue", double.class);
static final MethodReference booleanValueMethod = new MethodReference("java.lang.Boolean", static final MethodReference charValueMethod = new MethodReference(Character.class, "charValue", char.class);
new MethodDescriptor("booleanValue", ValueType.BOOLEAN)); static final MethodReference valueOfIntMethod = new MethodReference(Integer.class, "valueOf",
static final MethodReference doubleValueMethod = new MethodReference("java.lang.Double", int.class, Integer.class);
new MethodDescriptor("doubleValue", ValueType.DOUBLE)); static final MethodReference valueOfBooleanMethod = new MethodReference(Boolean.class, "valueOf",
static final MethodReference charValueMethod = new MethodReference("java.lang.Character", boolean.class, Boolean.class);
new MethodDescriptor("charValue", ValueType.CHARACTER)); static final MethodReference valueOfDoubleMethod = new MethodReference(Double.class, "valueOf",
static final MethodReference valueOfIntMethod = new MethodReference("java.lang.Integer", double.class, Double.class);
new MethodDescriptor("valueOf", ValueType.INTEGER, ValueType.object("java.lang.Integer"))); static final MethodReference valueOfCharMethod = new MethodReference(Character.class, "valueOf",
static final MethodReference valueOfBooleanMethod = new MethodReference("java.lang.Boolean", char.class, Character.class);
new MethodDescriptor("valueOf", ValueType.BOOLEAN, ValueType.object("java.lang.Boolean"))); static final MethodReference toJsMethod = new MethodReference(JavaScriptConv.class, "toJavaScript",
static final MethodReference valueOfDoubleMethod = new MethodReference("java.lang.Double", Object.class, Object.class);
new MethodDescriptor("valueOf", ValueType.DOUBLE, ValueType.object("java.lang.Double"))); static final MethodReference fromJsMethod = new MethodReference(JavaScriptConv.class, "fromJavaScript",
static final MethodReference valueOfCharMethod = new MethodReference("java.lang.Character", Object.class, Object.class, Object.class);
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));
@Override @Override
public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException { public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException {

View File

@ -107,7 +107,7 @@ abstract class JsCallback {
} }
sb.append(callMethod(refId, fqn, method, params)); sb.append(callMethod(refId, fqn, method, params));
if (body.charAt(paramBeg + 1) != (')')) { if (body.charAt(paramBeg + 1) != ')') {
sb.append(","); sb.append(",");
} }
pos = paramBeg + 1; pos = paramBeg + 1;

View File

@ -18,7 +18,7 @@ package org.teavm.html4j.testing;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Collections; 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.model.MethodReader;
import org.teavm.testing.TestAdapter; import org.teavm.testing.TestAdapter;

View File

@ -51,12 +51,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.java.html.BrwsrCtx; import net.java.html.BrwsrCtx;
import net.java.html.js.JavaScriptBody; import net.java.html.js.JavaScriptBody;
import org.apidesign.html.boot.spi.Fn; import org.netbeans.html.boot.spi.Fn;
import org.apidesign.html.context.spi.Contexts; import org.netbeans.html.context.spi.Contexts;
import org.apidesign.html.json.spi.JSONCall; import org.netbeans.html.json.spi.JSONCall;
import org.apidesign.html.json.spi.Technology; import org.netbeans.html.json.spi.Technology;
import org.apidesign.html.json.spi.Transfer; import org.netbeans.html.json.spi.Transfer;
import org.apidesign.html.json.tck.KnockoutTCK; import org.netbeans.html.json.tck.KnockoutTCK;
import org.netbeans.html.ko4j.KO4J; import org.netbeans.html.ko4j.KO4J;
import org.testng.Assert; import org.testng.Assert;

View File

@ -20,7 +20,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-jso</artifactId> <artifactId>teavm-jso</artifactId>

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-maven</artifactId> <artifactId>teavm-maven</artifactId>

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-maven</artifactId> <artifactId>teavm-maven</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-maven-plugin</artifactId> <artifactId>teavm-maven-plugin</artifactId>
<packaging>maven-plugin</packaging> <packaging>maven-plugin</packaging>

View File

@ -1,4 +1,3 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -6,7 +5,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-maven</artifactId> <artifactId>teavm-maven</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-maven-webapp</artifactId> <artifactId>teavm-maven-webapp</artifactId>
<name>TeaVM maven web application archetype</name> <name>TeaVM maven web application archetype</name>

View File

@ -9,7 +9,7 @@
<properties> <properties>
<java.version>1.7</java.version> <java.version>1.7</java.version>
<teavm.version>0.2-SNAPSHOT</teavm.version> <teavm.version>0.3.0-SNAPSHOT</teavm.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
@ -19,6 +19,7 @@
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-classlib</artifactId> <artifactId>teavm-classlib</artifactId>
<version>${teavm.version}</version> <version>${teavm.version}</version>
<scope>provided</scope>
</dependency> </dependency>
<!-- JavaScriptObjects (JSO) - a JavaScript binding for TeaVM --> <!-- JavaScriptObjects (JSO) - a JavaScript binding for TeaVM -->
@ -26,6 +27,7 @@
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-jso</artifactId> <artifactId>teavm-jso</artifactId>
<version>${teavm.version}</version> <version>${teavm.version}</version>
<scope>provided</scope>
</dependency> </dependency>
<!-- Different browser APIs for TeaVM in terms of JSO --> <!-- Different browser APIs for TeaVM in terms of JSO -->
@ -33,6 +35,7 @@
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-dom</artifactId> <artifactId>teavm-dom</artifactId>
<version>${teavm.version}</version> <version>${teavm.version}</version>
<scope>provided</scope>
</dependency> </dependency>
<!-- Servlet 3.1 specification --> <!-- Servlet 3.1 specification -->

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-platform</artifactId> <artifactId>teavm-platform</artifactId>

View File

@ -77,7 +77,7 @@ public class MetadataProviderNativeGenerator implements Generator {
Resource resource = generator.generateMetadata(metadataContext, methodRef); Resource resource = generator.generateMetadata(metadataContext, methodRef);
writer.append("if (!window.hasOwnProperty(\"").appendMethodBody(methodRef).append("$$resource\")) {") writer.append("if (!window.hasOwnProperty(\"").appendMethodBody(methodRef).append("$$resource\")) {")
.indent().softNewLine(); .indent().softNewLine();
writer.appendMethodBody(methodRef).append("$$resource = "); writer.append("window.").appendMethodBody(methodRef).append("$$resource = ");
ResourceWriterHelper.write(writer, resource); ResourceWriterHelper.write(writer, resource);
writer.append(';').softNewLine(); writer.append(';').softNewLine();
writer.outdent().append('}').softNewLine(); writer.outdent().append('}').softNewLine();

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-samples</artifactId> <artifactId>teavm-samples</artifactId>

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-samples</artifactId> <artifactId>teavm-samples</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-samples-benchmark</artifactId> <artifactId>teavm-samples-benchmark</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
@ -91,7 +91,7 @@
<targetDirectory>${project.build.directory}/generated/js/teavm</targetDirectory> <targetDirectory>${project.build.directory}/generated/js/teavm</targetDirectory>
<mainClass>org.teavm.samples.benchmark.teavm.BenchmarkStarter</mainClass> <mainClass>org.teavm.samples.benchmark.teavm.BenchmarkStarter</mainClass>
<runtime>SEPARATE</runtime> <runtime>SEPARATE</runtime>
<minifying>true</minifying> <minifying>false</minifying>
<debugInformationGenerated>true</debugInformationGenerated> <debugInformationGenerated>true</debugInformationGenerated>
</configuration> </configuration>
</execution> </execution>

View File

@ -20,7 +20,7 @@
<parent> <parent>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-samples</artifactId> <artifactId>teavm-samples</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>teavm-samples-hello</artifactId> <artifactId>teavm-samples-hello</artifactId>