I made the IR compile

This commit is contained in:
Meyer Simon
2025-04-29 22:40:32 -04:00
parent 789d67d0b6
commit e45f0663f1
5 changed files with 1058 additions and 20 deletions

View File

@ -24,6 +24,13 @@ typedef struct Stack {
__Node * n;
int size;
} Stack;
Stack * S_Init();
void S_Free(Stack *s);
void S_Push(Stack * s, void *v);
void * S_Pop(Stack *s);
void * S_Peek(Stack *s);
bool S_IsEmpty(Stack *s);
int S_Size(Stack *s);
//______________________________________________________________________________________________
typedef union TNConstUnion TNConstUnion;
@ -112,9 +119,8 @@ void bp_temp(int n);
extern Instruction * begin;
extern Instruction * current;
int temp_count = 0;
int label_count = 0;
bool code_gen = true;
extern int label_count;
extern bool code_gen;
TNodeOrConst * tn_or_const(Discriminant , void * );
@ -127,7 +133,7 @@ void emit_jump(int label);
void emit_conditional_jump(Op condition, int label, ...);
void emit_function_start(int name);
void emit_function_start(TableNode* name);
void emit_parameter(TNodeOrConst * param);
void emit_function_call(TableNode * result, int param_count, TNodeOrConst * name);
void emit_return(TNodeOrConst * value);
@ -135,4 +141,21 @@ void emit_reserve(TableNode * result, TNodeOrConst * size);
void emit_release(TableNode * pointer);
void emit_field_access(char* result, char* record, char* field);
void emit_array_access(Op op, TableNode * result, TNodeOrConst * array, TNodeOrConst * index);
void emit_bounds_check(TNodeOrConst * index, TNodeOrConst * arr, int error_label);
void emit_bounds_check(TNodeOrConst * index, TNodeOrConst * arr);
int getLabel(Instruction * i);
TableNode* getTN(TNodeOrConst* tnc);
int getConst(TNodeOrConst* tnc);
TNodeOrConst * getOperand1(Instruction * i);
TNodeOrConst * getOperand2(Instruction * i);
TableNode * getResult(Instruction * i);
Op getOp(Instruction * i);
int getLabel(Instruction * i);
int get_index(Instruction * i);
void set_label(Instruction * i, int label);
bool isConst(TNodeOrConst * tnc);
int label_gen();