Skip to content

Commit 01eb877

Browse files
committed
passing in almost all tests
1 parent fa2084e commit 01eb877

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/codeGen.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,7 @@ char* adressOfLeftAssign(Exp* e) {
706706
}
707707
int codeCond(Exp* e) {
708708
int i1;
709-
int temp = currentTempRegs[3];
710-
//fprintf(output, ";begin codecond\n");
709+
int temp = currentTempRegs[1];
711710
i1 = codeExp(e);
712711
codeZero(temp);
713712
incrementXbyY2(temp,i1);
@@ -740,18 +739,20 @@ void codeCommandList(CommandL* cl) {
740739
codeDebugMessage("end while");
741740
break;
742741
case CIf:
742+
temp0 = pushCells(1);
743+
codeZero(temp0);
743744
i1 = codeCond(c->condExp);
744-
bfalgo("[\n");
745-
codeCommandList(c->cmdIf );
746-
codeZero(currentTempRegs[2]);
747-
codeGoTo(currentTempRegs[3]);
748-
bfalgo("]\n");
745+
bfalgo("$[",i1);
746+
codeCommandList(c->cmdIf);
747+
bfalgo("$]$",temp0,i1);
748+
749+
749750
// leaveScope();
750751
break;
751752
case CIfElse:
752753
i1 = codeCond(c->condExp);
753-
temp0 = currentTempRegs[2];
754-
temp1 = currentTempRegs[3];
754+
temp0 = pushCells(1);
755+
temp1 = pushCells(1);
755756
bfalgo("$[-]+$[-]$[",temp0,temp1,i1);
756757
codeCommandList(c->cmdIf);
757758
bfalgo("$-$[$+$-]]$[$+$-]$[",temp0,i1,temp1,i1,temp1,i1,temp1,temp0);

test/runnable/dec.ha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ void main() {
22
byte x,y,z;
33
x = 20;
44
x--;
5-
@x;
5+
@x;@"\n";
66
}

test/runnable/optimize2.answer

Whitespace-only changes.

test/runnable/optimize2.ha

Whitespace-only changes.

0 commit comments

Comments
 (0)