Skip to content

Commit 6f49d61

Browse files
committed
Added support for class variables w/ Conditional Jumps
Also fixed a bug in a constant being used with the branch.
1 parent 1d5546a commit 6f49d61

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎codegen/CodeGenerator.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,9 @@ private void handleConditionalJump(Quadruple instruction, BufferedWriter bw)
915915
if(arg1.getType().equals("constant"))
916916
{
917917
String tempReg = allocator.allocateTempReg(0);
918+
temp = "li " + tempReg + ", " + arg1.getName() + "\n";
919+
bw.write(temp, 0, temp.length());
920+
918921
temp = "beq " + tempReg + ", $zero, " + label + "\n";
919922
}
920923
else if(arg1.getType().equals("temporary"))
@@ -929,8 +932,9 @@ else if(arg1.getType().equals("temporary"))
929932
}
930933
else //Class variable
931934
{
932-
//Todo
933-
temp = "";
935+
String tempReg = allocator.allocateTempReg(0);
936+
temp = "lw " + tempReg + ", " + arg1.getOffset() + "($a0)\n";
937+
temp = "beq " + tempReg + ", $zero, " + label + "\n";
934938
}
935939
}
936940

0 commit comments

Comments
 (0)