I added some packpatching
This commit is contained in:
@ -69,6 +69,13 @@ void emit_detach(){
|
||||
current->next = NULL;
|
||||
}
|
||||
|
||||
void backpatch(Stack *s, int l){
|
||||
while (!S_IsEmpty(s)){
|
||||
Instruction * i = S_Pop(s);
|
||||
set_label(i, l);
|
||||
}
|
||||
}
|
||||
|
||||
TNodeOrConst * getOperand1(Instruction * i){
|
||||
return i->operand1;
|
||||
}
|
||||
@ -480,21 +487,21 @@ void emit_as_file(FILE * out_file, Instruction * i){
|
||||
case E_LESS_THAN:
|
||||
// this feels wrong I need to TODO: this
|
||||
fprintf(out_file,
|
||||
"%4.d: %s = %s < %s\n",
|
||||
"%4.d: if ( %s < %s ) GOTO %d\n",
|
||||
i->index,
|
||||
getName(i->result),
|
||||
get_string(i->operand1),
|
||||
get_string(i->operand2)
|
||||
get_string(i->operand2),
|
||||
i->label
|
||||
);
|
||||
break;
|
||||
case E_EQUAL_TO:
|
||||
// this feels wrong I need to TODO: this
|
||||
fprintf(out_file,
|
||||
"%4.d: %s = %s == %s\n",
|
||||
"%4.d: if ( %s = %s ) GOTO %d\n",
|
||||
i->index,
|
||||
getName(i->result),
|
||||
get_string(i->operand1),
|
||||
get_string(i->operand2)
|
||||
get_string(i->operand2),
|
||||
i->label
|
||||
);
|
||||
break;
|
||||
case E_CALL:
|
||||
|
Reference in New Issue
Block a user