TDT4205/exercises/04/vslc/include/ir.h

52 lines
1.1 KiB
C
Raw Normal View History

2022-03-12 18:09:07 +01:00
#ifndef IR_H
#define IR_H
/* This is the tree node structure */
typedef struct n {
node_index_t type;
void *data;
struct s *entry;
uint64_t n_children;
struct n **children;
} node_t;
2022-03-12 19:21:38 +01:00
/**Export the initializer function, it is needed by the parser
* @param *nd node to initialize
* @param type type of node (see nodetype.h)
* @param *data associated data. Declared void to allow any type
* @param n_children number of children
* @param ... variable argument list of child nodes (node_t *)
*
* @return Pointer to the initialized node
* */
node_t* node_init (
2022-03-13 20:19:53 +01:00
node_t* nd,
node_index_t type,
void* data,
2022-03-15 22:29:29 +01:00
uint64_t n_children,
2022-03-13 20:19:53 +01:00
...
2022-03-12 18:09:07 +01:00
);
typedef enum {
2022-03-13 20:19:53 +01:00
SYM_GLOBAL_VAR,
SYM_FUNCTION,
SYM_PARAMETER,
SYM_LOCAL_VAR
2022-03-12 18:09:07 +01:00
} symtype_t;
typedef struct s {
2022-03-17 21:40:18 +01:00
char* name;
symtype_t type;
node_t* node;
size_t seq;
size_t nparms;
tlhash_t* locals;
2022-03-12 18:09:07 +01:00
} symbol_t;
#endif
2022-03-15 22:29:29 +01:00
#define GLOBAL_BUCKET_SIZE 32
#define LOCAL_BUCKET_SIZE 16
2022-03-16 22:25:32 +01:00
#define DEFAULT_STRING_LIST_SIZE 8
2022-03-16 22:26:25 +01:00
#define DEFAULT_NO_SCOPES 1