emission for func dec
This commit is contained in:
@ -315,6 +315,7 @@ function_declaration:
|
||||
CreateEntry(cur,TYPE_FUNCTION_DECLARATION, look_up(cur, $4), $2, CreateFunctionDeclarationInfo(-1, false,NULL));
|
||||
|
||||
}
|
||||
emit_function_dec(table_lookup(cur, $2));
|
||||
}
|
||||
|
||||
| EXTERNAL FUNCTION ID COLON ID
|
||||
|
@ -167,6 +167,7 @@ TNodeOrConst *tn_or_const(Discriminant d, void *tnc) {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static void emit_helper(void) {
|
||||
Instruction *inst = calloc(1, sizeof(*inst));
|
||||
if (begin == NULL) {
|
||||
@ -179,6 +180,11 @@ static void emit_helper(void) {
|
||||
current = inst;
|
||||
}
|
||||
}
|
||||
void emit_function_dec(TableNode * name){
|
||||
emit_helper();
|
||||
current->opcode = E_FUNC_DEC;
|
||||
current->result = name;
|
||||
}
|
||||
|
||||
void emit_binary_op(
|
||||
Op op,
|
||||
@ -405,6 +411,13 @@ void emit_as_file(FILE *out_file, Instruction *i) {
|
||||
return;
|
||||
}
|
||||
switch (i->opcode) {
|
||||
case E_FUNC_DEC:
|
||||
fprintf(out_file,
|
||||
"%4.d: func_dec : %s\n",
|
||||
i->index,
|
||||
getName(i->result));
|
||||
|
||||
break;
|
||||
case E_FUNC_START:
|
||||
fprintf(out_file,
|
||||
"%4.d: func : %s\n",
|
||||
|
@ -44,6 +44,7 @@ typedef struct TNodeOrConst TNodeOrConst;
|
||||
typedef enum { // these are from page 364
|
||||
E_LABEL = 10000, // this is not in the book
|
||||
E_FUNC_START,
|
||||
E_FUNC_DEC,
|
||||
E_ADD, // 1 from the list
|
||||
E_SUB, // 1
|
||||
E_MUL, // 1
|
||||
@ -138,6 +139,7 @@ void emit_conditional_jump(Op condition, int label, ...);
|
||||
void emit_function_start(TableNode *name);
|
||||
void emit_parameter(TNodeOrConst *param);
|
||||
void emit_function_call(TableNode *result, int param_count, TNodeOrConst *name);
|
||||
void emit_function_dec(TableNode * name);
|
||||
void emit_return(TNodeOrConst *value);
|
||||
void emit_reserve(TableNode *result, TNodeOrConst *size);
|
||||
void emit_release(TableNode *pointer);
|
||||
|
Reference in New Issue
Block a user