Move metaprogramming API implementation into separate module

This commit is contained in:
Alexey Andreev 2016-04-12 22:54:32 +03:00
parent 74a0278881
commit f63ec25ed3
60 changed files with 212 additions and 82 deletions

View File

@ -26,6 +26,7 @@
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" /> <outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" /> <processorPath useClasspath="true" />
<module name="impl" />
<module name="teavm-chrome-rdp" /> <module name="teavm-chrome-rdp" />
<module name="teavm-classlib" /> <module name="teavm-classlib" />
<module name="teavm-cli" /> <module name="teavm-cli" />
@ -52,6 +53,7 @@
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel> <bytecodeTargetLevel>
<module name="impl" target="1.8" />
<module name="teavm" target="1.5" /> <module name="teavm" target="1.5" />
<module name="teavm-chrome-rdp" target="1.8" /> <module name="teavm-chrome-rdp" target="1.8" />
<module name="teavm-classlib" target="1.8" /> <module name="teavm-classlib" target="1.8" />

View File

@ -9,7 +9,8 @@
<file url="file://$PROJECT_DIR$/jso/apis" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/jso/apis" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/jso/core" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/jso/core" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/jso/impl" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/jso/impl" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/metaprogramming-api" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/metaprogramming/api" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/metaprogramming/impl" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/platform" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/platform" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/samples" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/samples" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/samples/async" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/samples/async" charset="UTF-8" />

View File

@ -45,7 +45,8 @@
<file type="gwt" url="file://$PROJECT_DIR$/samples/benchmark" /> <file type="gwt" url="file://$PROJECT_DIR$/samples/benchmark" />
<file type="Osmorc" url="file://$PROJECT_DIR$/classlib" /> <file type="Osmorc" url="file://$PROJECT_DIR$/classlib" />
<file type="Osmorc" url="file://$PROJECT_DIR$/core" /> <file type="Osmorc" url="file://$PROJECT_DIR$/core" />
<file type="Osmorc" url="file://$PROJECT_DIR$/metaprogramming-api" /> <file type="Osmorc" url="file://$PROJECT_DIR$/metaprogramming/api" />
<file type="Osmorc" url="file://$PROJECT_DIR$/metaprogramming/impl" />
<file type="Osmorc" url="file://$PROJECT_DIR$/platform" /> <file type="Osmorc" url="file://$PROJECT_DIR$/platform" />
<file type="Osmorc" url="file://$PROJECT_DIR$/tools/chrome-rdp" /> <file type="Osmorc" url="file://$PROJECT_DIR$/tools/chrome-rdp" />
<file type="Osmorc" url="file://$PROJECT_DIR$/tools/core" /> <file type="Osmorc" url="file://$PROJECT_DIR$/tools/core" />

View File

@ -3,6 +3,7 @@
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/all-deps/all-deps.iml" filepath="$PROJECT_DIR$/all-deps/all-deps.iml" /> <module fileurl="file://$PROJECT_DIR$/all-deps/all-deps.iml" filepath="$PROJECT_DIR$/all-deps/all-deps.iml" />
<module fileurl="file://$PROJECT_DIR$/metaprogramming/impl/impl.iml" filepath="$PROJECT_DIR$/metaprogramming/impl/impl.iml" />
<module fileurl="file://$PROJECT_DIR$/teavm.iml" filepath="$PROJECT_DIR$/teavm.iml" /> <module fileurl="file://$PROJECT_DIR$/teavm.iml" filepath="$PROJECT_DIR$/teavm.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/chrome-rdp/teavm-chrome-rdp.iml" filepath="$PROJECT_DIR$/tools/chrome-rdp/teavm-chrome-rdp.iml" /> <module fileurl="file://$PROJECT_DIR$/tools/chrome-rdp/teavm-chrome-rdp.iml" filepath="$PROJECT_DIR$/tools/chrome-rdp/teavm-chrome-rdp.iml" />
<module fileurl="file://$PROJECT_DIR$/classlib/teavm-classlib.iml" filepath="$PROJECT_DIR$/classlib/teavm-classlib.iml" /> <module fileurl="file://$PROJECT_DIR$/classlib/teavm-classlib.iml" filepath="$PROJECT_DIR$/classlib/teavm-classlib.iml" />
@ -19,7 +20,7 @@
<module fileurl="file://$PROJECT_DIR$/tools/maven/teavm-maven.iml" filepath="$PROJECT_DIR$/tools/maven/teavm-maven.iml" /> <module fileurl="file://$PROJECT_DIR$/tools/maven/teavm-maven.iml" filepath="$PROJECT_DIR$/tools/maven/teavm-maven.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/maven/plugin/teavm-maven-plugin.iml" filepath="$PROJECT_DIR$/tools/maven/plugin/teavm-maven-plugin.iml" /> <module fileurl="file://$PROJECT_DIR$/tools/maven/plugin/teavm-maven-plugin.iml" filepath="$PROJECT_DIR$/tools/maven/plugin/teavm-maven-plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/maven/webapp/teavm-maven-webapp.iml" filepath="$PROJECT_DIR$/tools/maven/webapp/teavm-maven-webapp.iml" /> <module fileurl="file://$PROJECT_DIR$/tools/maven/webapp/teavm-maven-webapp.iml" filepath="$PROJECT_DIR$/tools/maven/webapp/teavm-maven-webapp.iml" />
<module fileurl="file://$PROJECT_DIR$/metaprogramming-api/teavm-metaprogramming-api.iml" filepath="$PROJECT_DIR$/metaprogramming-api/teavm-metaprogramming-api.iml" /> <module fileurl="file://$PROJECT_DIR$/metaprogramming/api/teavm-metaprogramming-api.iml" filepath="$PROJECT_DIR$/metaprogramming/api/teavm-metaprogramming-api.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/teavm-platform.iml" filepath="$PROJECT_DIR$/platform/teavm-platform.iml" /> <module fileurl="file://$PROJECT_DIR$/platform/teavm-platform.iml" filepath="$PROJECT_DIR$/platform/teavm-platform.iml" />
<module fileurl="file://$PROJECT_DIR$/samples/teavm-samples.iml" filepath="$PROJECT_DIR$/samples/teavm-samples.iml" /> <module fileurl="file://$PROJECT_DIR$/samples/teavm-samples.iml" filepath="$PROJECT_DIR$/samples/teavm-samples.iml" />
<module fileurl="file://$PROJECT_DIR$/samples/async/teavm-samples-async.iml" filepath="$PROJECT_DIR$/samples/async/teavm-samples-async.iml" /> <module fileurl="file://$PROJECT_DIR$/samples/async/teavm-samples-async.iml" filepath="$PROJECT_DIR$/samples/async/teavm-samples-async.iml" />

View File

@ -14,7 +14,7 @@
<property key="Bundle-Description" value="TeaVM Java class library emulation" /> <property key="Bundle-Description" value="TeaVM Java class library emulation" />
<property key="Export-Package" value="org.teavm.classlib.*" /> <property key="Export-Package" value="org.teavm.classlib.*" />
<property key="Bundle-Name" value="TeaVM Java class library" /> <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" /> <property key="Include-Resource" value="html/jcl.html=$MODULE_DIR$/src/main/resources/html/jcl.html,html/annotation_obj.png=$MODULE_DIR$/src/main/resources/html/annotation_obj.png,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/package_obj.png=$MODULE_DIR$/src/main/resources/html/package_obj.png,html/field_public_obj.png=$MODULE_DIR$/src/main/resources/html/field_public_obj.png,html/class_obj.png=$MODULE_DIR$/src/main/resources/html/class_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/methpro_obj.png=$MODULE_DIR$/src/main/resources/html/methpro_obj.png,html/methpub_obj.png=$MODULE_DIR$/src/main/resources/html/methpub_obj.png,html/field_protected_obj.png=$MODULE_DIR$/src/main/resources/html/field_protected_obj.png,META-INF/teavm.properties=$MODULE_DIR$/src/main/resources/META-INF/teavm.properties,META-INF/services/org.teavm.vm.spi.TeaVMPlugin=$MODULE_DIR$/src/main/resources/META-INF/services/org.teavm.vm.spi.TeaVMPlugin,org/teavm/classlib/impl/tz/tzdata2015d.zip=$MODULE_DIR$/src/main/resources/org/teavm/classlib/impl/tz/tzdata2015d.zip,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" />
</additionalProperties> </additionalProperties>
<additionalJARContents /> <additionalJARContents />
</configuration> </configuration>

View File

@ -31,7 +31,6 @@ import org.teavm.javascript.spi.GeneratedBy;
import org.teavm.javascript.spi.Generator; import org.teavm.javascript.spi.Generator;
import org.teavm.javascript.spi.InjectedBy; import org.teavm.javascript.spi.InjectedBy;
import org.teavm.javascript.spi.Injector; import org.teavm.javascript.spi.Injector;
import org.teavm.metaprogramming.impl.MetaprogrammingDependencyListener;
import org.teavm.model.*; import org.teavm.model.*;
import org.teavm.model.instructions.*; import org.teavm.model.instructions.*;
import org.teavm.model.util.*; import org.teavm.model.util.*;
@ -356,8 +355,6 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
return; return;
} }
dependencyChecker.addDependencyListener(new MetaprogrammingDependencyListener());
AliasProvider aliasProvider = minifying ? new MinifyingAliasProvider() : new DefaultAliasProvider(); AliasProvider aliasProvider = minifying ? new MinifyingAliasProvider() : new DefaultAliasProvider();
dependencyChecker.setInterruptor(() -> progressListener.progressReached(0) == TeaVMProgressFeedback.CONTINUE); dependencyChecker.setInterruptor(() -> progressListener.progressReached(0) == TeaVMProgressFeedback.CONTINUE);
dependencyChecker.linkMethod(new MethodReference(Class.class.getName(), "getClass", dependencyChecker.linkMethod(new MethodReference(Class.class.getName(), "getClass",

View File

@ -24,6 +24,7 @@
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm</artifactId> <artifactId>teavm</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent> </parent>
<artifactId>teavm-metaprogramming-api</artifactId> <artifactId>teavm-metaprogramming-api</artifactId>
@ -46,7 +47,8 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<configuration> <configuration>
<configLocation>../checkstyle.xml</configLocation> <configLocation>../../checkstyle.xml</configLocation>
<propertyExpansion>config_loc=${basedir}/../..</propertyExpansion>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>

View File

@ -66,6 +66,7 @@ public class SourceLocation {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(method.getName()); sb.append(method.getName());
return lineNumber > 0 ? fileName + ":" + lineNumber : fileName; sb.append(lineNumber > 0 ? fileName + ":" + lineNumber : fileName);
return sb.toString();
} }
} }

View File

@ -17,7 +17,6 @@
<output-test url="file://$MODULE_DIR$/target/test-classes" /> <output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<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" />
</additionalProperties>
<additionalJARContents />
</configuration>
</facet>
</component>
<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$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="teavm-core" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm-debug-all:5.0.4" level="project" />
<orderEntry type="library" name="Maven: com.carrotsearch:hppc:0.6.1" level="project" />
<orderEntry type="module" module-name="teavm-metaprogramming-api" />
<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" />
</component>
</module>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2016 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.
-->
<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">
<parent>
<artifactId>teavm</artifactId>
<groupId>org.teavm</groupId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teavm-metaprogramming-impl</artifactId>
<packaging>bundle</packaging>
<name>TeaVM metaprogramming API implementation</name>
<description>Implementation of metaprogramming API</description>
<dependencies>
<dependency>
<groupId>org.teavm</groupId>
<artifactId>teavm-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.teavm</groupId>
<artifactId>teavm-metaprogramming-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>../../checkstyle.xml</configLocation>
<propertyExpansion>config_loc=${basedir}/../..</propertyExpansion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.teavm.metaprogramming.*</Export-Package>
<Bundle-SymbolicName>teavm-metaprogramming-api</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -42,16 +42,11 @@ import org.teavm.model.instructions.InvocationType;
import org.teavm.model.instructions.NumericOperandType; import org.teavm.model.instructions.NumericOperandType;
import org.teavm.model.instructions.SwitchTableEntryReader; import org.teavm.model.instructions.SwitchTableEntryReader;
/** class AliasFinder {
* private int[] aliases;
* @author Alexey Andreev private ArrayElement[] arrayElements;
*/
public class AliasFinder {
int[] aliases;
Object[] constants;
ArrayElement[] arrayElements;
public void findAliases(ProgramReader program) { void findAliases(ProgramReader program) {
DisjointSet set = new DisjointSet(); DisjointSet set = new DisjointSet();
for (int i = 0; i < program.variableCount(); ++i) { for (int i = 0; i < program.variableCount(); ++i) {
set.create(); set.create();
@ -85,7 +80,7 @@ public class AliasFinder {
} }
aliases = variables; aliases = variables;
constants = reader.constants; Object[] constants = reader.constants;
arrayElements = reader.arrayElements; arrayElements = reader.arrayElements;
for (int i = 0; i < arrayElements.length; ++i) { for (int i = 0; i < arrayElements.length; ++i) {
@ -102,29 +97,25 @@ public class AliasFinder {
} }
} }
public static class ArrayElement { static class ArrayElement {
public int array; public int array;
public int index; public int index;
} }
public int[] getAliases() { int[] getAliases() {
return aliases.clone(); return aliases.clone();
} }
public Object[] getConstants() { ArrayElement[] getArrayElements() {
return constants.clone();
}
public ArrayElement[] getArrayElements() {
return arrayElements.clone(); return arrayElements.clone();
} }
static class AliasReader implements InstructionReader { private static class AliasReader implements InstructionReader {
DisjointSet disjointSet; DisjointSet disjointSet;
Object[] constants; Object[] constants;
ArrayElement[] arrayElements; ArrayElement[] arrayElements;
AliasReader(DisjointSet disjointSet, int variableCount) { private AliasReader(DisjointSet disjointSet, int variableCount) {
this.disjointSet = disjointSet; this.disjointSet = disjointSet;
this.constants = new Object[variableCount]; this.constants = new Object[variableCount];
this.arrayElements = new ArrayElement[variableCount]; this.arrayElements = new ArrayElement[variableCount];

View File

@ -26,7 +26,6 @@ import java.util.stream.Stream;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.metaprogramming.ReflectClass; import org.teavm.metaprogramming.ReflectClass;
import org.teavm.metaprogramming.Value; import org.teavm.metaprogramming.Value;
import org.teavm.metaprogramming.impl.AliasFinder.ArrayElement;
import org.teavm.metaprogramming.impl.reflect.ReflectClassImpl; import org.teavm.metaprogramming.impl.reflect.ReflectClassImpl;
import org.teavm.metaprogramming.impl.reflect.ReflectFieldImpl; import org.teavm.metaprogramming.impl.reflect.ReflectFieldImpl;
import org.teavm.metaprogramming.impl.reflect.ReflectMethodImpl; import org.teavm.metaprogramming.impl.reflect.ReflectMethodImpl;
@ -454,10 +453,10 @@ public class CompositeMethodGenerator {
private int variableOffset; private int variableOffset;
int[] variableMapping; int[] variableMapping;
CapturedValue[] capturedValues; CapturedValue[] capturedValues;
ArrayElement[] arrayElements; AliasFinder.ArrayElement[] arrayElements;
TemplateSubstitutor(CapturedValue[] capturedValues, int[] variableMapping, ArrayElement[] arrayElements, TemplateSubstitutor(CapturedValue[] capturedValues, int[] variableMapping,
int blockOffset, int variableOffset) { AliasFinder.ArrayElement[] arrayElements, int blockOffset, int variableOffset) {
this.capturedValues = capturedValues; this.capturedValues = capturedValues;
this.variableMapping = variableMapping; this.variableMapping = variableMapping;
this.arrayElements = arrayElements; this.arrayElements = arrayElements;
@ -482,7 +481,7 @@ public class CompositeMethodGenerator {
if (capturedValues[index] != null) { if (capturedValues[index] != null) {
return captureValue(capturedValues[index]); return captureValue(capturedValues[index]);
} }
ArrayElement elem = arrayElements[index]; AliasFinder.ArrayElement elem = arrayElements[index];
if (elem != null) { if (elem != null) {
int arrayVar = variableMapping[elem.array]; int arrayVar = variableMapping[elem.array];
if (capturedValues[arrayVar] != null) { if (capturedValues[arrayVar] != null) {
@ -770,7 +769,7 @@ public class CompositeMethodGenerator {
public void getElement(VariableReader receiver, VariableReader array, VariableReader index) { public void getElement(VariableReader receiver, VariableReader array, VariableReader index) {
int arrayIndex = variableMapping[array.getIndex()]; int arrayIndex = variableMapping[array.getIndex()];
ArrayElement elem = arrayElements[receiver.getIndex()]; AliasFinder.ArrayElement elem = arrayElements[receiver.getIndex()];
if (elem != null && capturedValues[arrayIndex] != null) { if (elem != null && capturedValues[arrayIndex] != null) {
AssignInstruction insn = new AssignInstruction(); AssignInstruction insn = new AssignInstruction();
insn.setAssignee(var(receiver)); insn.setAssignee(var(receiver));

View File

@ -20,10 +20,6 @@ import org.teavm.metaprogramming.Value;
import org.teavm.model.InstructionLocation; import org.teavm.model.InstructionLocation;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
/**
*
* @author Alexey Andreev
*/
public class LazyValueImpl<T> implements Value<T> { public class LazyValueImpl<T> implements Value<T> {
boolean evaluated; boolean evaluated;
VariableContext context; VariableContext context;

View File

@ -26,6 +26,7 @@ import org.teavm.metaprogramming.LazyComputation;
import org.teavm.metaprogramming.ReflectClass; import org.teavm.metaprogramming.ReflectClass;
import org.teavm.metaprogramming.SourceLocation; import org.teavm.metaprogramming.SourceLocation;
import org.teavm.metaprogramming.Value; import org.teavm.metaprogramming.Value;
import org.teavm.metaprogramming.impl.optimization.Optimizations;
import org.teavm.metaprogramming.impl.reflect.ReflectClassImpl; import org.teavm.metaprogramming.impl.reflect.ReflectClassImpl;
import org.teavm.metaprogramming.impl.reflect.ReflectContext; import org.teavm.metaprogramming.impl.reflect.ReflectContext;
import org.teavm.metaprogramming.impl.reflect.ReflectFieldImpl; import org.teavm.metaprogramming.impl.reflect.ReflectFieldImpl;
@ -277,7 +278,7 @@ public final class MetaprogrammingImpl {
jumpToStart.setTarget(program.basicBlockAt(startBlock.getIndex() + 1)); jumpToStart.setTarget(program.basicBlockAt(startBlock.getIndex() + 1));
startBlock.getInstructions().add(jumpToStart); startBlock.getInstructions().add(jumpToStart);
//new BoxingEliminator().optimize(program); new Optimizations().apply(program);
cls.addMethod(methodHolder); cls.addMethod(methodHolder);
} finally { } finally {
returnType = returnTypeBackup; returnType = returnTypeBackup;

View File

@ -0,0 +1,26 @@
/*
* Copyright 2016 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.metaprogramming.impl;
import org.teavm.vm.spi.TeaVMHost;
import org.teavm.vm.spi.TeaVMPlugin;
public class MetaprogrammingPlugin implements TeaVMPlugin {
@Override
public void install(TeaVMHost host) {
host.add(new MetaprogrammingDependencyListener());
}
}

View File

@ -62,7 +62,7 @@ class UsageGenerator {
this.classLoader = classLoader; this.classLoader = classLoader;
} }
public void installProxyEmitter() { void installProxyEmitter() {
Diagnostics diagnostics = agent.getDiagnostics(); Diagnostics diagnostics = agent.getDiagnostics();
try { try {

View File

@ -47,10 +47,6 @@ class AnnotationProxy implements InvocationHandler {
this.annotationType = annotationType; this.annotationType = annotationType;
} }
AnnotationProxy(AnnotationReader reader) {
this.reader = reader;
}
@Override @Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("annotationType")) { if (method.getName().equals("annotationType")) {

View File

@ -53,7 +53,7 @@ public class ReflectClassImpl<T> implements ReflectClass<T> {
this.context = context; this.context = context;
} }
public ReflectContext getReflectContext() { ReflectContext getReflectContext() {
return context; return context;
} }
@ -265,7 +265,7 @@ public class ReflectClassImpl<T> implements ReflectClass<T> {
}); });
} }
public ReflectMethodImpl getDeclaredMethod(MethodDescriptor method) { private ReflectMethodImpl getDeclaredMethod(MethodDescriptor method) {
resolve(); resolve();
return methods.computeIfAbsent(method, m -> { return methods.computeIfAbsent(method, m -> {
MethodReader methodReader = classReader.getMethod(m); MethodReader methodReader = classReader.getMethod(m);

View File

@ -24,10 +24,6 @@ import org.teavm.model.ElementModifier;
import org.teavm.model.ElementReader; import org.teavm.model.ElementReader;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
/**
*
* @author Alexey Andreev
*/
public class ReflectContext { public class ReflectContext {
private ClassReaderSource classSource; private ClassReaderSource classSource;
private Map<ValueType, ReflectClassImpl<?>> classes = new HashMap<>(); private Map<ValueType, ReflectClassImpl<?>> classes = new HashMap<>();

View File

@ -21,10 +21,6 @@ import org.teavm.metaprogramming.reflect.ReflectField;
import org.teavm.model.ElementModifier; import org.teavm.model.ElementModifier;
import org.teavm.model.FieldReader; import org.teavm.model.FieldReader;
/**
*
* @author Alexey Andreev
*/
public class ReflectFieldImpl implements ReflectField { public class ReflectFieldImpl implements ReflectField {
private ReflectContext context; private ReflectContext context;
private ReflectClassImpl<?> declaringClass; private ReflectClassImpl<?> declaringClass;

View File

@ -24,10 +24,6 @@ import org.teavm.metaprogramming.reflect.ReflectAnnotatedElement;
import org.teavm.metaprogramming.reflect.ReflectMethod; import org.teavm.metaprogramming.reflect.ReflectMethod;
import org.teavm.model.MethodReader; import org.teavm.model.MethodReader;
/**
*
* @author Alexey Andreev
*/
public class ReflectMethodImpl implements ReflectMethod { public class ReflectMethodImpl implements ReflectMethod {
private ReflectContext context; private ReflectContext context;
private ReflectClassImpl<?> declaringClass; private ReflectClassImpl<?> declaringClass;

View File

@ -0,0 +1,17 @@
#
# Copyright 2016 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.
#
org.teavm.metaprogramming.impl.MetaprogrammingPlugin

View File

@ -79,7 +79,7 @@
</properties> </properties>
<modules> <modules>
<module>metaprogramming-api</module> <module>metaprogramming/api</module>
<module>core</module> <module>core</module>
<module>classlib</module> <module>classlib</module>
<module>jso/core</module> <module>jso/core</module>
@ -95,6 +95,7 @@
<module>tools/junit</module> <module>tools/junit</module>
<module>tests</module> <module>tests</module>
<module>extras-slf4j</module> <module>extras-slf4j</module>
<module>metaprogramming/impl</module>
</modules> </modules>
<dependencyManagement> <dependencyManagement>

View File

@ -57,10 +57,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.teavm</groupId> <groupId>org.teavm</groupId>
<artifactId>teavm-metaprogramming-api</artifactId> <artifactId>teavm-metaprogramming-impl</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<classifier>tests</classifier>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

View File

@ -22,7 +22,6 @@ import static org.teavm.metaprogramming.Metaprogramming.exit;
import static org.teavm.metaprogramming.Metaprogramming.proxy; import static org.teavm.metaprogramming.Metaprogramming.proxy;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.teavm.classlib.java.lang.StringBuilderTest;
import org.teavm.junit.SkipJVM; import org.teavm.junit.SkipJVM;
import org.teavm.junit.TeaVMTestRunner; import org.teavm.junit.TeaVMTestRunner;
import org.teavm.metaprogramming.CompileTime; import org.teavm.metaprogramming.CompileTime;

View File

@ -10,14 +10,6 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: net.sourceforge.htmlunit:htmlunit:2.19" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apache.httpcomponents:httpmime:4.5.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.sourceforge.cssparser:cssparser:0.9.18" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.websocket:websocket-client:9.2.13.v20150730" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty:jetty-util:9.2.13.v20150730" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty:jetty-io:9.2.13.v20150730" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.websocket:websocket-common:9.2.13.v20150730" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.websocket:websocket-api:9.2.13.v20150730" level="project" />
<orderEntry type="module" module-name="teavm-core" /> <orderEntry type="module" module-name="teavm-core" />
<orderEntry type="module" module-name="teavm-metaprogramming-api" /> <orderEntry type="module" module-name="teavm-metaprogramming-api" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" /> <orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
@ -33,7 +25,7 @@
<orderEntry type="module" module-name="teavm-platform" /> <orderEntry type="module" module-name="teavm-platform" />
<orderEntry type="module" module-name="teavm-jso-apis" /> <orderEntry type="module" module-name="teavm-jso-apis" />
<orderEntry type="module" module-name="teavm-jso-apis" production-on-test="" /> <orderEntry type="module" module-name="teavm-jso-apis" production-on-test="" />
<orderEntry type="module" module-name="teavm-metaprogramming-api" production-on-test="" /> <orderEntry type="module" module-name="impl" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" 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="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="module" module-name="teavm-tooling" scope="TEST" /> <orderEntry type="module" module-name="teavm-tooling" scope="TEST" />

View File

@ -7,7 +7,7 @@
<property key="Bundle-Description" value="TeaVM API that helps to create tooling" /> <property key="Bundle-Description" value="TeaVM API that helps to create tooling" />
<property key="Export-Package" value="org.teavm.*" /> <property key="Export-Package" value="org.teavm.*" />
<property key="Bundle-Name" value="TeaVM tooling core" /> <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" /> <property key="Include-Resource" value="org/teavm/tooling/main.html=$MODULE_DIR$/src/main/resources/org/teavm/tooling/main.html,org/teavm/tooling/test/junit.html=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/junit.html,org/teavm/tooling/test/junit-client.html=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/junit-client.html,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/control-000-small.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/control-000-small.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/junit-client.js=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/junit-client.js,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-red.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/tick-small-red.png,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/class_obj.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/class_obj.png,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/res/toggle-small-expand.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/toggle-small-expand.png,org/teavm/tooling/test/res/methpub_obj.png=$MODULE_DIR$/src/main/resources/org/teavm/tooling/test/res/methpub_obj.png" />
</additionalProperties> </additionalProperties>
<additionalJARContents /> <additionalJARContents />
</configuration> </configuration>

View File

@ -11,14 +11,6 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: net.sourceforge.htmlunit:htmlunit:2.19" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.1" level="project" />
<orderEntry type="library" name="Maven: net.sourceforge.cssparser:cssparser:0.9.18" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-client:9.2.13.v20150730" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-util:9.2.13.v20150730" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-io:9.2.13.v20150730" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-common:9.2.13.v20150730" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-api:9.2.13.v20150730" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.11" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="module" module-name="teavm-tooling" /> <orderEntry type="module" module-name="teavm-tooling" />