Demo file choice

This commit is contained in:
Meyer Simon
2025-04-30 09:36:05 -04:00
parent 856e443181
commit 5b3de8cb02
3 changed files with 52 additions and 47 deletions

View File

@ -118,7 +118,7 @@ CGNode *findCG(TableNode *tn) {
CGNode *addCG(TableNode *tn, int sp) { CGNode *addCG(TableNode *tn, int sp) {
CGNode *cg = calloc(1, sizeof(CGNode)); CGNode *cg = calloc(1, sizeof(CGNode));
cg->tn = tn; cg->tn = tn;
offset += 4; // <- quick fix getPrimSize(getTypeEntry(tn)) offset += getPrimSize(getTypeEntry(tn));
cg->address = offset; cg->address = offset;
cg->next = cgList; cg->next = cgList;
cgList = cg; cgList = cg;

View File

@ -129,6 +129,10 @@ TNodeOrConst * tn_or_const(Discriminant d, void * tnc) {
} }
static void emit_helper(void){ static void emit_helper(void){
if (!ir_flag) {
begin = NULL;
return;
}
Instruction * inst = calloc(1, sizeof(*inst)); Instruction * inst = calloc(1, sizeof(*inst));
if(begin == NULL){ if(begin == NULL){
begin = current = inst; begin = current = inst;

View File

@ -121,6 +121,7 @@ extern Instruction * begin;
extern Instruction * current; extern Instruction * current;
extern int label_count; extern int label_count;
extern bool code_gen; extern bool code_gen;
extern FILE * ir_flag;
TNodeOrConst * tn_or_const(Discriminant , void * ); TNodeOrConst * tn_or_const(Discriminant , void * );