mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 08:24:10 -08:00
This commit is contained in:
parent
697bc5ec6c
commit
5ae384538d
|
@ -15,8 +15,17 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.dependency;
|
package org.teavm.dependency;
|
||||||
|
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.BasicBlock;
|
||||||
|
import org.teavm.model.ClassHolder;
|
||||||
|
import org.teavm.model.ElementModifier;
|
||||||
|
import org.teavm.model.FieldHolder;
|
||||||
|
import org.teavm.model.FieldReference;
|
||||||
|
import org.teavm.model.Instruction;
|
||||||
|
import org.teavm.model.MethodHolder;
|
||||||
|
import org.teavm.model.MethodReference;
|
||||||
|
import org.teavm.model.Program;
|
||||||
import org.teavm.model.instructions.GetFieldInstruction;
|
import org.teavm.model.instructions.GetFieldInstruction;
|
||||||
|
import org.teavm.model.instructions.InitClassInstruction;
|
||||||
import org.teavm.model.instructions.InvokeInstruction;
|
import org.teavm.model.instructions.InvokeInstruction;
|
||||||
import org.teavm.model.instructions.PutFieldInstruction;
|
import org.teavm.model.instructions.PutFieldInstruction;
|
||||||
|
|
||||||
|
@ -50,7 +59,9 @@ public class Linker {
|
||||||
Program program = method.getProgram();
|
Program program = method.getProgram();
|
||||||
for (int i = 0; i < program.basicBlockCount(); ++i) {
|
for (int i = 0; i < program.basicBlockCount(); ++i) {
|
||||||
BasicBlock block = program.basicBlockAt(i);
|
BasicBlock block = program.basicBlockAt(i);
|
||||||
for (Instruction insn : block.getInstructions()) {
|
for (int j = 0; j < block.getInstructions().size(); ++j) {
|
||||||
|
Instruction insn = block.getInstructions().get(j);
|
||||||
|
|
||||||
if (insn instanceof InvokeInstruction) {
|
if (insn instanceof InvokeInstruction) {
|
||||||
InvokeInstruction invoke = (InvokeInstruction) insn;
|
InvokeInstruction invoke = (InvokeInstruction) insn;
|
||||||
MethodDependencyInfo linkedMethod = dependency.getMethodImplementation(invoke.getMethod());
|
MethodDependencyInfo linkedMethod = dependency.getMethodImplementation(invoke.getMethod());
|
||||||
|
@ -63,6 +74,14 @@ public class Linker {
|
||||||
if (linkedField != null) {
|
if (linkedField != null) {
|
||||||
getField.setField(linkedField.getReference());
|
getField.setField(linkedField.getReference());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FieldReference fieldRef = getField.getField();
|
||||||
|
if (!fieldRef.getClassName().equals(method.getOwnerName())) {
|
||||||
|
InitClassInstruction initInsn = new InitClassInstruction();
|
||||||
|
initInsn.setClassName(fieldRef.getClassName());
|
||||||
|
block.getInstructions().add(j++, initInsn);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (insn instanceof PutFieldInstruction) {
|
} else if (insn instanceof PutFieldInstruction) {
|
||||||
PutFieldInstruction getField = (PutFieldInstruction) insn;
|
PutFieldInstruction getField = (PutFieldInstruction) insn;
|
||||||
FieldDependencyInfo linkedField = dependency.getField(getField.getField());
|
FieldDependencyInfo linkedField = dependency.getField(getField.getField());
|
||||||
|
|
|
@ -1679,11 +1679,6 @@ public class ProgramParser implements VariableDebugInformation {
|
||||||
case Opcodes.GETSTATIC: {
|
case Opcodes.GETSTATIC: {
|
||||||
ValueType type = ValueType.parse(desc);
|
ValueType type = ValueType.parse(desc);
|
||||||
int value = desc.equals("D") || desc.equals("J") ? pushDouble() : pushSingle();
|
int value = desc.equals("D") || desc.equals("J") ? pushDouble() : pushSingle();
|
||||||
if (!owner.equals(currentClassName)) {
|
|
||||||
InitClassInstruction initInsn = new InitClassInstruction();
|
|
||||||
initInsn.setClassName(ownerCls);
|
|
||||||
addInstruction(initInsn);
|
|
||||||
}
|
|
||||||
GetFieldInstruction insn = new GetFieldInstruction();
|
GetFieldInstruction insn = new GetFieldInstruction();
|
||||||
insn.setField(new FieldReference(ownerCls, name));
|
insn.setField(new FieldReference(ownerCls, name));
|
||||||
insn.setFieldType(type);
|
insn.setFieldType(type);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user