Fixed methotcall with params
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
i22007 2024-07-05 06:20:49 -04:00
parent c6e61defce
commit 3fb11e5d7e

View File

@ -267,7 +267,7 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
@Override @Override
public void visit(MemberAccessNode memberAccessNode) { public void visit(MemberAccessNode memberAccessNode) {
// Only used to get, not to put // Only used to get, not to put
int localVarIndex = localVariables.indexOf("memberAccessNode.identifier"); // TODO: Anführungszeichen entfernen int localVarIndex = localVariables.indexOf("memberAccessNode.identifier"); // TODO
if (localVarIndex >= 0) { // local var object if (localVarIndex >= 0) { // local var object
methodVisitor.visitVarInsn(ALOAD, localVarIndex); methodVisitor.visitVarInsn(ALOAD, localVarIndex);
} else { // this field } else { // this field
@ -723,10 +723,6 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
@Override @Override
public void visit(MethodCallNode methodCallNode) { public void visit(MethodCallNode methodCallNode) {
List<ParameterNode> parameterNodes = new ArrayList<>(); List<ParameterNode> parameterNodes = new ArrayList<>();
for (IExpressionNode expressionNode : methodCallNode.parameters) {
expressionNode.accept(this);
parameterNodes.add(new ParameterNode(expressionNode.getType(), ""));
}
int localVarIndex = -1; int localVarIndex = -1;
if (methodCallNode.target.memberAccess.identifiers.size() > 1) { if (methodCallNode.target.memberAccess.identifiers.size() > 1) {
localVarIndex = localVariables.indexOf(methodCallNode.target.memberAccess.identifiers.get(1)); localVarIndex = localVariables.indexOf(methodCallNode.target.memberAccess.identifiers.get(1));
@ -736,8 +732,9 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
} else { // this field } else { // this field
methodVisitor.visitVarInsn(ALOAD, 0); methodVisitor.visitVarInsn(ALOAD, 0);
} }
if (methodCallNode.type == null) { for (IExpressionNode expressionNode : methodCallNode.parameters) {
methodCallNode.type = new BaseType(TypeEnum.INT); expressionNode.accept(this);
parameterNodes.add(new ParameterNode(expressionNode.getType(), ""));
} }
methodVisitor.visitMethodInsn(INVOKEVIRTUAL, methodCallNode.target.memberAccess.identifiers.get(0), methodCallNode.identifier, mapper.generateMethodDescriptor(methodCallNode.type, parameterNodes), false); methodVisitor.visitMethodInsn(INVOKEVIRTUAL, methodCallNode.target.memberAccess.identifiers.get(0), methodCallNode.identifier, mapper.generateMethodDescriptor(methodCallNode.type, parameterNodes), false);
} }