mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix bug in JSO
This commit is contained in:
parent
6144a4bd14
commit
058566e731
|
@ -15,16 +15,12 @@
|
|||
*/
|
||||
package org.teavm.dependency;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
public class DependencyType {
|
||||
private DependencyChecker dependencyChecker;
|
||||
private String name;
|
||||
int index;
|
||||
|
||||
public DependencyType(DependencyChecker dependencyChecker, String name, int index) {
|
||||
DependencyType(DependencyChecker dependencyChecker, String name, int index) {
|
||||
this.dependencyChecker = dependencyChecker;
|
||||
this.name = name;
|
||||
this.index = index;
|
||||
|
|
|
@ -90,12 +90,7 @@ class JSDependencyListener extends AbstractDependencyListener {
|
|||
}
|
||||
|
||||
private ExposedClass getExposedClass(String name) {
|
||||
ExposedClass cls = exposedClasses.get(name);
|
||||
if (cls == null) {
|
||||
cls = createExposedClass(name);
|
||||
exposedClasses.put(name, cls);
|
||||
}
|
||||
return cls;
|
||||
return exposedClasses.computeIfAbsent(name, this::createExposedClass);
|
||||
}
|
||||
|
||||
private ExposedClass createExposedClass(String name) {
|
||||
|
@ -111,6 +106,7 @@ class JSDependencyListener extends AbstractDependencyListener {
|
|||
exposedCls.implementedInterfaces.addAll(parent.implementedInterfaces);
|
||||
}
|
||||
addInterfaces(exposedCls, cls);
|
||||
if (!cls.hasModifier(ElementModifier.ABSTRACT)) {
|
||||
for (MethodReader method : cls.getMethods()) {
|
||||
if (method.getName().equals("<init>")) {
|
||||
continue;
|
||||
|
@ -122,6 +118,7 @@ class JSDependencyListener extends AbstractDependencyListener {
|
|||
methodDep.use();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exposedCls.functorField == null) {
|
||||
FieldReader functorField = cls.getField("$$jso_functor$$");
|
||||
if (functorField != null) {
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.teavm.dependency.DependencyPlugin;
|
|||
import org.teavm.dependency.MethodDependency;
|
||||
import org.teavm.model.CallLocation;
|
||||
import org.teavm.model.ClassReader;
|
||||
import org.teavm.model.ElementModifier;
|
||||
import org.teavm.model.MethodReader;
|
||||
import org.teavm.model.MethodReference;
|
||||
import org.teavm.model.ValueType;
|
||||
|
@ -176,7 +177,7 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
|
|||
case "instantiate":
|
||||
case "function":
|
||||
for (int i = 0; i < method.getReference().parameterCount(); ++i) {
|
||||
method.getVariable(i).addConsumer(type -> achieveFunctorMethods(agent, type.getName(), method));
|
||||
method.getVariable(i).addConsumer(type -> reachFunctorMethods(agent, type.getName(), method));
|
||||
}
|
||||
break;
|
||||
case "unwrapString":
|
||||
|
@ -185,17 +186,19 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
|
|||
}
|
||||
}
|
||||
|
||||
private void achieveFunctorMethods(DependencyAgent agent, String type, MethodDependency caller) {
|
||||
private void reachFunctorMethods(DependencyAgent agent, String type, MethodDependency caller) {
|
||||
if (caller.isMissing()) {
|
||||
return;
|
||||
}
|
||||
ClassReader cls = agent.getClassSource().get(type);
|
||||
if (cls != null) {
|
||||
for (MethodReader method : cls.getMethods()) {
|
||||
if (!method.hasModifier(ElementModifier.STATIC)) {
|
||||
agent.linkMethod(method.getReference(), null).use();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void generateFunction(InjectorContext context) throws IOException {
|
||||
SourceWriter writer = context.getWriter();
|
||||
|
|
|
@ -22,10 +22,6 @@ import org.teavm.model.ClassReaderSource;
|
|||
import org.teavm.model.MethodHolder;
|
||||
import org.teavm.model.MethodReference;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
public class JSObjectClassTransformer implements ClassHolderTransformer {
|
||||
private JSClassProcessor processor;
|
||||
private JSBodyRepository repository;
|
||||
|
|
Loading…
Reference in New Issue
Block a user