mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Dependency plugin receives DependencyAgent instead of DependencyChecker
This commit is contained in:
parent
da2a26fb4f
commit
c3e30cc295
|
@ -19,7 +19,7 @@ import java.io.IOException;
|
||||||
import org.teavm.classlib.impl.unicode.UnicodeHelper;
|
import org.teavm.classlib.impl.unicode.UnicodeHelper;
|
||||||
import org.teavm.classlib.impl.unicode.UnicodeSupport;
|
import org.teavm.classlib.impl.unicode.UnicodeSupport;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyChecker;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.ni.Generator;
|
||||||
|
@ -52,7 +52,7 @@ public class CharacterNativeGenerator implements Generator, DependencyPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
|
public void methodAchieved(DependencyAgent agent, MethodDependency method) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "obtainDigitMapping":
|
case "obtainDigitMapping":
|
||||||
case "obtainClasses":
|
case "obtainClasses":
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyChecker;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.ni.Generator;
|
||||||
|
@ -186,7 +186,7 @@ public class ClassNativeGenerator implements Generator, Injector, DependencyPlug
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyChecker checker, MethodDependency graph) {
|
public void methodAchieved(DependencyAgent agent, MethodDependency graph) {
|
||||||
switch (graph.getReference().getName()) {
|
switch (graph.getReference().getName()) {
|
||||||
case "voidClass":
|
case "voidClass":
|
||||||
case "booleanClass":
|
case "booleanClass":
|
||||||
|
@ -205,7 +205,7 @@ public class ClassNativeGenerator implements Generator, Injector, DependencyPlug
|
||||||
graph.getResult().propagate("java.lang.Class");
|
graph.getResult().propagate("java.lang.Class");
|
||||||
break;
|
break;
|
||||||
case "newInstance":
|
case "newInstance":
|
||||||
checker.linkMethod(new MethodReference(InstantiationException.class.getName(), "<init>",
|
agent.linkMethod(new MethodReference(InstantiationException.class.getName(), "<init>",
|
||||||
ValueType.VOID), graph.getStack()).use();
|
ValueType.VOID), graph.getStack()).use();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,16 +17,12 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyChecker;
|
import org.teavm.dependency.*;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
|
||||||
import org.teavm.dependency.MethodDependency;
|
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.ni.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.ni.GeneratorContext;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.ni.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.ni.InjectorContext;
|
||||||
import org.teavm.model.MethodDescriptor;
|
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.ValueType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -62,13 +58,13 @@ public class ObjectNativeGenerator implements Generator, Injector, DependencyPlu
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
|
public void methodAchieved(DependencyAgent agent, MethodDependency method) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "clone":
|
case "clone":
|
||||||
method.getVariable(0).connect(method.getResult());
|
method.getVariable(0).connect(method.getResult());
|
||||||
break;
|
break;
|
||||||
case "getClass":
|
case "getClass":
|
||||||
achieveGetClass(checker, method);
|
achieveGetClass(agent, method);
|
||||||
break;
|
break;
|
||||||
case "wrap":
|
case "wrap":
|
||||||
method.getVariable(1).connect(method.getResult());
|
method.getVariable(1).connect(method.getResult());
|
||||||
|
@ -87,11 +83,9 @@ public class ObjectNativeGenerator implements Generator, Injector, DependencyPlu
|
||||||
writer.append(".constructor)");
|
writer.append(".constructor)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void achieveGetClass(DependencyChecker checker, MethodDependency method) {
|
private void achieveGetClass(DependencyAgent agent, MethodDependency method) {
|
||||||
String classClass = "java.lang.Class";
|
MethodReference initMethod = new MethodReference(Class.class, "createNew", Class.class);
|
||||||
MethodReference initMethod = new MethodReference(classClass, new MethodDescriptor("createNew",
|
agent.linkMethod(initMethod, method.getStack()).use();
|
||||||
ValueType.object(classClass)));
|
|
||||||
checker.addEntryPoint(initMethod);
|
|
||||||
method.getResult().propagate("java.lang.Class");
|
method.getResult().propagate("java.lang.Class");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.dependency.DependencyChecker;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.ni.Injector;
|
||||||
|
@ -29,7 +29,7 @@ import org.teavm.model.MethodReference;
|
||||||
*/
|
*/
|
||||||
public class StringNativeGenerator implements Injector, DependencyPlugin {
|
public class StringNativeGenerator implements Injector, DependencyPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
|
public void methodAchieved(DependencyAgent agent, MethodDependency method) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "wrap":
|
case "wrap":
|
||||||
method.getVariable(1).connect(method.getResult());
|
method.getVariable(1).connect(method.getResult());
|
||||||
|
|
|
@ -54,16 +54,16 @@ public class SystemNativeGenerator implements Generator, DependencyPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
|
public void methodAchieved(DependencyAgent agent, MethodDependency method) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "doArrayCopy":
|
case "doArrayCopy":
|
||||||
achieveArrayCopy(method);
|
achieveArrayCopy(method);
|
||||||
break;
|
break;
|
||||||
case "setOut":
|
case "setOut":
|
||||||
achieveSetOut(checker, method);
|
achieveSetOut(agent, method);
|
||||||
break;
|
break;
|
||||||
case "setErr":
|
case "setErr":
|
||||||
achieveSetErr(checker, method);
|
achieveSetErr(agent, method);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,13 +97,13 @@ public class SystemNativeGenerator implements Generator, DependencyPlugin {
|
||||||
src.getArrayItem().connect(dest.getArrayItem());
|
src.getArrayItem().connect(dest.getArrayItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void achieveSetErr(DependencyChecker checker, MethodDependency method) {
|
private void achieveSetErr(DependencyAgent agent, MethodDependency method) {
|
||||||
FieldDependency fieldDep = checker.linkField(new FieldReference("java.lang.System", "err"), method.getStack());
|
FieldDependency fieldDep = agent.linkField(new FieldReference("java.lang.System", "err"), method.getStack());
|
||||||
method.getVariable(1).connect(fieldDep.getValue());
|
method.getVariable(1).connect(fieldDep.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void achieveSetOut(DependencyChecker checker, MethodDependency method) {
|
private void achieveSetOut(DependencyAgent agent, MethodDependency method) {
|
||||||
FieldDependency fieldDep = checker.linkField(new FieldReference("java.lang.System", "out"), method.getStack());
|
FieldDependency fieldDep = agent.linkField(new FieldReference("java.lang.System", "out"), method.getStack());
|
||||||
method.getVariable(1).connect(fieldDep.getValue());
|
method.getVariable(1).connect(fieldDep.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,7 @@ package org.teavm.classlib.java.lang.reflect;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyChecker;
|
import org.teavm.dependency.*;
|
||||||
import org.teavm.dependency.DependencyConsumer;
|
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
|
||||||
import org.teavm.dependency.MethodDependency;
|
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.ni.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.ni.GeneratorContext;
|
||||||
import org.teavm.model.ClassReader;
|
import org.teavm.model.ClassReader;
|
||||||
|
@ -41,16 +38,16 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
|
||||||
ValueType.INTEGER, ValueType.LONG, ValueType.FLOAT, ValueType.DOUBLE, ValueType.BOOLEAN };
|
ValueType.INTEGER, ValueType.LONG, ValueType.FLOAT, ValueType.DOUBLE, ValueType.BOOLEAN };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
|
public void methodAchieved(DependencyAgent agent, MethodDependency method) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "getLength":
|
case "getLength":
|
||||||
achieveGetLength(checker, method);
|
achieveGetLength(agent, method);
|
||||||
break;
|
break;
|
||||||
case "newInstanceImpl":
|
case "newInstanceImpl":
|
||||||
method.getResult().propagate("[java.lang.Object");
|
method.getResult().propagate("[java.lang.Object");
|
||||||
break;
|
break;
|
||||||
case "getImpl":
|
case "getImpl":
|
||||||
achieveGet(checker, method);
|
achieveGet(agent, method);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,13 +78,12 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
|
||||||
writer.append("return " + array + ".data.length;").softNewLine();
|
writer.append("return " + array + ".data.length;").softNewLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void achieveGetLength(final DependencyChecker checker, final MethodDependency method) {
|
private void achieveGetLength(final DependencyAgent agent, final MethodDependency method) {
|
||||||
method.getVariable(1).addConsumer(new DependencyConsumer() {
|
method.getVariable(1).addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(String type) {
|
@Override public void consume(String type) {
|
||||||
if (!type.startsWith("[")) {
|
if (!type.startsWith("[")) {
|
||||||
MethodReference cons = new MethodReference("java.lang.IllegalArgumentException",
|
MethodReference cons = new MethodReference(IllegalArgumentException.class, "<init>", void.class);
|
||||||
new MethodDescriptor("<init>", ValueType.VOID));
|
agent.linkMethod(cons, method.getStack()).use();
|
||||||
checker.addEntryPoint(cons);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -129,7 +125,7 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
|
||||||
writer.outdent().append("}").softNewLine();
|
writer.outdent().append("}").softNewLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void achieveGet(final DependencyChecker checker, final MethodDependency method) {
|
private void achieveGet(final DependencyAgent agent, final MethodDependency method) {
|
||||||
method.getVariable(1).getArrayItem().connect(method.getResult());
|
method.getVariable(1).getArrayItem().connect(method.getResult());
|
||||||
method.getVariable(1).addConsumer(new DependencyConsumer() {
|
method.getVariable(1).addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(String type) {
|
@Override public void consume(String type) {
|
||||||
|
@ -140,7 +136,7 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
|
||||||
String wrapper = "java.lang." + primitiveWrappers[i];
|
String wrapper = "java.lang." + primitiveWrappers[i];
|
||||||
MethodReference methodRef = new MethodReference(wrapper, "valueOf",
|
MethodReference methodRef = new MethodReference(wrapper, "valueOf",
|
||||||
primitiveTypes[i], ValueType.object(wrapper));
|
primitiveTypes[i], ValueType.object(wrapper));
|
||||||
checker.linkMethod(methodRef, method.getStack()).use();
|
agent.linkMethod(methodRef, method.getStack()).use();
|
||||||
method.getResult().propagate("java.lang." + primitiveWrappers[i]);
|
method.getResult().propagate("java.lang." + primitiveWrappers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyChecker;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.ni.Generator;
|
||||||
|
@ -63,7 +63,7 @@ public class LocaleNativeGenerator implements Generator, DependencyPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
|
public void methodAchieved(DependencyAgent agent, MethodDependency method) {
|
||||||
switch (method.getMethod().getName()) {
|
switch (method.getMethod().getName()) {
|
||||||
case "getDefaultLocale":
|
case "getDefaultLocale":
|
||||||
case "getDisplayCountry":
|
case "getDisplayCountry":
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyChecker;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
import org.teavm.dependency.DependencyPlugin;
|
||||||
import org.teavm.dependency.MethodDependency;
|
import org.teavm.dependency.MethodDependency;
|
||||||
import org.teavm.javascript.ni.Generator;
|
import org.teavm.javascript.ni.Generator;
|
||||||
|
@ -34,10 +34,11 @@ public class TimerNativeGenerator implements Generator, DependencyPlugin {
|
||||||
"performOnce", ValueType.VOID);
|
"performOnce", ValueType.VOID);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
|
public void methodAchieved(DependencyAgent agent, MethodDependency method) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "scheduleOnce": {
|
case "scheduleOnce": {
|
||||||
MethodDependency performMethod = checker.linkMethod(performOnceRef, method.getStack());
|
MethodDependency performMethod = agent.linkMethod(performOnceRef, method.getStack());
|
||||||
|
performMethod.use();
|
||||||
method.getVariable(1).connect(performMethod.getVariable(1));
|
method.getVariable(1).connect(performMethod.getVariable(1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,5 +20,5 @@ package org.teavm.dependency;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface DependencyPlugin {
|
public interface DependencyPlugin {
|
||||||
void methodAchieved(DependencyChecker checker, MethodDependency method);
|
void methodAchieved(DependencyAgent checker, MethodDependency method);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,7 @@ package org.teavm.jso;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.codegen.SourceWriter;
|
import org.teavm.codegen.SourceWriter;
|
||||||
import org.teavm.dependency.DependencyChecker;
|
import org.teavm.dependency.*;
|
||||||
import org.teavm.dependency.DependencyConsumer;
|
|
||||||
import org.teavm.dependency.DependencyPlugin;
|
|
||||||
import org.teavm.dependency.MethodDependency;
|
|
||||||
import org.teavm.javascript.ast.ConstantExpr;
|
import org.teavm.javascript.ast.ConstantExpr;
|
||||||
import org.teavm.javascript.ast.Expr;
|
import org.teavm.javascript.ast.Expr;
|
||||||
import org.teavm.javascript.ast.InvocationExpr;
|
import org.teavm.javascript.ast.InvocationExpr;
|
||||||
|
@ -28,7 +25,10 @@ import org.teavm.javascript.ni.Generator;
|
||||||
import org.teavm.javascript.ni.GeneratorContext;
|
import org.teavm.javascript.ni.GeneratorContext;
|
||||||
import org.teavm.javascript.ni.Injector;
|
import org.teavm.javascript.ni.Injector;
|
||||||
import org.teavm.javascript.ni.InjectorContext;
|
import org.teavm.javascript.ni.InjectorContext;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.ClassReader;
|
||||||
|
import org.teavm.model.FieldReference;
|
||||||
|
import org.teavm.model.MethodReader;
|
||||||
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -115,24 +115,24 @@ public class JSNativeGenerator implements Generator, Injector, DependencyPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(final DependencyChecker checker, final MethodDependency method) {
|
public void methodAchieved(final DependencyAgent agent, final MethodDependency method) {
|
||||||
for (int i = 0; i < method.getReference().parameterCount(); ++i) {
|
for (int i = 0; i < method.getReference().parameterCount(); ++i) {
|
||||||
method.getVariable(i).addConsumer(new DependencyConsumer() {
|
method.getVariable(i).addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(String type) {
|
@Override public void consume(String type) {
|
||||||
achieveFunctorMethods(checker, type, method);
|
achieveFunctorMethods(agent, type, method);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void achieveFunctorMethods(DependencyChecker checker, String type, MethodDependency caller) {
|
private void achieveFunctorMethods(DependencyAgent agent, String type, MethodDependency caller) {
|
||||||
if (caller.isMissing()) {
|
if (caller.isMissing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ClassReader cls = checker.getClassSource().get(type);
|
ClassReader cls = agent.getClassSource().get(type);
|
||||||
if (cls != null) {
|
if (cls != null) {
|
||||||
for (MethodReader method : cls.getMethods()) {
|
for (MethodReader method : cls.getMethods()) {
|
||||||
checker.linkMethod(method.getReference(), caller.getStack()).use();
|
agent.linkMethod(method.getReference(), caller.getStack()).use();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user