@@ -12,6 +12,19 @@ public class JVMInstructionUtils {
12
12
13
13
public static int numLocals = 0 ;
14
14
public static int stackSize = 0 ;
15
+ public static int currStackSize = 0 ;
16
+
17
+ public static void increaseStackSize (int n ) {
18
+ currStackSize += n ;
19
+ if (currStackSize > stackSize )
20
+ stackSize = currStackSize ;
21
+ }
22
+
23
+ public static void decreaseStackSize (int n ) {
24
+ currStackSize -= n ;
25
+ if (currStackSize > stackSize )
26
+ stackSize = currStackSize ;
27
+ }
15
28
16
29
public static String getLoadInstruction (Element element , HashMap <String , Descriptor > varTable ) {
17
30
if (element .isLiteral ()) {
@@ -33,7 +46,7 @@ public static String getLoadInstruction(Element element, HashMap<String, Descrip
33
46
else
34
47
elementType = element .getType ().getTypeOfElement ();
35
48
int virtualReg = varTable .get (((Operand )element ).getName ()).getVirtualReg ();
36
- if (virtualReg > JVMInstructionUtils . numLocals )
49
+ if (virtualReg > numLocals )
37
50
numLocals = virtualReg ;
38
51
39
52
switch (elementType ) {
@@ -62,7 +75,7 @@ public static String getArrayLoadInstruction(ArrayOperand array, HashMap<String,
62
75
63
76
public static String getStoreInstruction (Element element , HashMap <String , Descriptor > varTable ) {
64
77
int virtualReg = varTable .get (((Operand )element ).getName ()).getVirtualReg ();
65
- if (virtualReg > JVMInstructionUtils . numLocals )
78
+ if (virtualReg > numLocals )
66
79
numLocals = virtualReg ;
67
80
68
81
if (element .isLiteral ()) {
0 commit comments