This commit is contained in:
parent
240913d422
commit
d835a98e6f
@ -425,6 +425,38 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assignLocalVar(AssignNode assignNode) {
|
||||||
|
if (!localVariables.contains(assignNode.assignable.identifier)) {
|
||||||
|
localVariables.add(assignNode.assignable.identifier);
|
||||||
|
}
|
||||||
|
if (assignNode.expression.getType() instanceof BaseType) {
|
||||||
|
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
||||||
|
} else if (assignNode.expression.getType() instanceof ReferenceType) {
|
||||||
|
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assignFieldOrObjectVar(AssignNode assignNode) {
|
||||||
|
int localVarIndex = localVariables.indexOf(assignNode.assignable.identifier);
|
||||||
|
if (localVarIndex >= 0) { // object
|
||||||
|
methodVisitor.visitVarInsn(ALOAD, localVarIndex);
|
||||||
|
} else if (assignNode.assignable.memberAccess.thisExpr) { // this
|
||||||
|
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||||
|
} else {
|
||||||
|
localVariables.add(assignNode.assignable.identifier);
|
||||||
|
methodVisitor.visitVarInsn(ALOAD, localVariables.indexOf(assignNode.assignable.identifier));
|
||||||
|
}
|
||||||
|
|
||||||
|
assignNode.expression.accept(this);
|
||||||
|
|
||||||
|
if (assignNode.expression.getType() instanceof BaseType) {
|
||||||
|
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) assignNode.expression.getType()));
|
||||||
|
} else if (assignNode.expression.getType() instanceof ReferenceType) {
|
||||||
|
ReferenceType referenceType = (ReferenceType) assignNode.expression.getType();
|
||||||
|
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), "L" + referenceType.getIdentifier() + ";");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void localVarCrementAssign(AssignNode assignNode) {
|
private void localVarCrementAssign(AssignNode assignNode) {
|
||||||
if (assignNode.expression instanceof IncrementNode) {
|
if (assignNode.expression instanceof IncrementNode) {
|
||||||
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
||||||
@ -462,9 +494,9 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
assignNode.expression.accept(this);
|
assignNode.expression.accept(this);
|
||||||
methodVisitor.visitInsn(DUP_X1);
|
methodVisitor.visitInsn(DUP_X1);
|
||||||
|
|
||||||
if (assignNode.expression instanceof BaseType) {
|
if (assignNode.expression.getType() instanceof BaseType) {
|
||||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) assignNode.expression.getType()));
|
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) assignNode.expression.getType()));
|
||||||
} else if (assignNode.expression instanceof ReferenceType) {
|
} else if (assignNode.expression.getType() instanceof ReferenceType) {
|
||||||
ReferenceType referenceType = (ReferenceType) assignNode.expression.getType();
|
ReferenceType referenceType = (ReferenceType) assignNode.expression.getType();
|
||||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), "L" + referenceType.getIdentifier() + ";");
|
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), "L" + referenceType.getIdentifier() + ";");
|
||||||
}
|
}
|
||||||
@ -483,9 +515,9 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
|
|
||||||
loadBeforeCrement(assignNode);
|
loadBeforeCrement(assignNode);
|
||||||
|
|
||||||
if (assignNode.expression instanceof BaseType) {
|
if (assignNode.expression.getType() instanceof BaseType) {
|
||||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) assignNode.expression.getType()));
|
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) assignNode.expression.getType()));
|
||||||
} else if (assignNode.expression instanceof ReferenceType) {
|
} else if (assignNode.expression.getType() instanceof ReferenceType) {
|
||||||
ReferenceType referenceType = (ReferenceType) assignNode.expression.getType();
|
ReferenceType referenceType = (ReferenceType) assignNode.expression.getType();
|
||||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), "L" + referenceType.getIdentifier() + ";");
|
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), "L" + referenceType.getIdentifier() + ";");
|
||||||
}
|
}
|
||||||
@ -493,40 +525,6 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
assignNode.expression.accept(this);
|
assignNode.expression.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assignLocalVar(AssignNode assignNode) {
|
|
||||||
methodVisitor.visitInsn(DUP);
|
|
||||||
if (!localVariables.contains(assignNode.assignable.identifier)) {
|
|
||||||
localVariables.add(assignNode.assignable.identifier);
|
|
||||||
}
|
|
||||||
if (assignNode.expression instanceof BaseType) {
|
|
||||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
} else if (assignNode.expression instanceof ReferenceType) {
|
|
||||||
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assignFieldOrObjectVar(AssignNode assignNode) {
|
|
||||||
int localVarIndex = localVariables.indexOf(assignNode.assignable.identifier);
|
|
||||||
if (localVarIndex >= 0) { // object
|
|
||||||
methodVisitor.visitVarInsn(ALOAD, localVarIndex);
|
|
||||||
} else if (assignNode.assignable.memberAccess.thisExpr) { // this
|
|
||||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
|
||||||
} else {
|
|
||||||
localVariables.add(assignNode.assignable.identifier);
|
|
||||||
methodVisitor.visitVarInsn(ALOAD, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
}
|
|
||||||
|
|
||||||
assignNode.expression.accept(this);
|
|
||||||
methodVisitor.visitInsn(DUP_X1);
|
|
||||||
|
|
||||||
if (assignNode.expression instanceof BaseType) {
|
|
||||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) assignNode.expression.getType()));
|
|
||||||
} else if (assignNode.expression instanceof ReferenceType) {
|
|
||||||
ReferenceType referenceType = (ReferenceType) assignNode.expression.getType();
|
|
||||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), "L" + referenceType.getIdentifier() + ";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadBeforeCrement(AssignNode assignNode) {
|
private void loadBeforeCrement(AssignNode assignNode) {
|
||||||
if(assignNode.expression instanceof IncrementNode) {
|
if(assignNode.expression instanceof IncrementNode) {
|
||||||
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
||||||
|
Loading…
Reference in New Issue
Block a user