Skip to content

Commit d3f0780

Browse files
committed
Added number of method arguments and this for instance methods in locals calculation
1 parent afa84a8 commit d3f0780

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/pt/up/fe/comp2023/jasmin/JasminUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,12 @@ public static String createConstructMethod(String superClassName) {
198198
public static String createMethodDirective(Method method) {
199199
JVMInstructionUtils.numLocals = 0;
200200
JVMInstructionUtils.stackSize = 0;
201-
String methodDirective = ".method ";
202201
String instructions = handleMethodStatements(method);
202+
JVMInstructionUtils.numLocals += method.getParams().size();
203+
if (!method.isStaticMethod())
204+
JVMInstructionUtils.numLocals++;
203205

206+
String methodDirective = ".method ";
204207
methodDirective += createMethodDeclaration(method);
205208
methodDirective += "\t.limit stack " + JVMInstructionUtils.stackSize + "\n";
206209
methodDirective += "\t.limit locals " + JVMInstructionUtils.numLocals + "\n";

0 commit comments

Comments
 (0)