Fixing minor bugs

This commit is contained in:
Alexey Andreev 2016-09-17 10:42:46 +03:00
parent 1b78de9b40
commit 6c5a691fc9
25 changed files with 98 additions and 23 deletions

View File

@ -45,7 +45,7 @@
<module name="teavm-core" target="1.8" />
<module name="teavm-extras-slf4j" target="1.8" />
<module name="teavm-html4j" target="1.8" />
<module name="teavm-interop" target="1.5" />
<module name="teavm-interop" target="1.8" />
<module name="teavm-jso" target="1.8" />
<module name="teavm-jso-apis" target="1.8" />
<module name="teavm-jso-impl" target="1.8" />

View File

@ -10,7 +10,10 @@
<module fileurl="file://$PROJECT_DIR$/core/teavm-core.iml" filepath="$PROJECT_DIR$/core/teavm-core.iml" />
<module fileurl="file://$PROJECT_DIR$/extras-slf4j/teavm-extras-slf4j.iml" filepath="$PROJECT_DIR$/extras-slf4j/teavm-extras-slf4j.iml" />
<module fileurl="file://$PROJECT_DIR$/html4j/teavm-html4j.iml" filepath="$PROJECT_DIR$/html4j/teavm-html4j.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/idea/teavm-idea-plugin.iml" filepath="$PROJECT_DIR$/tools/idea/teavm-idea-plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/interop/core/teavm-interop.iml" filepath="$PROJECT_DIR$/interop/core/teavm-interop.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/idea/jps-common/teavm-jps-common.iml" filepath="$PROJECT_DIR$/tools/idea/jps-common/teavm-jps-common.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/idea/jps-plugin/teavm-jps-plugin.iml" filepath="$PROJECT_DIR$/tools/idea/jps-plugin/teavm-jps-plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/jso/core/teavm-jso.iml" filepath="$PROJECT_DIR$/jso/core/teavm-jso.iml" />
<module fileurl="file://$PROJECT_DIR$/jso/apis/teavm-jso-apis.iml" filepath="$PROJECT_DIR$/jso/apis/teavm-jso-apis.iml" />
<module fileurl="file://$PROJECT_DIR$/jso/impl/teavm-jso-impl.iml" filepath="$PROJECT_DIR$/jso/impl/teavm-jso-impl.iml" />

View File

@ -21,5 +21,7 @@
<orderEntry type="module" module-name="teavm-samples-scala" exported="" />
<orderEntry type="module" module-name="teavm-samples-storage" exported="" />
<orderEntry type="module" module-name="teavm-samples-video" exported="" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-runtime:1.0.3" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.0.3" level="project" />
</component>
</module>

View File

@ -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<T> extends TObject implements TAnnotatedElement {
TString name;
@ -67,7 +63,7 @@ public class TClass<T> 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<T> 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);

View File

@ -4,6 +4,7 @@
<facet type="Osmorc" name="OSGi">
<configuration manifestGenerationMode="OsmorcControlled" manifestLocation="" jarfileLocation="teavm-classlib-1.0.0-SNAPSHOT.jar" outputPathType="CompilerOutputPath" bndFileLocation="" bundlorFileLocation="" bundleActivator="" bundleSymbolicName="teavm-classlib" bundleVersion="1.0.0.SNAPSHOT" ignoreFilePattern="" useProjectDefaultManifestFileLocation="true" alwaysRebuildBundleJAR="false" doNotSynchronizeWithMaven="false">
<additionalProperties>
<property key="Bundle-Description" value="TeaVM Java class library emulation" />
<property key="Export-Package" value="org.teavm.classlib.*" />
<property key="Bundle-Name" value="TeaVM Java class library" />
<property key="Include-Resource" value="META-INF/services/org.teavm.vm.spi.TeaVMPlugin=$MODULE_DIR$/src/main/resources/META-INF/services/org.teavm.vm.spi.TeaVMPlugin,META-INF/teavm.properties=$MODULE_DIR$/src/main/resources/META-INF/teavm.properties,html/field_public_obj.png=$MODULE_DIR$/src/main/resources/html/field_public_obj.png,html/methpro_obj.png=$MODULE_DIR$/src/main/resources/html/methpro_obj.png,html/int_obj.png=$MODULE_DIR$/src/main/resources/html/int_obj.png,html/jcl-class.html=$MODULE_DIR$/src/main/resources/html/jcl-class.html,html/enum_obj.png=$MODULE_DIR$/src/main/resources/html/enum_obj.png,html/jcl.css=$MODULE_DIR$/src/main/resources/html/jcl.css,html/field_protected_obj.png=$MODULE_DIR$/src/main/resources/html/field_protected_obj.png,html/class_obj.png=$MODULE_DIR$/src/main/resources/html/class_obj.png,html/package_obj.png=$MODULE_DIR$/src/main/resources/html/package_obj.png,html/methpub_obj.png=$MODULE_DIR$/src/main/resources/html/methpub_obj.png,html/annotation_obj.png=$MODULE_DIR$/src/main/resources/html/annotation_obj.png,html/jcl.html=$MODULE_DIR$/src/main/resources/html/jcl.html,org/teavm/classlib/impl/currency/iso4217.xml=$MODULE_DIR$/src/main/resources/org/teavm/classlib/impl/currency/iso4217.xml,org/teavm/classlib/impl/currency/iso3166.csv=$MODULE_DIR$/src/main/resources/org/teavm/classlib/impl/currency/iso3166.csv,org/teavm/classlib/impl/unicode/UnicodeData.txt=$MODULE_DIR$/src/main/resources/org/teavm/classlib/impl/unicode/UnicodeData.txt,org/teavm/classlib/impl/unicode/cldr-json.zip=$MODULE_DIR$/src/main/resources/org/teavm/classlib/impl/unicode/cldr-json.zip,org/teavm/classlib/impl/tz/tzdata2015d.zip=$MODULE_DIR$/src/main/resources/org/teavm/classlib/impl/tz/tzdata2015d.zip" />

View File

@ -29,6 +29,10 @@
<name>TeaVM core</name>
<description>TeaVM compiler and SPI</description>
<properties>
<kotlin.version>1.0.3</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
@ -63,6 +67,11 @@
<artifactId>objenesis</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
@ -93,6 +102,20 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -575,6 +575,9 @@ public class WasmTarget implements TeaVMTarget {
}
ClassReader cls = classes.get(className);
if (cls == null) {
continue;
}
MethodReader method = cls.getMethod(new MethodDescriptor("<clinit>", void.class));
if (method == null) {
continue;

View File

@ -132,10 +132,12 @@ public class WasmClassGenerator {
String className = ((ValueType.Object) type).getClassName();
ClassReader cls = classSource.get(className);
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();
addClass(itemType);

View File

@ -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());
}

View File

@ -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

View File

@ -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());

View File

@ -185,8 +185,6 @@ public class GcRootMaintainingTransformer {
clearInvocation.getArguments().add(slotVar);
clearInvocation.setLocation(callInstruction.getLocation());
instructionsToAdd.add(clearInvocation);
++slot;
}
instructions.addAll(index, instructionsToAdd);

View File

@ -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;
}

View File

@ -4,6 +4,7 @@
<facet type="Osmorc" name="OSGi">
<configuration manifestGenerationMode="OsmorcControlled" manifestLocation="" jarfileLocation="teavm-core-1.0.0-SNAPSHOT.jar" outputPathType="CompilerOutputPath" bndFileLocation="" bundlorFileLocation="" bundleActivator="" bundleSymbolicName="teavm-core" bundleVersion="1.0.0.SNAPSHOT" ignoreFilePattern="" useProjectDefaultManifestFileLocation="true" alwaysRebuildBundleJAR="false" doNotSynchronizeWithMaven="false">
<additionalProperties>
<property key="Bundle-Description" value="TeaVM compiler and SPI" />
<property key="Export-Package" value="org.teavm.*" />
<property key="Bundle-Name" value="TeaVM core" />
<property key="Include-Resource" value="org/teavm/backend/javascript/runtime.js=$MODULE_DIR$/src/main/resources/org/teavm/backend/javascript/runtime.js" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">

View File

@ -4,6 +4,7 @@
<facet type="Osmorc" name="OSGi">
<configuration manifestGenerationMode="OsmorcControlled" manifestLocation="" jarfileLocation="teavm-metaprogramming-api-1.0.0-SNAPSHOT.jar" outputPathType="CompilerOutputPath" bndFileLocation="" bundlorFileLocation="" bundleActivator="" bundleSymbolicName="teavm-metaprogramming-api" bundleVersion="1.0.0.SNAPSHOT" ignoreFilePattern="" useProjectDefaultManifestFileLocation="true" alwaysRebuildBundleJAR="false" doNotSynchronizeWithMaven="false">
<additionalProperties>
<property key="Bundle-Description" value="Declaration of interfaces and annotations for TeaVM metaprogramming" />
<property key="Export-Package" value="org.teavm.metaprogramming.*" />
<property key="Bundle-Name" value="TeaVM metaprogramming API" />
</additionalProperties>

View File

@ -4,6 +4,7 @@
<facet type="Osmorc" name="OSGi">
<configuration manifestGenerationMode="OsmorcControlled" manifestLocation="" jarfileLocation="teavm-metaprogramming-impl-1.0.0-SNAPSHOT.jar" outputPathType="CompilerOutputPath" bndFileLocation="" bundlorFileLocation="" bundleActivator="" bundleSymbolicName="teavm-metaprogramming-api" bundleVersion="1.0.0.SNAPSHOT" ignoreFilePattern="" useProjectDefaultManifestFileLocation="true" alwaysRebuildBundleJAR="false" doNotSynchronizeWithMaven="false">
<additionalProperties>
<property key="Bundle-Description" value="Implementation of metaprogramming API" />
<property key="Export-Package" value="org.teavm.metaprogramming.*" />
<property key="Bundle-Name" value="TeaVM metaprogramming API implementation" />
<property key="Include-Resource" value="META-INF/services/org.teavm.vm.spi.TeaVMPlugin=$MODULE_DIR$/src/main/resources/META-INF/services/org.teavm.vm.spi.TeaVMPlugin" />

View File

@ -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();
}
}

View File

@ -4,6 +4,7 @@
<facet type="Osmorc" name="OSGi">
<configuration manifestGenerationMode="OsmorcControlled" manifestLocation="" jarfileLocation="teavm-platform-1.0.0-SNAPSHOT.jar" outputPathType="CompilerOutputPath" bndFileLocation="" bundlorFileLocation="" bundleActivator="" bundleSymbolicName="teavm-platform" bundleVersion="1.0.0.SNAPSHOT" ignoreFilePattern="" useProjectDefaultManifestFileLocation="true" alwaysRebuildBundleJAR="false" doNotSynchronizeWithMaven="false">
<additionalProperties>
<property key="Bundle-Description" value="A low-level classes that help to implement Java class library" />
<property key="Export-Package" value="org.teavm.platform.*" />
<property key="Bundle-Name" value="TeaVM platform" />
<property key="Include-Resource" value="META-INF/services/org.teavm.vm.spi.TeaVMPlugin=$MODULE_DIR$/src/main/resources/META-INF/services/org.teavm.vm.spi.TeaVMPlugin" />

View File

@ -30,7 +30,7 @@
<description>A sample application written in Kotlin and compiled by TeaVM</description>
<properties>
<kotlin.version>1.0.1-2</kotlin.version>
<kotlin.version>1.0.3</kotlin.version>
</properties>
<dependencies>

View File

@ -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<String>) {
println("Hello from Kotlin")
}

View File

@ -18,7 +18,7 @@ package org.teavm.samples.kotlin
import org.teavm.jso.browser.*
fun main(args : Array<String>) {
val document = Window.current().document;
val document = Window.current().document
document.getElementById("hello-kotlin").addEventListener("click") { Window.alert("Hello, developer!") }
}

View File

@ -22,8 +22,8 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.0.1-2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains.kotlin:kotlin-runtime:1.0.1-2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.0.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains.kotlin:kotlin-runtime:1.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="module" module-name="teavm-classlib" scope="PROVIDED" />

View File

@ -4,6 +4,7 @@
<facet type="Osmorc" name="OSGi">
<configuration manifestGenerationMode="OsmorcControlled" manifestLocation="" jarfileLocation="teavm-chrome-rdp-1.0.0-SNAPSHOT.jar" outputPathType="CompilerOutputPath" bndFileLocation="" bundlorFileLocation="" bundleActivator="" bundleSymbolicName="teavm-chrome-rdp" bundleVersion="1.0.0.SNAPSHOT" ignoreFilePattern="" useProjectDefaultManifestFileLocation="true" alwaysRebuildBundleJAR="false" doNotSynchronizeWithMaven="false">
<additionalProperties>
<property key="Bundle-Description" value="TeaVM debugging backend for Google Chrome RDP" />
<property key="Export-Package" value="org.teavm.chromerdp" />
<property key="Bundle-Name" value="TeaVM debugging backend for Google Chrome RDP" />
</additionalProperties>

View File

@ -4,6 +4,7 @@
<facet type="Osmorc" name="OSGi">
<configuration manifestGenerationMode="OsmorcControlled" manifestLocation="" jarfileLocation="teavm-tooling-1.0.0-SNAPSHOT.jar" outputPathType="CompilerOutputPath" bndFileLocation="" bundlorFileLocation="" bundleActivator="" bundleSymbolicName="teavm-tooling" bundleVersion="1.0.0.SNAPSHOT" ignoreFilePattern="" useProjectDefaultManifestFileLocation="true" alwaysRebuildBundleJAR="false" doNotSynchronizeWithMaven="false">
<additionalProperties>
<property key="Bundle-Description" value="TeaVM API that helps to create tooling" />
<property key="Export-Package" value="org.teavm.*" />
<property key="Bundle-Name" value="TeaVM tooling core" />
<property key="Include-Resource" value="org/teavm/tooling/test/junit.html=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/junit.html,org/teavm/tooling/test/res/junit.css=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/junit.css,org/teavm/tooling/test/res/tick-small.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/tick-small.png,org/teavm/tooling/test/res/tick-small-red.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/tick-small-red.png,org/teavm/tooling/test/res/toggle-small-expand.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/toggle-small-expand.png,org/teavm/tooling/test/res/control-000-small.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/control-000-small.png,org/teavm/tooling/test/res/junit-support.js=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/junit-support.js,org/teavm/tooling/test/res/class_obj.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/class_obj.png,org/teavm/tooling/test/res/package_obj.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/package_obj.png,org/teavm/tooling/test/res/methpub_obj.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/methpub_obj.png,org/teavm/tooling/test/res/junit-client.js=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/junit-client.js,org/teavm/tooling/test/res/toggle-small.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/toggle-small.png,org/teavm/tooling/test/junit-client.html=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/junit-client.html,org/teavm/tooling/main.html=$MODULE_DIR$/src/main/resources/org/teavm/tooling/main.html" />