First step to fixing methodCall
This commit is contained in:
parent
cabbbdcaf3
commit
38aeaa657d
@ -37,6 +37,8 @@ public class InstVarExpression extends AbstractType implements IExpression{
|
|||||||
}
|
}
|
||||||
TypeCheckResult result = new TypeCheckResult();
|
TypeCheckResult result = new TypeCheckResult();
|
||||||
result.type = varType;
|
result.type = varType;
|
||||||
|
//TODO: Needed for methodCall codeGen
|
||||||
|
setTypeCheckResult(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,30 +119,30 @@ public class MethodCallStatementExpression extends AbstractType implements IExpr
|
|||||||
} else {
|
} else {
|
||||||
throw new ExecutionControl.NotImplementedException("Receiver is null.");
|
throw new ExecutionControl.NotImplementedException("Receiver is null.");
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
else {
|
|
||||||
|
|
||||||
String type = localVars.get(receiver.identifier);
|
|
||||||
if (type == null) {
|
|
||||||
type = typeContext.get(thisClass).get(receiver.identifier);
|
|
||||||
}
|
|
||||||
mv.visitVarInsn(Opcodes.ALOAD, 1);
|
|
||||||
mv.visitFieldInsn(Opcodes.GETFIELD, thisClass, receiver.identifier, "L" + type + ";");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Generate the code for each argument expression
|
// Generate the code for each argument expression
|
||||||
for (IExpression argument : arguments) {
|
for (IExpression argument : arguments) {
|
||||||
argument.codeGen(mv, localVars, typeContext, methodContext);
|
argument.codeGen(mv, localVars, typeContext, methodContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke the method
|
// Invoke the method for each receiving method in the chain
|
||||||
String descriptor = getMethodDescriptor(localVars, methodContext);
|
for (ReceivingMethod receivingMethod : receivingMethods) {
|
||||||
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, methodName, descriptor, false);
|
// Get the owner class for the current method in the chain
|
||||||
|
owner = receivingMethod.thisClass;
|
||||||
|
|
||||||
|
// Generate the code for each argument expression for the current method
|
||||||
|
for (IExpression argument : receivingMethod.arguments) {
|
||||||
|
argument.codeGen(mv, localVars, typeContext, methodContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoke the current method
|
||||||
|
String descriptor = getMethodDescriptor(receivingMethod.methodName, localVars, methodContext, receivingMethod.arguments);
|
||||||
|
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, receivingMethod.methodName, descriptor, false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ()I
|
// ()I
|
||||||
private String getMethodDescriptor(LinkedHashMap<String, String> localVars, HashMap<String, HashMap<String, HashMap<String, ParameterList>>> methodContext) {
|
private String getMethodDescriptor(String methodName, LinkedHashMap<String, String> localVars, HashMap<String, HashMap<String, HashMap<String, ParameterList>>> methodContext, List<IExpression> arguments) {
|
||||||
StringBuilder descriptor = new StringBuilder("(");
|
StringBuilder descriptor = new StringBuilder("(");
|
||||||
|
|
||||||
for (IExpression argument : arguments) {
|
for (IExpression argument : arguments) {
|
||||||
|
Loading…
Reference in New Issue
Block a user