-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcode.h
43 lines (37 loc) · 1007 Bytes
/
code.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
#include "const.h"
#define MAX_TABLE_SIZE 5000
void init_symbol_table();
char * install_symbol(char *s);
int look_up_symbol(char *s);
int look_up_symbol_kw(char *s);
void pop_up_symbol(int scope);
void set_scope_and_offset_of_param(char *s);
void set_local_vars(char *functor);
void set_global_vars(char *s);
void code_gen_func_header(char *functor);
void code_gen_global_vars();
void code_gen_at_end_of_function_body(char *functor);
char * copyn(register int n, register char *s);
char * copys(char *s);
typedef struct symbol_entry *PTR_SYMB;
struct symbol_entry {
char *name;
int scope;
int offset;
int id;
int variant;
int type;
int total_args;
int total_locals;
int mode;
int functor_index; /* add for risc-v, 2020 by Jenq-Kuen Lee */
} table[MAX_TABLE_SIZE];
#define T_FUNCTION 1
#define ARGUMENT_MODE 2
#define LOCAL_MODE 4
#define GLOBAL_MODE 8
extern int cur_scope;
extern int cur_counter;
extern FILE* codegen;