Implemented the 2 operation functions #t51
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
#include "intermediate_code.h"
|
||||
|
||||
|
||||
start = current = NULL;
|
||||
|
||||
|
||||
|
||||
@ -7,11 +11,38 @@
|
||||
|
||||
|
||||
|
||||
void emit_binary_op(char* result, char* op, char* arg1, char* arg2){
|
||||
return;
|
||||
void emit_binary_op(char* result, Op op, char* arg1, char* arg2){
|
||||
Instruction * inst = calloc(1, sizeof(*inst));
|
||||
if(start == NULL){
|
||||
start = current = inst;
|
||||
current->index = 1;
|
||||
} else {
|
||||
current->next = inst;
|
||||
inst->prev = current;
|
||||
inst->index = current->index++;
|
||||
current = inst;
|
||||
}
|
||||
current->opcode = op;
|
||||
current->result = look_up(result);
|
||||
current->operand1 = look_up(arg1);
|
||||
current->operand2 = look_up(arg2);
|
||||
return;
|
||||
}
|
||||
void emit_unary_op(char* result, char* op, char* arg){
|
||||
return;
|
||||
void emit_unary_op(char* result, Oo op, char* arg){
|
||||
Instruction * inst = calloc(1, sizeof(*inst));
|
||||
if(start == NULL){
|
||||
start = current = inst;
|
||||
current->index = 1;
|
||||
} else {
|
||||
current->next = inst;
|
||||
inst->prev = current;
|
||||
inst->index = current->index++;
|
||||
current = inst;
|
||||
}
|
||||
current->opcode = op;
|
||||
current->result = look_up(result);
|
||||
current->operand1 = look_up(arg);
|
||||
return;
|
||||
}
|
||||
void emit_assignment(char* target, char* source){
|
||||
return;
|
||||
|
Reference in New Issue
Block a user