add returnType into MethodContext constructor call

This commit is contained in:
simon 2024-06-25 17:28:21 +02:00
parent 724347e250
commit b917ae594d

View File

@ -124,7 +124,7 @@ public class TypedMethod implements TypedNode {
int accessModifier = Opcodes.ACC_PUBLIC; // ist laut Andi ok
MethodVisitor mv = ctx.getCw().visitMethod(accessModifier, name,
CodeGenUtils.generateDescriptor(typedParameters.stream().map(TypedParameter::getType).toList(), returnType), null, null);
MethodContext mctx = new MethodContext(ctx, mv);
MethodContext mctx = new MethodContext(ctx, mv, returnType);
typedParameters.forEach(param -> mctx.registerVariable(param.getParaName(), param.getType()));
typedBlock.codeGen(mctx);
@ -134,7 +134,7 @@ public class TypedMethod implements TypedNode {
public void codeGenMain(ClassContext ctx) {
MethodVisitor mv = ctx.getCw().visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC,
name, "([Ljava/lang/String;)V", null, null);
MethodContext mctx = new MethodContext(ctx, mv);
MethodContext mctx = new MethodContext(ctx, mv, returnType);
typedParameters.forEach(param -> mctx.registerVariable(param.getParaName(), param.getType()));
typedBlock.codeGen(mctx);