please dont break

This commit is contained in:
Annie
2025-05-06 16:44:26 -04:00
parent a7e10521d8
commit 8bba742c99
2 changed files with 33 additions and 4 deletions

View File

@ -535,11 +535,39 @@ int generateCondGoto(Instruction *inst) {
}
int generateIfTrue(Instruction *inst) {
TNodeOrConst *op1 = getOperand1(inst);
if (op1 == NULL) {
printdebug("%sgenerateIfTrue failed, NULL operand", COLOR_RED);
return -1;
}
CGNode *cg = findCG(getTN(op1));
if (cg == NULL) {
printdebug("generateIfTrue failed, operand not on stack");
return -1;
}
fprintf(cg_flag, "\tcmpl\t$0, %d(%%rbp)\t#if true start\n", getAddress(cg));
fprintf(cg_flag, "\tjne\t.L%d\t\t#if true end\n", getLabel(inst));
}
int generateIfFalse(Instruction *inst) {
TNodeOrConst *op1 = getOperand1(inst);
if (op1 == NULL) {
printdebug("%sgenerateIfFalse failed, NULL operand", COLOR_RED);
return -1;
}
CGNode *cg = findCG(getTN(op1));
if (cg == NULL) {
printdebug("generateIfFalse failed, operand not on stack");
return -1;
}
fprintf(cg_flag, "\tcmpl\t$0, %d(%%rbp)\t#if false start\n", getAddress(cg));
fprintf(cg_flag, "\tje\t.L%d\t\t#if false end\n", getLabel(inst));
}
int generateLessThan(Instruction *inst) {

View File

@ -12,9 +12,10 @@ Fib(i) := {
} else {
i := i;
}
b := b | (a & c);
b := 2 < 3;
(*b := b | (a & c);
b := 2 < 3;*)
if(i = 1) then {
i := printCharacter('a');
return 1;
} else {
return i + Fib(i - 1);