Added body of some of the functions (not compiling) #t51
This commit is contained in:
@ -12,24 +12,48 @@
|
||||
// - Subtraction, multiplication, division, modulo
|
||||
#include "symbol_table.h"
|
||||
|
||||
typedef enum {ADD, SUB, MUL, DIV} Op; // TODO: add all the instructions
|
||||
typedef struct {
|
||||
// these are from page 364
|
||||
typedef enum {
|
||||
LABEL, // this is not in the book
|
||||
ADD, // 1 from the list
|
||||
SUB, // 1
|
||||
MUL, // 1
|
||||
DIV, // 1
|
||||
MOD, // 1
|
||||
OR, // 1
|
||||
AND, // 1
|
||||
NEG, // 2
|
||||
NOT, // 2
|
||||
ASSIGN, // 3
|
||||
GOTO, // 4
|
||||
CGOTO, // 5
|
||||
LESSTHEN, // 6 rule 1 + 5
|
||||
EQUALTO, // 6 rule 1 + 5
|
||||
PARAM, // 7
|
||||
CALL // 7
|
||||
|
||||
} Op;
|
||||
typedef struct Instruction {
|
||||
Op opcode;
|
||||
TableNode * result;
|
||||
TableNode * operand1;
|
||||
TableNode * operand2;
|
||||
int label;
|
||||
char * label;
|
||||
|
||||
|
||||
int index;
|
||||
|
||||
|
||||
Instruction * prev;
|
||||
Instruction * next;
|
||||
} Instruction;
|
||||
|
||||
Instruction * start;
|
||||
Instruction * current;
|
||||
extern Instruction * begin;
|
||||
extern Instruction * current;
|
||||
|
||||
|
||||
void emit_binary_op(char* result, char* op, char* arg1, char* arg2);
|
||||
void emit_unary_op(char* result, char* op, char* arg);
|
||||
void emit_binary_op(char* result, Op op, char* arg1, char* arg2);
|
||||
void emit_unary_op(char* result, Op op, char* arg);
|
||||
void emit_assignment(char* target, char* source);
|
||||
// TODO: Find out what these are suposed to do. Guess is create an entry in
|
||||
// the list of instructions. Guess is that its suposed to ret a struct ptr
|
||||
|
Reference in New Issue
Block a user