Compare commits
2 Commits
97aadb9ba8
...
3628a0a4d8
Author | SHA1 | Date | |
---|---|---|---|
3628a0a4d8 | |||
36f0683240 |
@ -10,6 +10,7 @@ import ast.members.MainMethodNode;
|
|||||||
import ast.members.MethodNode;
|
import ast.members.MethodNode;
|
||||||
import ast.parameters.ParameterNode;
|
import ast.parameters.ParameterNode;
|
||||||
import ast.statementexpressions.AssignNode;
|
import ast.statementexpressions.AssignNode;
|
||||||
|
import ast.statementexpressions.AssignableNode;
|
||||||
import ast.statementexpressions.NewDeclarationNode;
|
import ast.statementexpressions.NewDeclarationNode;
|
||||||
import ast.statementexpressions.crementexpressions.CrementType;
|
import ast.statementexpressions.crementexpressions.CrementType;
|
||||||
import ast.statementexpressions.crementexpressions.DecrementNode;
|
import ast.statementexpressions.crementexpressions.DecrementNode;
|
||||||
@ -277,7 +278,7 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
methodVisitor.visitFieldInsn(GETFIELD, memberAccessNode.identifiers.get(0), memberAccessNode.identifiers.get(1), mapper.getTypeChar((BaseType) memberAccessNode.getTypeNode()));
|
methodVisitor.visitFieldInsn(GETFIELD, memberAccessNode.identifiers.get(0), memberAccessNode.identifiers.get(1), mapper.getTypeChar((BaseType) memberAccessNode.getTypeNode()));
|
||||||
} else if (memberAccessNode.getTypeNode() instanceof ReferenceType) {
|
} else if (memberAccessNode.getTypeNode() instanceof ReferenceType) {
|
||||||
methodVisitor.visitFieldInsn(GETFIELD, memberAccessNode.identifiers.get(0), memberAccessNode.identifiers.get(1), "L" + ((ReferenceType) memberAccessNode.getTypeNode()).getIdentifier() + ";");
|
methodVisitor.visitFieldInsn(GETFIELD, memberAccessNode.identifiers.get(0), memberAccessNode.identifiers.get(1), "L" + ((ReferenceType) memberAccessNode.getTypeNode()).getIdentifier() + ";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -304,9 +305,8 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
public void visit(UnaryNode unaryNode) {
|
public void visit(UnaryNode unaryNode) {
|
||||||
if (unaryNode.thisExp != null) {
|
if (unaryNode.thisExp != null) {
|
||||||
methodVisitor.visitVarInsn(ALOAD, 0); // this
|
methodVisitor.visitVarInsn(ALOAD, 0); // this
|
||||||
} else if (unaryNode.identifier != null) {
|
|
||||||
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(unaryNode.identifier));
|
|
||||||
} else if (unaryNode.memberAccess != null) {
|
} else if (unaryNode.memberAccess != null) {
|
||||||
|
unaryNode.memberAccess.setTypeNode(unaryNode.getType());
|
||||||
unaryNode.memberAccess.accept(this);
|
unaryNode.memberAccess.accept(this);
|
||||||
} else if (unaryNode.value != null) {
|
} else if (unaryNode.value != null) {
|
||||||
unaryNode.value.accept(this);
|
unaryNode.value.accept(this);
|
||||||
@ -316,6 +316,8 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
unaryNode.statement.accept(this);
|
unaryNode.statement.accept(this);
|
||||||
} else if (unaryNode.expression != null) {
|
} else if (unaryNode.expression != null) {
|
||||||
unaryNode.expression.accept(this);
|
unaryNode.expression.accept(this);
|
||||||
|
} else if (unaryNode.identifier != null) {
|
||||||
|
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(unaryNode.identifier));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +326,7 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(BlockNode blockNode) {
|
public void visit(BlockNode blockNode) {
|
||||||
for(IStatementNode statementNode : blockNode.statements) {
|
for (IStatementNode statementNode : blockNode.statements) {
|
||||||
statementNode.accept(this);
|
statementNode.accept(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,6 +382,20 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
if (localVariableDeclarationNode.expression != null) {
|
if (localVariableDeclarationNode.expression != null) {
|
||||||
// Process expression
|
// Process expression
|
||||||
localVariableDeclarationNode.expression.accept(this);
|
localVariableDeclarationNode.expression.accept(this);
|
||||||
|
|
||||||
|
if (localVariableDeclarationNode.expression instanceof UnaryNode) {
|
||||||
|
UnaryNode unaryNode = (UnaryNode) localVariableDeclarationNode.expression;
|
||||||
|
if (unaryNode.statement instanceof IncrementNode) {
|
||||||
|
IncrementNode incrementNode = (IncrementNode) unaryNode.statement;
|
||||||
|
incrementNode.assignableExpression.typeNode = unaryNode.type;
|
||||||
|
loadInrement(incrementNode);
|
||||||
|
} else if (unaryNode.statement instanceof DecrementNode) {
|
||||||
|
DecrementNode decrementNode = (DecrementNode) unaryNode.statement;
|
||||||
|
decrementNode.assignableExpression.typeNode = unaryNode.type;
|
||||||
|
loadDecrement(decrementNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add local var to list if not in list
|
// add local var to list if not in list
|
||||||
if (!localVariables.contains(localVariableDeclarationNode.identifier)) {
|
if (!localVariables.contains(localVariableDeclarationNode.identifier)) {
|
||||||
localVariables.add(localVariableDeclarationNode.identifier);
|
localVariables.add(localVariableDeclarationNode.identifier);
|
||||||
@ -400,24 +416,37 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
@Override
|
@Override
|
||||||
public void visit(AssignNode assignNode) {
|
public void visit(AssignNode assignNode) {
|
||||||
if (assignNode.assignable.memberAccess != null) { // this / object
|
if (assignNode.assignable.memberAccess != null) { // this / object
|
||||||
if (assignNode.expression instanceof IncrementNode) {
|
assignNode.assignable.memberAccess.setTypeNode(assignNode.assignable.typeNode);
|
||||||
if (((IncrementNode) assignNode.expression).crementType.equals(CrementType.PREFIX)) { // ++i
|
if (assignNode.expression instanceof UnaryNode) {
|
||||||
fieldOrObjectVarPrefixCrementAssign(assignNode);
|
UnaryNode unaryNode = (UnaryNode) assignNode.expression;
|
||||||
} else { // i++
|
if (unaryNode.statement instanceof IncrementNode) {
|
||||||
fieldOrObjectVarSuffixCrementAssign(assignNode);
|
IncrementNode incrementNode = (IncrementNode) unaryNode.statement;
|
||||||
}
|
if (incrementNode.crementType.equals(CrementType.PREFIX)) { // ++i
|
||||||
} else if (assignNode.expression instanceof DecrementNode) {
|
incrementNode.accept(this); // crement
|
||||||
if (((DecrementNode) assignNode.expression).crementType.equals(CrementType.PREFIX)) {
|
fieldOrObjectVarCrementAssign(assignNode); // assign
|
||||||
fieldOrObjectVarPrefixCrementAssign(assignNode);
|
} else { // i++
|
||||||
} else {
|
fieldOrObjectVarCrementAssign(assignNode); // assign
|
||||||
fieldOrObjectVarSuffixCrementAssign(assignNode);
|
incrementNode.accept(this); // crement
|
||||||
|
}
|
||||||
|
} else if (unaryNode.statement instanceof DecrementNode) {
|
||||||
|
DecrementNode decrementNode = (DecrementNode) unaryNode.statement;
|
||||||
|
if (decrementNode.crementType.equals(CrementType.PREFIX)) {
|
||||||
|
decrementNode.accept(this); // crement
|
||||||
|
fieldOrObjectVarCrementAssign(assignNode); // assign
|
||||||
|
} else {
|
||||||
|
fieldOrObjectVarCrementAssign(assignNode); // assign
|
||||||
|
decrementNode.accept(this); // crement
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assignFieldOrObjectVar(assignNode);
|
assignFieldOrObjectVar(assignNode);
|
||||||
}
|
}
|
||||||
} else { // local var
|
} else { // local var
|
||||||
if (assignNode.expression instanceof IncrementNode || assignNode.expression instanceof DecrementNode) {
|
if (assignNode.expression instanceof UnaryNode) {
|
||||||
localVarCrementAssign(assignNode);
|
UnaryNode unaryNode = (UnaryNode) assignNode.expression;
|
||||||
|
if (unaryNode.statement instanceof IncrementNode || unaryNode.statement instanceof DecrementNode) {
|
||||||
|
localVarCrementAssign(assignNode);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assignNode.expression.accept(this);
|
assignNode.expression.accept(this);
|
||||||
assignLocalVar(assignNode);
|
assignLocalVar(assignNode);
|
||||||
@ -425,10 +454,37 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadInrement(IncrementNode incrementNode) {
|
||||||
|
AssignableNode assignableNode = incrementNode.assignableExpression;
|
||||||
|
if (assignableNode.memberAccess != null) {
|
||||||
|
assignableNode.memberAccess.accept(this);
|
||||||
|
} else { // TODO: typeNode incrementNode.assignableExpression = null, erledigt
|
||||||
|
if (assignableNode.typeNode instanceof BaseType) {
|
||||||
|
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(assignableNode.identifier));
|
||||||
|
} else if (assignableNode.typeNode instanceof ReferenceType) {
|
||||||
|
methodVisitor.visitVarInsn(ALOAD, localVariables.indexOf(assignableNode.identifier));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadDecrement(DecrementNode decrementNode) {
|
||||||
|
AssignableNode assignableNode = decrementNode.assignableExpression;
|
||||||
|
if (assignableNode.memberAccess != null) {
|
||||||
|
assignableNode.memberAccess.accept(this);
|
||||||
|
} else { // TODO: typeNode decrementNode.assignableExpression = null, erledigt
|
||||||
|
if (assignableNode.typeNode instanceof BaseType) {
|
||||||
|
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(assignableNode.identifier));
|
||||||
|
} else if (assignableNode.typeNode instanceof ReferenceType) {
|
||||||
|
methodVisitor.visitVarInsn(ALOAD, localVariables.indexOf(assignableNode.identifier));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void assignLocalVar(AssignNode assignNode) {
|
private void assignLocalVar(AssignNode assignNode) {
|
||||||
if (!localVariables.contains(assignNode.assignable.identifier)) {
|
if (!localVariables.contains(assignNode.assignable.identifier)) {
|
||||||
localVariables.add(assignNode.assignable.identifier);
|
localVariables.add(assignNode.assignable.identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assignNode.expression.getType() instanceof BaseType) {
|
if (assignNode.expression.getType() instanceof BaseType) {
|
||||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
||||||
} else if (assignNode.expression.getType() instanceof ReferenceType) {
|
} else if (assignNode.expression.getType() instanceof ReferenceType) {
|
||||||
@ -444,7 +500,6 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||||
} else {
|
} else {
|
||||||
localVariables.add(assignNode.assignable.identifier);
|
localVariables.add(assignNode.assignable.identifier);
|
||||||
methodVisitor.visitVarInsn(ALOAD, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assignNode.expression.accept(this);
|
assignNode.expression.accept(this);
|
||||||
@ -458,41 +513,56 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void localVarCrementAssign(AssignNode assignNode) {
|
private void localVarCrementAssign(AssignNode assignNode) {
|
||||||
if (assignNode.expression instanceof IncrementNode) {
|
UnaryNode unaryNode = (UnaryNode) assignNode.expression;
|
||||||
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
if (unaryNode.statement instanceof IncrementNode) {
|
||||||
|
IncrementNode incrementNode = (IncrementNode) unaryNode.statement;
|
||||||
if (incrementNode.crementType.equals(CrementType.PREFIX)) { // ++i
|
if (incrementNode.crementType.equals(CrementType.PREFIX)) { // ++i
|
||||||
incrementNode.accept(this);
|
incrementNode.accept(this);
|
||||||
|
incrementNode.assignableExpression.typeNode = unaryNode.getType();
|
||||||
|
loadInrement(incrementNode);
|
||||||
assignLocalVar(assignNode);
|
assignLocalVar(assignNode);
|
||||||
} else { // i++
|
} else { // i++
|
||||||
loadBeforeCrement(assignNode);
|
incrementNode.assignableExpression.typeNode = unaryNode.getType();
|
||||||
|
loadInrement(incrementNode);
|
||||||
assignLocalVar(assignNode);
|
assignLocalVar(assignNode);
|
||||||
incrementNode.accept(this);
|
incrementNode.accept(this);
|
||||||
}
|
}
|
||||||
} else if (assignNode.expression instanceof DecrementNode decrementNode) {
|
} else if (unaryNode.statement instanceof DecrementNode) {
|
||||||
|
DecrementNode decrementNode = (DecrementNode) unaryNode.statement;
|
||||||
if (decrementNode.crementType.equals(CrementType.PREFIX)) {
|
if (decrementNode.crementType.equals(CrementType.PREFIX)) {
|
||||||
decrementNode.accept(this);
|
decrementNode.accept(this);
|
||||||
|
decrementNode.assignableExpression.typeNode = unaryNode.getType();
|
||||||
|
loadDecrement(decrementNode);
|
||||||
assignLocalVar(assignNode);
|
assignLocalVar(assignNode);
|
||||||
} else {
|
} else {
|
||||||
loadBeforeCrement(assignNode);
|
decrementNode.assignableExpression.typeNode = unaryNode.getType();
|
||||||
|
loadDecrement(decrementNode);
|
||||||
assignLocalVar(assignNode);
|
assignLocalVar(assignNode);
|
||||||
decrementNode.accept(this);
|
decrementNode.accept(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fieldOrObjectVarPrefixCrementAssign(AssignNode assignNode) {
|
private void fieldOrObjectVarCrementAssign(AssignNode assignNode) {
|
||||||
int localVarIndex = localVariables.indexOf(assignNode.assignable.identifier);
|
int localVarIndex = localVariables.indexOf(assignNode.assignable.identifier);
|
||||||
if(localVarIndex >= 0) { // object
|
if (localVarIndex >= 0) { // object
|
||||||
methodVisitor.visitVarInsn(ALOAD, localVarIndex);
|
methodVisitor.visitVarInsn(ALOAD, localVarIndex);
|
||||||
} else if(assignNode.assignable.memberAccess.thisExpr) { // field
|
} else if (assignNode.assignable.memberAccess.thisExpr) { // field
|
||||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||||
} else {
|
} else {
|
||||||
localVariables.add(assignNode.assignable.identifier);
|
localVariables.add(assignNode.assignable.identifier);
|
||||||
methodVisitor.visitVarInsn(ALOAD, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assignNode.expression.accept(this);
|
UnaryNode unaryNode = (UnaryNode) assignNode.expression;
|
||||||
methodVisitor.visitInsn(DUP_X1);
|
if (unaryNode.statement instanceof IncrementNode) {
|
||||||
|
IncrementNode incrementNode = (IncrementNode) unaryNode.statement;
|
||||||
|
incrementNode.assignableExpression.typeNode = unaryNode.getType();
|
||||||
|
loadInrement((incrementNode));
|
||||||
|
} else if (unaryNode.statement instanceof DecrementNode) {
|
||||||
|
DecrementNode decrementNode = (DecrementNode) unaryNode.statement;
|
||||||
|
decrementNode.assignableExpression.typeNode = unaryNode.getType();
|
||||||
|
loadDecrement(decrementNode);
|
||||||
|
}
|
||||||
|
|
||||||
if (assignNode.expression.getType() 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()));
|
||||||
@ -502,55 +572,6 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fieldOrObjectVarSuffixCrementAssign(AssignNode assignNode) {
|
|
||||||
int localVarIndex = localVariables.indexOf(assignNode.assignable.identifier);
|
|
||||||
if(localVarIndex >= 0) { // object
|
|
||||||
methodVisitor.visitVarInsn(ALOAD, localVarIndex);
|
|
||||||
} else if(assignNode.assignable.memberAccess.thisExpr) { // field
|
|
||||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
|
||||||
} else {
|
|
||||||
localVariables.add(assignNode.assignable.identifier);
|
|
||||||
methodVisitor.visitVarInsn(ALOAD, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
}
|
|
||||||
|
|
||||||
loadBeforeCrement(assignNode);
|
|
||||||
|
|
||||||
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() + ";");
|
|
||||||
}
|
|
||||||
|
|
||||||
assignNode.expression.accept(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadBeforeCrement(AssignNode assignNode) {
|
|
||||||
if(assignNode.expression instanceof IncrementNode) {
|
|
||||||
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
|
||||||
if(incrementNode.assignableExpression.memberAccess != null) {
|
|
||||||
incrementNode.assignableExpression.memberAccess.accept(this);
|
|
||||||
} else {
|
|
||||||
if(assignNode.assignable.typeNode instanceof BaseType) {
|
|
||||||
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
} else if(assignNode.assignable.typeNode instanceof ReferenceType) {
|
|
||||||
methodVisitor.visitVarInsn(ALOAD, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(assignNode.expression instanceof DecrementNode) {
|
|
||||||
DecrementNode decrementNode = (DecrementNode) assignNode.expression;
|
|
||||||
if(decrementNode.assignableExpression.memberAccess != null) {
|
|
||||||
decrementNode.assignableExpression.memberAccess.accept(this);
|
|
||||||
} else {
|
|
||||||
if(assignNode.assignable.typeNode instanceof BaseType) {
|
|
||||||
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
} else if(assignNode.assignable.typeNode instanceof ReferenceType) {
|
|
||||||
methodVisitor.visitVarInsn(ALOAD, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(IncrementNode incrementNode) {
|
public void visit(IncrementNode incrementNode) {
|
||||||
if (incrementNode.assignableExpression.memberAccess != null) { // Object var / field
|
if (incrementNode.assignableExpression.memberAccess != null) { // Object var / field
|
||||||
@ -565,7 +586,6 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
} else if (incrementNode.assignableExpression.memberAccess.getTypeNode() instanceof ReferenceType) {
|
} else if (incrementNode.assignableExpression.memberAccess.getTypeNode() instanceof ReferenceType) {
|
||||||
methodVisitor.visitFieldInsn(GETFIELD, incrementNode.assignableExpression.memberAccess.identifiers.get(0), incrementNode.assignableExpression.memberAccess.identifiers.get(1), "L" + (((ReferenceType) incrementNode.assignableExpression.memberAccess.getTypeNode()).getIdentifier() + ";"));
|
methodVisitor.visitFieldInsn(GETFIELD, incrementNode.assignableExpression.memberAccess.identifiers.get(0), incrementNode.assignableExpression.memberAccess.identifiers.get(1), "L" + (((ReferenceType) incrementNode.assignableExpression.memberAccess.getTypeNode()).getIdentifier() + ";"));
|
||||||
}
|
}
|
||||||
methodVisitor.visitInsn(DUP);
|
|
||||||
methodVisitor.visitInsn(ICONST_1);
|
methodVisitor.visitInsn(ICONST_1);
|
||||||
methodVisitor.visitInsn(IADD);
|
methodVisitor.visitInsn(IADD);
|
||||||
if (incrementNode.assignableExpression.memberAccess.getTypeNode() instanceof BaseType) {
|
if (incrementNode.assignableExpression.memberAccess.getTypeNode() instanceof BaseType) {
|
||||||
@ -587,7 +607,6 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
} else { // this
|
} else { // this
|
||||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||||
}
|
}
|
||||||
methodVisitor.visitInsn(DUP);
|
|
||||||
if (decrementNode.assignableExpression.memberAccess.getTypeNode() instanceof BaseType) {
|
if (decrementNode.assignableExpression.memberAccess.getTypeNode() instanceof BaseType) {
|
||||||
methodVisitor.visitFieldInsn(GETFIELD, decrementNode.assignableExpression.memberAccess.identifiers.get(0), decrementNode.assignableExpression.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) decrementNode.assignableExpression.memberAccess.getTypeNode()));
|
methodVisitor.visitFieldInsn(GETFIELD, decrementNode.assignableExpression.memberAccess.identifiers.get(0), decrementNode.assignableExpression.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) decrementNode.assignableExpression.memberAccess.getTypeNode()));
|
||||||
} else if (decrementNode.assignableExpression.memberAccess.getTypeNode() instanceof ReferenceType) {
|
} else if (decrementNode.assignableExpression.memberAccess.getTypeNode() instanceof ReferenceType) {
|
||||||
@ -660,6 +679,21 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
} else { // Return something
|
} else { // Return something
|
||||||
// Process expression
|
// Process expression
|
||||||
returnNode.expression.accept(this);
|
returnNode.expression.accept(this);
|
||||||
|
|
||||||
|
if (returnNode.expression instanceof UnaryNode) {
|
||||||
|
UnaryNode unaryNode = (UnaryNode) returnNode.expression;
|
||||||
|
if (unaryNode.statement instanceof IncrementNode) {
|
||||||
|
IncrementNode incrementNode = (IncrementNode) unaryNode.statement;
|
||||||
|
incrementNode.assignableExpression.typeNode = unaryNode.getType();
|
||||||
|
loadInrement(incrementNode);
|
||||||
|
}
|
||||||
|
if (unaryNode.statement instanceof DecrementNode) {
|
||||||
|
DecrementNode decrementNode = (DecrementNode) unaryNode.statement;
|
||||||
|
decrementNode.assignableExpression.typeNode = unaryNode.getType();
|
||||||
|
loadDecrement(decrementNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return result of expression
|
// Return result of expression
|
||||||
if (returnNode.expression.getType() instanceof BaseType) {
|
if (returnNode.expression.getType() instanceof BaseType) {
|
||||||
methodVisitor.visitInsn(IRETURN);
|
methodVisitor.visitInsn(IRETURN);
|
||||||
|
Loading…
Reference in New Issue
Block a user