From f1da7a417e1c129368be1c7180c8eea72349fa0b Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 11 Apr 2017 23:29:06 +0300 Subject: [PATCH] WASM: preparing to implement metadata API --- .../org/teavm/backend/wasm/TeaVMWasmHost.java | 23 ++++++++ .../org/teavm/backend/wasm/WasmTarget.java | 49 ++++++++++++++++- .../wasm/generate/WasmGenerationVisitor.java | 5 ++ .../wasm/intrinsics/WasmIntrinsicFactory.java | 21 +++++++ .../WasmIntrinsicFactoryContext.java | 30 ++++++++++ .../wasm/intrinsics/WasmIntrinsicManager.java | 3 + .../platform/metadata/BooleanResource.java | 4 -- .../teavm/platform/metadata/ByteResource.java | 4 -- .../platform/metadata/ClassResource.java | 4 -- .../platform/metadata/DoubleResource.java | 4 -- .../platform/metadata/FloatResource.java | 4 -- .../teavm/platform/metadata/IntResource.java | 4 -- .../platform/metadata/ResourceArray.java | 5 -- .../teavm/platform/metadata/ResourceMap.java | 5 -- .../platform/metadata/ShortResource.java | 4 -- .../metadata/StaticFieldResource.java | 4 -- .../platform/metadata/StringResource.java | 4 -- .../DefaultMetadataGeneratorContext.java | 4 -- .../platform/plugin/MetadataIntrinsic.java | 55 +++++++++++++++++++ .../MetadataProviderNativeGenerator.java | 4 -- .../platform/plugin/MetadataProviderRef.java | 4 -- .../teavm/platform/plugin/PlatformPlugin.java | 18 ++++-- .../platform/plugin/ResourceAccessor.java | 4 -- .../ResourceAccessorDependencyListener.java | 4 -- .../plugin/ResourceAccessorGenerator.java | 4 -- .../plugin/ResourceAccessorInjector.java | 4 -- .../plugin/ResourceAccessorTransformer.java | 8 +-- .../platform/plugin/ResourceTransformer.java | 4 -- 28 files changed, 202 insertions(+), 88 deletions(-) create mode 100644 core/src/main/java/org/teavm/backend/wasm/TeaVMWasmHost.java create mode 100644 core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicFactory.java create mode 100644 core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicFactoryContext.java create mode 100644 platform/src/main/java/org/teavm/platform/plugin/MetadataIntrinsic.java diff --git a/core/src/main/java/org/teavm/backend/wasm/TeaVMWasmHost.java b/core/src/main/java/org/teavm/backend/wasm/TeaVMWasmHost.java new file mode 100644 index 000000000..9c881d803 --- /dev/null +++ b/core/src/main/java/org/teavm/backend/wasm/TeaVMWasmHost.java @@ -0,0 +1,23 @@ +/* + * Copyright 2017 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.backend.wasm; + +import org.teavm.backend.wasm.intrinsics.WasmIntrinsicFactory; +import org.teavm.vm.spi.TeaVMHostExtension; + +public interface TeaVMWasmHost extends TeaVMHostExtension { + void add(WasmIntrinsicFactory intrinsicFactory); +} 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 19538bed2..a9d516b3b 100644 --- a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java +++ b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; +import java.util.Properties; import java.util.Set; import org.teavm.ast.decompilation.Decompiler; import org.teavm.backend.wasm.binary.BinaryWriter; @@ -46,6 +47,8 @@ import org.teavm.backend.wasm.intrinsics.PlatformIntrinsic; import org.teavm.backend.wasm.intrinsics.PlatformObjectIntrinsic; import org.teavm.backend.wasm.intrinsics.ShadowStackIntrinsic; import org.teavm.backend.wasm.intrinsics.StructureIntrinsic; +import org.teavm.backend.wasm.intrinsics.WasmIntrinsicFactory; +import org.teavm.backend.wasm.intrinsics.WasmIntrinsicFactoryContext; import org.teavm.backend.wasm.intrinsics.WasmRuntimeIntrinsic; import org.teavm.backend.wasm.model.WasmFunction; import org.teavm.backend.wasm.model.WasmLocal; @@ -76,6 +79,7 @@ import org.teavm.backend.wasm.render.WasmCRenderer; import org.teavm.backend.wasm.render.WasmRenderer; import org.teavm.backend.wasm.transformation.IndirectCallTraceTransformation; import org.teavm.backend.wasm.transformation.MemoryAccessTraceTransformation; +import org.teavm.common.ServiceRepository; import org.teavm.dependency.ClassDependency; import org.teavm.dependency.DependencyChecker; import org.teavm.dependency.DependencyListener; @@ -89,6 +93,7 @@ import org.teavm.model.CallLocation; import org.teavm.model.ClassHolder; import org.teavm.model.ClassHolderTransformer; import org.teavm.model.ClassReader; +import org.teavm.model.ClassReaderSource; import org.teavm.model.ElementModifier; import org.teavm.model.FieldReader; import org.teavm.model.FieldReference; @@ -122,7 +127,7 @@ import org.teavm.vm.TeaVMTarget; import org.teavm.vm.TeaVMTargetController; import org.teavm.vm.spi.TeaVMHostExtension; -public class WasmTarget implements TeaVMTarget { +public class WasmTarget implements TeaVMTarget, TeaVMWasmHost { private TeaVMTargetController controller; private boolean debugging; private boolean wastEmitted; @@ -132,6 +137,7 @@ public class WasmTarget implements TeaVMTarget { private ClassInitializerTransformer classInitializerTransformer; private ShadowStackTransformer shadowStackTransformer; private WasmBinaryVersion version = WasmBinaryVersion.V_0x1; + private List additionalIntrinsics = new ArrayList<>(); @Override public void setController(TeaVMTargetController controller) { @@ -142,9 +148,14 @@ public class WasmTarget implements TeaVMTarget { clinitInsertionTransformer = new ClassInitializerInsertionTransformer(controller.getUnprocessedClassSource()); } + @Override + public void add(WasmIntrinsicFactory intrinsic) { + additionalIntrinsics.add(intrinsic); + } + @Override public List getHostExtensions() { - return Collections.emptyList(); + return Collections.singletonList(this); } @Override @@ -296,6 +307,12 @@ public class WasmTarget implements TeaVMTarget { context.addIntrinsic(new PlatformClassIntrinsic()); context.addIntrinsic(new PlatformObjectIntrinsic(classGenerator)); context.addIntrinsic(new ClassIntrinsic()); + + IntrinsicFactoryContext intrinsicFactoryContext = new IntrinsicFactoryContext(classes); + for (WasmIntrinsicFactory additionalIntrinsicFactory : additionalIntrinsics) { + context.addIntrinsic(additionalIntrinsicFactory.create(intrinsicFactoryContext)); + } + GCIntrinsic gcIntrinsic = new GCIntrinsic(); context.addIntrinsic(gcIntrinsic); MutatorIntrinsic mutatorIntrinsic = new MutatorIntrinsic(); @@ -379,6 +396,34 @@ public class WasmTarget implements TeaVMTarget { } } + private class IntrinsicFactoryContext implements WasmIntrinsicFactoryContext { + private ClassReaderSource classSource; + + public IntrinsicFactoryContext(ClassReaderSource classSource) { + this.classSource = classSource; + } + + @Override + public ClassReaderSource getClassSource() { + return classSource; + } + + @Override + public ClassLoader getClassLoader() { + return controller.getClassLoader(); + } + + @Override + public ServiceRepository getServices() { + return controller.getServices(); + } + + @Override + public Properties getProperties() { + return controller.getProperties(); + } + } + private String getBaseName(String name) { int index = name.lastIndexOf('.'); return index < 0 ? name : name.substring(0, index); diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java index 3717068fe..6209bf729 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java @@ -1529,6 +1529,11 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor { accept(expr); return result; } + + @Override + public BinaryWriter getBinaryWriter() { + return binaryWriter; + } }; private WasmLocal getTemporary(WasmType type) { diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicFactory.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicFactory.java new file mode 100644 index 000000000..7d016acfa --- /dev/null +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicFactory.java @@ -0,0 +1,21 @@ +/* + * Copyright 2017 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.backend.wasm.intrinsics; + +@FunctionalInterface +public interface WasmIntrinsicFactory { + WasmIntrinsic create(WasmIntrinsicFactoryContext context); +} diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicFactoryContext.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicFactoryContext.java new file mode 100644 index 000000000..c9012aef1 --- /dev/null +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicFactoryContext.java @@ -0,0 +1,30 @@ +/* + * Copyright 2017 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.backend.wasm.intrinsics; + +import java.util.Properties; +import org.teavm.common.ServiceRepository; +import org.teavm.model.ClassReaderSource; + +public interface WasmIntrinsicFactoryContext { + ClassReaderSource getClassSource(); + + ClassLoader getClassLoader(); + + ServiceRepository getServices(); + + Properties getProperties(); +} diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicManager.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicManager.java index 469cb5a50..570e0ec4e 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicManager.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/WasmIntrinsicManager.java @@ -16,8 +16,11 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.Expr; +import org.teavm.backend.wasm.binary.BinaryWriter; import org.teavm.backend.wasm.model.expression.WasmExpression; public interface WasmIntrinsicManager { WasmExpression generate(Expr expr); + + BinaryWriter getBinaryWriter(); } diff --git a/platform/src/main/java/org/teavm/platform/metadata/BooleanResource.java b/platform/src/main/java/org/teavm/platform/metadata/BooleanResource.java index ebf4bf6f7..b3301c27f 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/BooleanResource.java +++ b/platform/src/main/java/org/teavm/platform/metadata/BooleanResource.java @@ -15,10 +15,6 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - */ public interface BooleanResource extends Resource { boolean getValue(); diff --git a/platform/src/main/java/org/teavm/platform/metadata/ByteResource.java b/platform/src/main/java/org/teavm/platform/metadata/ByteResource.java index 582cda32b..cc4a430c0 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/ByteResource.java +++ b/platform/src/main/java/org/teavm/platform/metadata/ByteResource.java @@ -15,10 +15,6 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - */ public interface ByteResource extends Resource { byte getValue(); diff --git a/platform/src/main/java/org/teavm/platform/metadata/ClassResource.java b/platform/src/main/java/org/teavm/platform/metadata/ClassResource.java index 71e1525db..d7a40bfd9 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/ClassResource.java +++ b/platform/src/main/java/org/teavm/platform/metadata/ClassResource.java @@ -15,9 +15,5 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - */ public interface ClassResource extends Resource { } diff --git a/platform/src/main/java/org/teavm/platform/metadata/DoubleResource.java b/platform/src/main/java/org/teavm/platform/metadata/DoubleResource.java index 2d728fdf5..1285d6343 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/DoubleResource.java +++ b/platform/src/main/java/org/teavm/platform/metadata/DoubleResource.java @@ -15,10 +15,6 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - */ public interface DoubleResource extends Resource { double getValue(); diff --git a/platform/src/main/java/org/teavm/platform/metadata/FloatResource.java b/platform/src/main/java/org/teavm/platform/metadata/FloatResource.java index 4c159052c..afaf5f275 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/FloatResource.java +++ b/platform/src/main/java/org/teavm/platform/metadata/FloatResource.java @@ -15,10 +15,6 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - */ public interface FloatResource extends Resource { float getValue(); diff --git a/platform/src/main/java/org/teavm/platform/metadata/IntResource.java b/platform/src/main/java/org/teavm/platform/metadata/IntResource.java index 574b84192..aa00bad15 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/IntResource.java +++ b/platform/src/main/java/org/teavm/platform/metadata/IntResource.java @@ -15,10 +15,6 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - */ public interface IntResource extends Resource { int getValue(); diff --git a/platform/src/main/java/org/teavm/platform/metadata/ResourceArray.java b/platform/src/main/java/org/teavm/platform/metadata/ResourceArray.java index 8a0f1b23b..e76faf695 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/ResourceArray.java +++ b/platform/src/main/java/org/teavm/platform/metadata/ResourceArray.java @@ -15,11 +15,6 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - * @param - */ public interface ResourceArray extends Resource { int size(); diff --git a/platform/src/main/java/org/teavm/platform/metadata/ResourceMap.java b/platform/src/main/java/org/teavm/platform/metadata/ResourceMap.java index a3bfcc157..c78510522 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/ResourceMap.java +++ b/platform/src/main/java/org/teavm/platform/metadata/ResourceMap.java @@ -15,11 +15,6 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - * @param - */ public interface ResourceMap extends Resource { boolean has(String key); diff --git a/platform/src/main/java/org/teavm/platform/metadata/ShortResource.java b/platform/src/main/java/org/teavm/platform/metadata/ShortResource.java index c0a31ba68..1aa087c71 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/ShortResource.java +++ b/platform/src/main/java/org/teavm/platform/metadata/ShortResource.java @@ -15,10 +15,6 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - */ public interface ShortResource extends Resource { short getValue(); diff --git a/platform/src/main/java/org/teavm/platform/metadata/StaticFieldResource.java b/platform/src/main/java/org/teavm/platform/metadata/StaticFieldResource.java index 5bfdcead5..592b68d96 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/StaticFieldResource.java +++ b/platform/src/main/java/org/teavm/platform/metadata/StaticFieldResource.java @@ -15,9 +15,5 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - */ public interface StaticFieldResource extends Resource { } diff --git a/platform/src/main/java/org/teavm/platform/metadata/StringResource.java b/platform/src/main/java/org/teavm/platform/metadata/StringResource.java index a48754b30..1a8bf619d 100644 --- a/platform/src/main/java/org/teavm/platform/metadata/StringResource.java +++ b/platform/src/main/java/org/teavm/platform/metadata/StringResource.java @@ -15,10 +15,6 @@ */ package org.teavm.platform.metadata; -/** - * - * @author Alexey Andreev - */ public interface StringResource extends Resource { String getValue(); diff --git a/platform/src/main/java/org/teavm/platform/plugin/DefaultMetadataGeneratorContext.java b/platform/src/main/java/org/teavm/platform/plugin/DefaultMetadataGeneratorContext.java index 35a1b08eb..edfbd5f0f 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/DefaultMetadataGeneratorContext.java +++ b/platform/src/main/java/org/teavm/platform/plugin/DefaultMetadataGeneratorContext.java @@ -22,10 +22,6 @@ import org.teavm.model.FieldReference; import org.teavm.model.ListableClassReaderSource; import org.teavm.platform.metadata.*; -/** - * - * @author Alexey Andreev - */ class DefaultMetadataGeneratorContext implements MetadataGeneratorContext { private ListableClassReaderSource classSource; private ClassLoader classLoader; diff --git a/platform/src/main/java/org/teavm/platform/plugin/MetadataIntrinsic.java b/platform/src/main/java/org/teavm/platform/plugin/MetadataIntrinsic.java new file mode 100644 index 000000000..fc00a3b0f --- /dev/null +++ b/platform/src/main/java/org/teavm/platform/plugin/MetadataIntrinsic.java @@ -0,0 +1,55 @@ +/* + * Copyright 2017 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.platform.plugin; + +import java.util.Properties; +import org.teavm.ast.InvocationExpr; +import org.teavm.backend.wasm.intrinsics.WasmIntrinsic; +import org.teavm.backend.wasm.intrinsics.WasmIntrinsicManager; +import org.teavm.backend.wasm.model.expression.WasmExpression; +import org.teavm.model.AnnotationReader; +import org.teavm.model.ClassReader; +import org.teavm.model.ClassReaderSource; +import org.teavm.model.MethodReference; +import org.teavm.platform.metadata.MetadataProvider; + +public class MetadataIntrinsic implements WasmIntrinsic { + private ClassReaderSource classSource; + private ClassLoader classLoader; + private Properties properties; + + public MetadataIntrinsic(ClassReaderSource classSource, ClassLoader classLoader, Properties properties) { + this.classSource = classSource; + this.classLoader = classLoader; + this.properties = properties; + } + + @Override + public boolean isApplicable(MethodReference methodReference) { + ClassReader cls = classSource.get(methodReference.getClassName()); + if (cls == null) { + return false; + } + + AnnotationReader annot = cls.getAnnotations().get(MetadataProvider.class.getName()); + return annot != null; + } + + @Override + public WasmExpression apply(InvocationExpr invocation, WasmIntrinsicManager manager) { + return null; + } +} diff --git a/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderNativeGenerator.java b/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderNativeGenerator.java index 74f7ccd02..803c6ee47 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderNativeGenerator.java +++ b/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderNativeGenerator.java @@ -26,10 +26,6 @@ import org.teavm.platform.metadata.MetadataGenerator; import org.teavm.platform.metadata.MetadataProvider; import org.teavm.platform.metadata.Resource; -/** - * - * @author Alexey Andreev - */ public class MetadataProviderNativeGenerator implements Generator { @Override public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException { diff --git a/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderRef.java b/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderRef.java index 2f8f560b6..72d7443d1 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderRef.java +++ b/platform/src/main/java/org/teavm/platform/plugin/MetadataProviderRef.java @@ -20,10 +20,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * - * @author Alexey Andreev - */ @Retention(RetentionPolicy.CLASS) @Target(ElementType.METHOD) @interface MetadataProviderRef { diff --git a/platform/src/main/java/org/teavm/platform/plugin/PlatformPlugin.java b/platform/src/main/java/org/teavm/platform/plugin/PlatformPlugin.java index 34b51f4fb..b4f230c42 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/PlatformPlugin.java +++ b/platform/src/main/java/org/teavm/platform/plugin/PlatformPlugin.java @@ -15,16 +15,26 @@ */ package org.teavm.platform.plugin; +import org.teavm.backend.javascript.TeaVMJavaScriptHost; +import org.teavm.backend.wasm.TeaVMWasmHost; import org.teavm.vm.spi.TeaVMHost; import org.teavm.vm.spi.TeaVMPlugin; public class PlatformPlugin implements TeaVMPlugin { @Override public void install(TeaVMHost host) { - host.add(new MetadataProviderTransformer()); - host.add(new ResourceTransformer()); - host.add(new ResourceAccessorTransformer(host)); - host.add(new ResourceAccessorDependencyListener()); + if (host.getExtension(TeaVMJavaScriptHost.class) != null) { + host.add(new MetadataProviderTransformer()); + host.add(new ResourceTransformer()); + host.add(new ResourceAccessorTransformer(host)); + host.add(new ResourceAccessorDependencyListener()); + } + + TeaVMWasmHost wasmHost = host.getExtension(TeaVMWasmHost.class); + if (wasmHost != null) { + wasmHost.add(ctx -> new MetadataIntrinsic(ctx.getClassSource(), ctx.getClassLoader(), ctx.getProperties())); + } + host.add(new AsyncMethodProcessor()); host.add(new NewInstanceDependencySupport()); host.add(new ClassLookupDependencySupport()); diff --git a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessor.java b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessor.java index bd93c1078..7a1da64e2 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessor.java +++ b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessor.java @@ -17,10 +17,6 @@ package org.teavm.platform.plugin; import org.teavm.platform.metadata.Resource; -/** - * - * @author Alexey Andreev - */ final class ResourceAccessor { private ResourceAccessor() { } diff --git a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorDependencyListener.java b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorDependencyListener.java index c4eaad07c..b97398ae7 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorDependencyListener.java +++ b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorDependencyListener.java @@ -20,10 +20,6 @@ import org.teavm.dependency.DependencyAgent; import org.teavm.dependency.MethodDependency; import org.teavm.model.CallLocation; -/** - * - * @author Alexey Andreev - */ class ResourceAccessorDependencyListener extends AbstractDependencyListener { @Override public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { diff --git a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorGenerator.java b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorGenerator.java index 5e4b48f9b..23ceebd11 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorGenerator.java +++ b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorGenerator.java @@ -21,10 +21,6 @@ import org.teavm.backend.javascript.spi.Generator; import org.teavm.backend.javascript.spi.GeneratorContext; import org.teavm.model.MethodReference; -/** - * - * @author Alexey Andreev - */ class ResourceAccessorGenerator implements Generator { @Override public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException { diff --git a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorInjector.java b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorInjector.java index 646126e92..f91115782 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorInjector.java +++ b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorInjector.java @@ -23,10 +23,6 @@ import org.teavm.backend.javascript.spi.InjectorContext; import org.teavm.model.MethodReference; import org.teavm.model.ValueType; -/** - * - * @author Alexey Andreev - */ class ResourceAccessorInjector implements Injector { @Override public void generate(InjectorContext context, MethodReference methodRef) throws IOException { diff --git a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorTransformer.java b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorTransformer.java index 27f5c8d0d..fa0cefb44 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorTransformer.java +++ b/platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorTransformer.java @@ -25,10 +25,10 @@ import org.teavm.model.MethodHolder; import org.teavm.vm.spi.TeaVMHost; class ResourceAccessorTransformer implements ClassHolderTransformer { - private TeaVMJavaScriptHost vm; + private TeaVMJavaScriptHost jsHost; public ResourceAccessorTransformer(TeaVMHost vm) { - this.vm = vm.getExtension(TeaVMJavaScriptHost.class); + this.jsHost = vm.getExtension(TeaVMJavaScriptHost.class); } @Override @@ -38,9 +38,9 @@ class ResourceAccessorTransformer implements ClassHolderTransformer { for (MethodHolder method : cls.getMethods()) { if (method.hasModifier(ElementModifier.NATIVE)) { if (method.getName().equals("keys")) { - vm.add(method.getReference(), new ResourceAccessorGenerator()); + jsHost.add(method.getReference(), new ResourceAccessorGenerator()); } else { - vm.add(method.getReference(), injector); + jsHost.add(method.getReference(), injector); } } } diff --git a/platform/src/main/java/org/teavm/platform/plugin/ResourceTransformer.java b/platform/src/main/java/org/teavm/platform/plugin/ResourceTransformer.java index 1c37ea35b..bcddb82b0 100644 --- a/platform/src/main/java/org/teavm/platform/plugin/ResourceTransformer.java +++ b/platform/src/main/java/org/teavm/platform/plugin/ResourceTransformer.java @@ -18,10 +18,6 @@ package org.teavm.platform.plugin; import org.teavm.diagnostics.Diagnostics; import org.teavm.model.*; -/** - * - * @author Alexey Andreev - */ class ResourceTransformer implements ClassHolderTransformer { @Override public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) {