From b7754ea1a5081f60529b1bc1e9863a19dbba925d Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Tue, 30 Sep 2014 23:19:10 +0400 Subject: [PATCH] Minor improvements & bugfixes --- .../java/org/teavm/debugging/PropertyMap.java | 27 ++++++++++++++++--- .../org/teavm/parsing/SSATransformer.java | 3 +++ .../java/org/teavm/jso/JSNativeGenerator.java | 1 + .../META-INF/maven/archetype-metadata.xml | 5 ---- .../resources/archetype-resources/pom.xml | 4 +++ .../src/main/webapp/index.html | 5 ++-- 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/teavm-core/src/main/java/org/teavm/debugging/PropertyMap.java b/teavm-core/src/main/java/org/teavm/debugging/PropertyMap.java index 02d6fc16f..823524795 100644 --- a/teavm-core/src/main/java/org/teavm/debugging/PropertyMap.java +++ b/teavm-core/src/main/java/org/teavm/debugging/PropertyMap.java @@ -62,13 +62,34 @@ class PropertyMap extends AbstractMap { Map vars = new HashMap<>(); for (Map.Entry entry : jsVariables.entrySet()) { JavaScriptVariable jsVar = entry.getValue(); - String name = debugger.mapField(className, entry.getKey()); - if (name == null) { - continue; + String name; + if (className.endsWith("[]")) { + if (entry.getKey().equals("data")) { + name = entry.getKey(); + } else { + continue; + } + } else if (isNumeric(entry.getKey())) { + name = entry.getKey(); + } else { + name = debugger.mapField(className, entry.getKey()); + if (name == null) { + continue; + } } Value value = new Value(debugger, jsVar.getValue()); vars.put(entry.getKey(), new Variable(name, value)); } backingMap.compareAndSet(null, vars); } + + private boolean isNumeric(String str) { + for (int i = 0; i < str.length(); ++i) { + char c = str.charAt(i); + if (c < '0' || c > '9') { + return false; + } + } + return true; + } } diff --git a/teavm-core/src/main/java/org/teavm/parsing/SSATransformer.java b/teavm-core/src/main/java/org/teavm/parsing/SSATransformer.java index 4e1c5ae78..c61f74869 100644 --- a/teavm-core/src/main/java/org/teavm/parsing/SSATransformer.java +++ b/teavm-core/src/main/java/org/teavm/parsing/SSATransformer.java @@ -426,6 +426,9 @@ public class SSATransformer { @Override public void visit(UnwrapArrayInstruction insn) { insn.setArray(use(insn.getArray())); + for (String debugName : insn.getArray().getDebugNames()) { + variableDebugMap.put(insn.getReceiver().getIndex(), debugName + ".data"); + } insn.setReceiver(define(insn.getReceiver())); } diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSNativeGenerator.java b/teavm-jso/src/main/java/org/teavm/jso/JSNativeGenerator.java index 9aec63dbe..13616723f 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JSNativeGenerator.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JSNativeGenerator.java @@ -119,6 +119,7 @@ public class JSNativeGenerator implements Generator, Injector, DependencyPlugin switch (method.getReference().getName()) { case "invoke": case "instantiate": + case "function": for (int i = 0; i < method.getReference().parameterCount(); ++i) { method.getVariable(i).addConsumer(new DependencyConsumer() { @Override public void consume(DependencyAgentType type) { diff --git a/teavm-maven/teavm-maven-webapp/src/main/resources/META-INF/maven/archetype-metadata.xml b/teavm-maven/teavm-maven-webapp/src/main/resources/META-INF/maven/archetype-metadata.xml index d9360669a..8c7fce9d5 100644 --- a/teavm-maven/teavm-maven-webapp/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/teavm-maven/teavm-maven-webapp/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -3,11 +3,6 @@ xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="TeaVM web application" partial="false"> - - - - - src/main/java diff --git a/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml b/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml index 9210cedc6..936c60dcd 100644 --- a/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml +++ b/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/pom.xml @@ -101,6 +101,10 @@ true + + + true diff --git a/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/src/main/webapp/index.html b/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/src/main/webapp/index.html index ef607a1c1..928fde5f4 100644 --- a/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/src/main/webapp/index.html +++ b/teavm-maven/teavm-maven-webapp/src/main/resources/archetype-resources/src/main/webapp/index.html @@ -2,8 +2,9 @@ Main page - - + + +