mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fixes array item propagation
This commit is contained in:
parent
d310409db3
commit
f085dbb607
|
@ -30,6 +30,18 @@ public class JavaScriptBodyDependency implements DependencyListener {
|
||||||
public void started(DependencyChecker dependencyChecker) {
|
public void started(DependencyChecker dependencyChecker) {
|
||||||
allClassesNode = dependencyChecker.createNode();
|
allClassesNode = dependencyChecker.createNode();
|
||||||
allClassesNode.setTag("JavaScriptBody:global");
|
allClassesNode.setTag("JavaScriptBody:global");
|
||||||
|
allClassesNode.getArrayItem().addConsumer(new OneDirectionalConnection(allClassesNode));
|
||||||
|
allClassesNode.getArrayItem().getArrayItem().addConsumer(new OneDirectionalConnection(allClassesNode));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class OneDirectionalConnection implements DependencyConsumer {
|
||||||
|
private DependencyNode target;
|
||||||
|
public OneDirectionalConnection( DependencyNode target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
@Override public void consume(String type) {
|
||||||
|
target.propagate(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,12 +59,15 @@ public class JavaScriptBodyDependency implements DependencyListener {
|
||||||
MethodGraph graph = dependencyChecker.attachMethodGraph(methodRef);
|
MethodGraph graph = dependencyChecker.attachMethodGraph(methodRef);
|
||||||
if (graph.getResult() != null) {
|
if (graph.getResult() != null) {
|
||||||
allClassesNode.connect(graph.getResult());
|
allClassesNode.connect(graph.getResult());
|
||||||
|
allClassesNode.addConsumer(new OneDirectionalConnection(graph.getResult().getArrayItem()));
|
||||||
|
allClassesNode.addConsumer(new OneDirectionalConnection(graph.getResult().getArrayItem()
|
||||||
|
.getArrayItem()));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < graph.getParameterCount(); ++i) {
|
for (int i = 0; i < graph.getParameterCount(); ++i) {
|
||||||
graph.getVariable(i).connect(allClassesNode);
|
graph.getVariable(i).connect(allClassesNode);
|
||||||
allClassesNode.getArrayItem().connect(graph.getVariable(i).getArrayItem());
|
allClassesNode.addConsumer(new OneDirectionalConnection(graph.getVariable(i).getArrayItem()));
|
||||||
allClassesNode.getArrayItem().getArrayItem().connect(graph.getVariable(i)
|
allClassesNode.addConsumer(new OneDirectionalConnection(graph.getVariable(i).getArrayItem()
|
||||||
.getArrayItem().getArrayItem());
|
.getArrayItem()));
|
||||||
}
|
}
|
||||||
if (javacall != null && javacall.getBoolean()) {
|
if (javacall != null && javacall.getBoolean()) {
|
||||||
String body = annot.getValue("body").getString();
|
String body = annot.getValue("body").getString();
|
||||||
|
|
|
@ -44,6 +44,13 @@ public class JavaScriptBodyTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dependencyPropagatedThroughArray() {
|
public void dependencyPropagatedThroughArray() {
|
||||||
|
storeObject(new Object[] { new AImpl() });
|
||||||
|
A[] array = (A[])retrieveObject();
|
||||||
|
assertEquals(23, array[0].foo());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void dependencyPropagatedBackThroughArray() {
|
||||||
A[] first = new A[1];
|
A[] first = new A[1];
|
||||||
storeObject(first);
|
storeObject(first);
|
||||||
Object[] second = (Object[])retrieveObject();
|
Object[] second = (Object[])retrieveObject();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user