mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Merge branch 'master' into regex
This commit is contained in:
commit
c47689dc30
11
README.md
11
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).
|
||||
|
|
7
pom.xml
7
pom.xml
|
@ -20,7 +20,7 @@
|
|||
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>TeaVM</name>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<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>
|
||||
<slf4j.version>1.7.7</slf4j.version>
|
||||
</properties>
|
||||
|
@ -120,7 +120,7 @@
|
|||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-debug-all</artifactId>
|
||||
<version>4.2</version>
|
||||
<version>5.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
@ -192,6 +192,7 @@
|
|||
</executions>
|
||||
<configuration>
|
||||
<show>protected</show>
|
||||
<failOnError>false</failOnError>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-chrome-rdp</artifactId>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-classlib</artifactId>
|
||||
|
||||
|
@ -85,8 +85,6 @@
|
|||
<phase>process-test-classes</phase>
|
||||
<configuration>
|
||||
<minifying>false</minifying>
|
||||
<sourceMapsGenerated>true</sourceMapsGenerated>
|
||||
<sourceFilesCopied>true</sourceFilesCopied>
|
||||
<properties>
|
||||
<java.util.Locale.available>en, en_US, en_GB, ru, ru_RU</java.util.Locale.available>
|
||||
</properties>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<String, List<String>> entry : serviceMap.entrySet()) {
|
||||
writer.appendClass(entry.getKey()).append(".$$serviceList$$ = [");
|
||||
List<String> implementations = entry.getValue();
|
||||
|
|
|
@ -365,4 +365,9 @@ public class StringBuilderTest {
|
|||
assertEquals(3, sb.lastIndexOf("345"));
|
||||
assertEquals(-1, sb.lastIndexOf("35"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void substringWithUpperBoundAtEndWorks() {
|
||||
assertEquals("23", "123".substring(1, 3));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,4 +67,33 @@ public class VMTest {
|
|||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setsVariableBeforeTryCatch() {
|
||||
int a = 23;
|
||||
try {
|
||||
a = Integer.parseInt("not a number");
|
||||
} catch (NumberFormatException e) {
|
||||
// do nothing
|
||||
}
|
||||
assertEquals(23, a);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void surrogateInStringLiteralsWork() {
|
||||
assertEquals(0xDDC2, "a\uDDC2b".charAt(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void separatesExceptionAndVariable() {
|
||||
int n = foo();
|
||||
try {
|
||||
bar();
|
||||
} catch (RuntimeException e) {
|
||||
assertEquals(RuntimeException.class, e.getClass());
|
||||
assertEquals(2, n);
|
||||
}
|
||||
}
|
||||
private int foo() { return 2; }
|
||||
private void bar() { throw new RuntimeException(); }
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-cli</artifactId>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-core</artifactId>
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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, "<init>",
|
||||
ValueType.arrayOf(ValueType.CHARACTER), ValueType.VOID);
|
||||
writer.append("$rt_str = function(str) {").indent().softNewLine();
|
||||
MethodReference stringCons = new MethodReference(String.class, "<init>", 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, "<init>", 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<String> 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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)) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()];
|
||||
|
|
|
@ -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<String, TeaVMEntryPoint> 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<String, String> 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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-dom</artifactId>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-eclipse</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
|
|
@ -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 <konsoletyper@gmail.com>
|
||||
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,
|
||||
|
|
|
@ -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,\
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>teavm-eclipse-core-deps</artifactId>
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-eclipse</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-eclipse-core-plugin</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
<name>TeaVM core packages for Eclipse</name>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<feature
|
||||
id="teavm-eclipse-feature"
|
||||
label="TeaVM Eclipse support"
|
||||
version="0.2.0.qualifier"
|
||||
version="0.3.0.qualifier"
|
||||
provider-name="Alexey Andreev <konsoletyper@gmail.com>">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-eclipse</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-eclipse-feature</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
|
||||
<packaging>eclipse-feature</packaging>
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<feature
|
||||
id="teavm-eclipse-m2e-feature"
|
||||
label="TeaVM maven configuration support"
|
||||
version="0.2.0.qualifier"
|
||||
version="0.3.0.qualifier"
|
||||
provider-name="Alexey Andreev <konsoletyper@gmail.com>">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
|
@ -230,7 +230,7 @@
|
|||
</license>
|
||||
|
||||
<requires>
|
||||
<import feature="teavm-eclipse-feature" version="0.2.0.qualifier"/>
|
||||
<import feature="teavm-eclipse-feature" version="0.3.0.qualifier"/>
|
||||
</requires>
|
||||
|
||||
<plugin
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-eclipse</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-eclipse-m2e-feature</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
|
||||
<packaging>eclipse-feature</packaging>
|
||||
|
||||
|
|
|
@ -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 <konsoletyper@gmail.com>
|
||||
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)",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<pluginExecutionFilter>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-maven-plugin</artifactId>
|
||||
<versionRange>0.2.0-SNAPSHOT</versionRange>
|
||||
<versionRange>0.3.0-SNAPSHOT</versionRange>
|
||||
<goals>
|
||||
<goal>build-javascript</goal>
|
||||
</goals>
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-eclipse</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-eclipse-m2e-plugin</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
|
|
|
@ -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<String> 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) {
|
||||
|
|
|
@ -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 <konsoletyper@gmail.com>
|
||||
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
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-eclipse</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-eclipse-plugin</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site>
|
||||
<feature url="features/teavm-eclipse-feature_0.2.0.qualifier.jar" id="teavm-eclipse-feature"
|
||||
version="0.2.0.qualifier">
|
||||
<feature url="features/teavm-eclipse-feature_0.3.0.qualifier.jar" id="teavm-eclipse-feature"
|
||||
version="0.3.0.qualifier">
|
||||
<category name="teavm-category"/>
|
||||
</feature>
|
||||
<feature url="features/teavm-eclipse-m2e-feature_0.2.0.qualifier.jar" id="teavm-eclipse-m2e-feature"
|
||||
version="0.2.0.qualifier">
|
||||
<feature url="features/teavm-eclipse-m2e-feature_0.3.0.qualifier.jar" id="teavm-eclipse-m2e-feature"
|
||||
version="0.3.0.qualifier">
|
||||
<category name="teavm-category"/>
|
||||
</feature>
|
||||
<category-def name="teavm-category" label="TeaVM"/>
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-eclipse</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-eclipse-updatesite</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
|
||||
<packaging>eclipse-repository</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
<description name="TeaVM update site">
|
||||
TeaVM update site
|
||||
</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"/>
|
||||
</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"/>
|
||||
</feature>
|
||||
<category-def name="teavm-eclipse-caregory" label="TeaVM"/>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-html4j</artifactId>
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -26,28 +26,22 @@ import org.teavm.model.*;
|
|||
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||
*/
|
||||
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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-jso</artifactId>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-maven</artifactId>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-maven</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-maven-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -6,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-maven</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-maven-webapp</artifactId>
|
||||
<name>TeaVM maven web application archetype</name>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<properties>
|
||||
<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>
|
||||
</properties>
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
|||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-classlib</artifactId>
|
||||
<version>${teavm.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JavaScriptObjects (JSO) - a JavaScript binding for TeaVM -->
|
||||
|
@ -26,6 +27,7 @@
|
|||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-jso</artifactId>
|
||||
<version>${teavm.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Different browser APIs for TeaVM in terms of JSO -->
|
||||
|
@ -33,6 +35,7 @@
|
|||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-dom</artifactId>
|
||||
<version>${teavm.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Servlet 3.1 specification -->
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-platform</artifactId>
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-samples</artifactId>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-samples</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-samples-benchmark</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
@ -91,7 +91,7 @@
|
|||
<targetDirectory>${project.build.directory}/generated/js/teavm</targetDirectory>
|
||||
<mainClass>org.teavm.samples.benchmark.teavm.BenchmarkStarter</mainClass>
|
||||
<runtime>SEPARATE</runtime>
|
||||
<minifying>true</minifying>
|
||||
<minifying>false</minifying>
|
||||
<debugInformationGenerated>true</debugInformationGenerated>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<parent>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-samples</artifactId>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>teavm-samples-hello</artifactId>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user