From ee302bb2456306dfe252db51555898871b454746 Mon Sep 17 00:00:00 2001 From: Matthias Raba Date: Tue, 18 Jun 2024 07:37:01 +0200 Subject: [PATCH] maxLocals calculation --- src/ByteCode/Builder.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ByteCode/Builder.hs b/src/ByteCode/Builder.hs index dfebf89..258592a 100644 --- a/src/ByteCode/Builder.hs +++ b/src/ByteCode/Builder.hs @@ -69,18 +69,19 @@ methodAssembler (MethodDeclaration returntype name parameters statement) input = in case (splitAt index (methods input)) of (pre, []) -> input (pre, method : post) -> let - (_, bytecode, _) = assembleMethod (constantPool input, [], paramNames) declaration + (constants, bytecode, aParamNames) = assembleMethod (constantPool input, [], paramNames) declaration assembledMethod = method { memberAttributes = [ CodeAttribute { attributeMaxStack = 420, - attributeMaxLocals = 420, + attributeMaxLocals = fromIntegral $ length aParamNames, attributeCode = bytecode } ] } in input { + constantPool = constants, methods = pre ++ (assembledMethod : post) }