diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 1a58b7f65..b9d673c09 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -45,7 +45,7 @@
-
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 71ff15392..a991acf7d 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -10,7 +10,10 @@
+
+
+
diff --git a/all-deps/all-deps.iml b/all-deps/all-deps.iml
index c27f9de5e..d673fc169 100644
--- a/all-deps/all-deps.iml
+++ b/all-deps/all-deps.iml
@@ -21,5 +21,7 @@
+
+
\ No newline at end of file
diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java
index 7afde31fe..813fad5ca 100644
--- a/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java
+++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java
@@ -21,14 +21,10 @@ import java.util.Map;
import org.teavm.classlib.impl.DeclaringClassMetadataGenerator;
import org.teavm.classlib.java.lang.annotation.TAnnotation;
import org.teavm.classlib.java.lang.reflect.TAnnotatedElement;
-import org.teavm.interop.Address;
-import org.teavm.interop.DelegateTo;
import org.teavm.platform.Platform;
import org.teavm.platform.PlatformClass;
import org.teavm.platform.metadata.ClassResource;
import org.teavm.platform.metadata.ClassScopedMetadataProvider;
-import org.teavm.runtime.RuntimeClass;
-import org.teavm.runtime.RuntimeObject;
public class TClass extends TObject implements TAnnotatedElement {
TString name;
@@ -67,7 +63,7 @@ public class TClass extends TObject implements TAnnotatedElement {
public TString getName() {
if (name == null) {
- name = TString.wrap(platformClass.getMetadata().getName());
+ name = TString.wrap(Platform.getName(platformClass));
}
return name;
}
@@ -78,7 +74,7 @@ public class TClass extends TObject implements TAnnotatedElement {
simpleName = getComponentType().getSimpleName().concat(TString.wrap("[]"));
return simpleName;
}
- String name = platformClass.getMetadata().getName();
+ String name = Platform.getName(platformClass);
int lastDollar = name.lastIndexOf('$');
if (lastDollar != -1) {
name = name.substring(lastDollar + 1);
diff --git a/classlib/teavm-classlib.iml b/classlib/teavm-classlib.iml
index 81eb3914e..d96f6ab5c 100644
--- a/classlib/teavm-classlib.iml
+++ b/classlib/teavm-classlib.iml
@@ -4,6 +4,7 @@
+
diff --git a/core/pom.xml b/core/pom.xml
index 5b6d75016..cdf0155b0 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -29,6 +29,10 @@
TeaVM core
TeaVM compiler and SPI
+
+ 1.0.3
+
+
junit
@@ -63,6 +67,11 @@
objenesis
2.4
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ ${kotlin.version}
+
@@ -93,6 +102,20 @@
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+ ${kotlin.version}
+
+
+ compile
+ process-sources
+
+ compile
+
+
+
+
diff --git a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java
index f73e26ed6..46f20bc9c 100644
--- a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java
+++ b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java
@@ -575,6 +575,9 @@ public class WasmTarget implements TeaVMTarget {
}
ClassReader cls = classes.get(className);
+ if (cls == null) {
+ continue;
+ }
MethodReader method = cls.getMethod(new MethodDescriptor("", void.class));
if (method == null) {
continue;
diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java
index f502fd21c..7b02222d0 100644
--- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java
+++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java
@@ -132,9 +132,11 @@ public class WasmClassGenerator {
String className = ((ValueType.Object) type).getClassName();
ClassReader cls = classSource.get(className);
- calculateLayout(cls, binaryData);
- if (binaryData.start >= 0) {
- binaryData.start = binaryWriter.append(createStructure(binaryData));
+ if (cls != null) {
+ calculateLayout(cls, binaryData);
+ if (binaryData.start >= 0) {
+ binaryData.start = binaryWriter.append(createStructure(binaryData));
+ }
}
} else if (type instanceof ValueType.Array) {
ValueType itemType = ((ValueType.Array) type).getItemType();
diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java
index ae7826cc1..8fa17e2f0 100644
--- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java
+++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java
@@ -17,6 +17,7 @@ package org.teavm.backend.wasm.intrinsics;
import org.teavm.ast.InvocationExpr;
import org.teavm.backend.wasm.model.expression.WasmExpression;
+import org.teavm.backend.wasm.model.expression.WasmInt32Constant;
import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodReference;
@@ -33,6 +34,7 @@ public class PlatformIntrinsic implements WasmIntrinsic {
switch (methodDescriptor.getName()) {
case "getPlatformObject":
case "asJavaClass":
+ case "getName":
return true;
default:
return false;
@@ -45,6 +47,8 @@ public class PlatformIntrinsic implements WasmIntrinsic {
case "getPlatformObject":
case "asJavaClass":
return manager.generate(invocation.getArguments().get(0));
+ case "getName":
+ return new WasmInt32Constant(0);
default:
throw new IllegalArgumentException(invocation.getMethod().toString());
}
diff --git a/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java b/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java
index 1c44331f9..ddc719ef5 100644
--- a/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java
+++ b/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java
@@ -613,12 +613,17 @@ class WasmBinaryRenderingVisitor implements WasmExpressionVisitor {
for (WasmExpression argument : expression.getArguments()) {
argument.acceptVisitor(this);
}
+ Integer functionIndex = !expression.isImported()
+ ? functionIndexes.get(expression.getFunctionName())
+ : importedIndexes.get(expression.getFunctionName());
+ if (functionIndex == null) {
+ writer.writeByte(0x0A);
+ return;
+ }
+
writer.writeByte(!expression.isImported() ? 0x16 : 0x18);
writer.writeLEB(expression.getArguments().size());
- writer.writeLEB(!expression.isImported()
- ? functionIndexes.get(expression.getFunctionName())
- : importedIndexes.get(expression.getFunctionName()));
-
+ writer.writeLEB(functionIndex);
}
@Override
diff --git a/core/src/main/java/org/teavm/backend/wasm/render/WasmCRenderingVisitor.java b/core/src/main/java/org/teavm/backend/wasm/render/WasmCRenderingVisitor.java
index 117b5d139..44789b7eb 100644
--- a/core/src/main/java/org/teavm/backend/wasm/render/WasmCRenderingVisitor.java
+++ b/core/src/main/java/org/teavm/backend/wasm/render/WasmCRenderingVisitor.java
@@ -660,12 +660,17 @@ class WasmCRenderingVisitor implements WasmExpressionVisitor {
@Override
public void visit(WasmCall expression) {
+ WasmFunction function = module.getFunctions().get(expression.getFunctionName());
+ if (function == null) {
+ value = new CExpression("0");
+ return;
+ }
+
CExpression result = new CExpression();
WasmType type = requiredType;
StringBuilder sb = new StringBuilder();
sb.append(expression.getFunctionName()).append('(');
- WasmFunction function = module.getFunctions().get(expression.getFunctionName());
translateArguments(expression.getArguments(), function.getParameters(), result, sb);
sb.append(')');
result.setText(sb.toString());
diff --git a/core/src/main/java/org/teavm/model/lowlevel/GcRootMaintainingTransformer.java b/core/src/main/java/org/teavm/model/lowlevel/GcRootMaintainingTransformer.java
index 96aa88ebd..e6ac8a5f8 100644
--- a/core/src/main/java/org/teavm/model/lowlevel/GcRootMaintainingTransformer.java
+++ b/core/src/main/java/org/teavm/model/lowlevel/GcRootMaintainingTransformer.java
@@ -185,8 +185,6 @@ public class GcRootMaintainingTransformer {
clearInvocation.getArguments().add(slotVar);
clearInvocation.setLocation(callInstruction.getLocation());
instructionsToAdd.add(clearInvocation);
-
- ++slot;
}
instructions.addAll(index, instructionsToAdd);
diff --git a/core/src/main/java/org/teavm/model/optimization/Inlining.java b/core/src/main/java/org/teavm/model/optimization/Inlining.java
index 8a8bf56bd..c6ed3a58c 100644
--- a/core/src/main/java/org/teavm/model/optimization/Inlining.java
+++ b/core/src/main/java/org/teavm/model/optimization/Inlining.java
@@ -241,7 +241,8 @@ public class Inlining {
}
MethodReader invokedMethod = getMethod(classSource, invoke.getMethod());
- if (invokedMethod.getProgram() == null || invokedMethod.getProgram().basicBlockCount() == 0) {
+ if (invokedMethod == null || invokedMethod.getProgram() == null
+ || invokedMethod.getProgram().basicBlockCount() == 0) {
continue;
}
diff --git a/core/teavm-core.iml b/core/teavm-core.iml
index 2f70fa9a3..cc3c1e04c 100644
--- a/core/teavm-core.iml
+++ b/core/teavm-core.iml
@@ -4,6 +4,7 @@
+
diff --git a/interop/core/teavm-interop.iml b/interop/core/teavm-interop.iml
index f1f769417..dae5c19b8 100644
--- a/interop/core/teavm-interop.iml
+++ b/interop/core/teavm-interop.iml
@@ -1,6 +1,6 @@
-
+
diff --git a/metaprogramming/api/teavm-metaprogramming-api.iml b/metaprogramming/api/teavm-metaprogramming-api.iml
index e9b31cd72..146ecceee 100644
--- a/metaprogramming/api/teavm-metaprogramming-api.iml
+++ b/metaprogramming/api/teavm-metaprogramming-api.iml
@@ -4,6 +4,7 @@
+
diff --git a/metaprogramming/impl/teavm-metaprogramming-impl.iml b/metaprogramming/impl/teavm-metaprogramming-impl.iml
index 6a43b9c33..ba0901220 100644
--- a/metaprogramming/impl/teavm-metaprogramming-impl.iml
+++ b/metaprogramming/impl/teavm-metaprogramming-impl.iml
@@ -4,6 +4,7 @@
+
diff --git a/platform/src/main/java/org/teavm/platform/Platform.java b/platform/src/main/java/org/teavm/platform/Platform.java
index d46b1831c..60c9d6ada 100644
--- a/platform/src/main/java/org/teavm/platform/Platform.java
+++ b/platform/src/main/java/org/teavm/platform/Platform.java
@@ -166,4 +166,9 @@ public final class Platform {
private static RuntimeClass getArrayItemLowLevel(RuntimeClass cls) {
return cls.itemType;
}
+
+ @DelegateTo("getNameLowLevel")
+ public static String getName(PlatformClass cls) {
+ return cls.getMetadata().getName();
+ }
}
diff --git a/platform/teavm-platform.iml b/platform/teavm-platform.iml
index 29eb81a90..d2b600946 100644
--- a/platform/teavm-platform.iml
+++ b/platform/teavm-platform.iml
@@ -4,6 +4,7 @@
+
diff --git a/samples/kotlin/pom.xml b/samples/kotlin/pom.xml
index 4a0084e9b..4aac3bffa 100644
--- a/samples/kotlin/pom.xml
+++ b/samples/kotlin/pom.xml
@@ -30,7 +30,7 @@
A sample application written in Kotlin and compiled by TeaVM
- 1.0.1-2
+ 1.0.3
diff --git a/samples/kotlin/src/main/kotlin/org/teavm/samples/kotlin/ConsoleHello.kt b/samples/kotlin/src/main/kotlin/org/teavm/samples/kotlin/ConsoleHello.kt
new file mode 100644
index 000000000..4584046f2
--- /dev/null
+++ b/samples/kotlin/src/main/kotlin/org/teavm/samples/kotlin/ConsoleHello.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2016 konsoletyper.
+ *
+ * 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.samples.kotlin
+
+fun main(args : Array) {
+ println("Hello from Kotlin")
+}
\ No newline at end of file
diff --git a/samples/kotlin/src/main/kotlin/org/teavm/samples/kotlin/Hello.kt b/samples/kotlin/src/main/kotlin/org/teavm/samples/kotlin/Hello.kt
index 4364e19c8..c21d4a0f2 100644
--- a/samples/kotlin/src/main/kotlin/org/teavm/samples/kotlin/Hello.kt
+++ b/samples/kotlin/src/main/kotlin/org/teavm/samples/kotlin/Hello.kt
@@ -18,7 +18,7 @@ package org.teavm.samples.kotlin
import org.teavm.jso.browser.*
fun main(args : Array) {
- val document = Window.current().document;
+ val document = Window.current().document
document.getElementById("hello-kotlin").addEventListener("click") { Window.alert("Hello, developer!") }
}
diff --git a/samples/kotlin/teavm-samples-kotlin.iml b/samples/kotlin/teavm-samples-kotlin.iml
index a85a09e4a..ca051d2d5 100644
--- a/samples/kotlin/teavm-samples-kotlin.iml
+++ b/samples/kotlin/teavm-samples-kotlin.iml
@@ -22,8 +22,8 @@
-
-
+
+
diff --git a/tools/chrome-rdp/teavm-chrome-rdp.iml b/tools/chrome-rdp/teavm-chrome-rdp.iml
index ced1fa45a..278403112 100644
--- a/tools/chrome-rdp/teavm-chrome-rdp.iml
+++ b/tools/chrome-rdp/teavm-chrome-rdp.iml
@@ -4,6 +4,7 @@
+
diff --git a/tools/core/teavm-tooling.iml b/tools/core/teavm-tooling.iml
index 189842508..1c5cc5cb7 100644
--- a/tools/core/teavm-tooling.iml
+++ b/tools/core/teavm-tooling.iml
@@ -4,6 +4,7 @@
+