It seems that I had for gotten to fix one of the signatures

This commit is contained in:
Meyer Simon
2025-04-17 11:14:38 -04:00
parent f8010f463b
commit b8f468c94a
2 changed files with 68 additions and 51 deletions

View File

@ -2,7 +2,7 @@
// * Add Bison actions for arithmetic expressions:
// - Addition: $$ = new_temp(); emit_binary_op($$, "ADD", $1, $3);
// - Subtraction, multiplication, division, modulo
#include "symbol_table.h"
#include "runner.h"
#include <stdarg.h>
// these are from page 364
@ -44,42 +44,43 @@ typedef enum {
} Discriminant;
typedef union {
TableNode * node;
int integer;
char * string;
char character;
void * address;
bool Boolean;
} RegConstUnion;
TableNode * node;
int integer;
char * string;
char character;
void * address;
bool Boolean;
} TNConstUnion;
typedef struct {
Discriminant d;
RegConstUnion * rc_union;
TNConstUnion * tnc_union;
} TNodeOrConst;
typedef struct Instruction Instruction;
typedef struct Instruction {
Op opcode;
TableNode * result;
TableNode * result;
TNodeOrConst * operand1;
TableNode * operand2;
char * label;
TNodeOrConst * operand2;
int label;
int index;
int index;
Instruction * prev;
Instruction * next;
Instruction * prev;
Instruction * next;
} Instruction;
extern Instruction * begin;
extern Instruction * current;
extern Instruction * begin;
extern Instruction * current;
int temp_count = 0;
int label_count = 0;
bool code_gen = true;
void emit_binary_op(Op op, TableNode * result, TNodeOrConst * arg1, TableNode * arg2);
TNodeOrConst * tn_or_const(Op op, void * tnc);
void emit_binary_op(Op op, TableNode * result, TNodeOrConst * arg1, TNodeOrConst * arg2);
void emit_unary_op(Op op, TableNode * result, TNodeOrConst * arg);
void emit_assignment(TableNode * target, TNodeOrConst * source);
// TODO: Find out what these are suposed to do. Guess is create an entry in
@ -93,13 +94,13 @@ void emit_as_file(FILE * out_file, Instruction * instr_arr);
// * Implement instruction array storage for backpatching
void emit_label(char* label);
void emit_jump(char* label);
void emit_conditional_jump(int count, ...);
void emit_label(int label);
void emit_jump(int label);
void emit_conditional_jump(Op condition, int label, ...);
void emit_function_start(char* name);
void emit_function_start(int name);
void emit_parameter(TNodeOrConst * param);
void emit_function_call(TNodeOrConst * result, TNodeOrConst * name);
void emit_function_call(TableNode * result, int param_count, TNodeOrConst * name);
void emit_return(TNodeOrConst * value);
void emit_reserve(char* result, char* type_name, int size);
void emit_release(char* pointer);