}
/* Initialize main ast node aprts */
-static void ast_node_init(ast_node *self, lex_ctx_t ctx)
+static void ast_node_init(ast_node *self, lex_ctx ctx)
{
self->node.context = ctx;
self->node.destroy = &_ast_node_destroy;
ast_setfunc(&self->expression, codegen, codegen);
}
-ast_value* ast_value_new(lex_ctx_t ctx, const char *name, int t, bool keep)
+ast_value* ast_value_new(lex_ctx ctx, const char *name, int t, bool keep)
{
ast_instantiate(ast_value, ctx, ast_value_delete);
ast_expression_init((ast_expression*)self,
return !!self->name;
}
-ast_binary* ast_binary_new(lex_ctx_t ctx, int op,
+ast_binary* ast_binary_new(lex_ctx ctx, int op,
ast_value* left, ast_value* right)
{
ast_instantiate(ast_binary, ctx, ast_binary_delete);
mem_d(self);
}
-ast_store* ast_store_new(lex_ctx_t ctx, int op,
+ast_store* ast_store_new(lex_ctx ctx, int op,
ast_value *dest, ast_value *source)
{
ast_instantiate(ast_store, ctx, ast_store_delete);
mem_d(self);
}
-ast_block* ast_block_new(lex_ctx_t ctx)
+ast_block* ast_block_new(lex_ctx ctx)
{
ast_instantiate(ast_block, ctx, ast_block_delete);
ast_expression_init((ast_expression*)self,
mem_d(self);
}
-ast_function* ast_function_new(lex_ctx_t ctx, const char *name, ast_value *vtype)
+ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype)
{
ast_instantiate(ast_function, ctx, ast_function_delete);
typedef void ast_node_delete(ast_node*);
typedef struct
{
- lex_ctx_t context;
+ lex_ctx context;
/* I don't feel comfortable using keywords like 'delete' as names... */
ast_node_delete *destroy;
/* keep: if a node contains this node, 'keep'
union {
double vfloat;
int vint;
- vector_t vvec;
+ vector vvec;
const char *vstring;
int ventity;
ast_function *vfunc;
*/
MEM_VECTOR_MAKE(ast_value*, params);
};
-ast_value* ast_value_new(lex_ctx_t ctx, const char *name, int qctype, bool keep);
+ast_value* ast_value_new(lex_ctx ctx, const char *name, int qctype, bool keep);
void ast_value_delete(ast_value*);
bool ast_value_set_name(ast_value*, const char *name);
ast_value *left;
ast_value *right;
};
-ast_binary* ast_binary_new(lex_ctx_t ctx,
+ast_binary* ast_binary_new(lex_ctx ctx,
int op,
ast_value *left,
ast_value *right);
ast_value *dest;
ast_value *source;
};
-ast_store* ast_store_new(lex_ctx_t ctx, int op,
+ast_store* ast_store_new(lex_ctx ctx, int op,
ast_value *d, ast_value *s);
void ast_store_delete(ast_store*);
MEM_VECTOR_MAKE(ast_value*, locals);
MEM_VECTOR_MAKE(ast_expression*, exprs);
};
-ast_block* ast_block_new(lex_ctx_t ctx);
+ast_block* ast_block_new(lex_ctx ctx);
void ast_block_delete(ast_block*);
MEM_VECTOR_PROTO(ast_block, ast_value*, locals);
MEM_VECTOR_MAKE(ast_block*, blocks);
};
-ast_function* ast_function_new(lex_ctx_t ctx, const char *name, ast_value *vtype);
+ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype);
void ast_function_delete(ast_function*);
MEM_VECTOR_PROTO(ast_function, ast_block*, blocks);
typedef struct {
float x, y, z;
-} vector_t;
+} vector;
/*
* A shallow copy of a lex_file to remember where which ast node
typedef struct lex_ctx {
const char *file;
size_t line;
-} lex_ctx_t;
+} lex_ctx;
#endif
return true;
}
-bool ir_value_set_vector(ir_value *self, vector_t v)
+bool ir_value_set_vector(ir_value *self, vector v)
{
if (self->vtype != TYPE_VECTOR)
return false;
char *name;
int vtype;
int store;
- lex_ctx_t context;
+ lex_ctx context;
MEM_VECTOR_MAKE(struct ir_instr_s*, reads);
MEM_VECTOR_MAKE(struct ir_instr_s*, writes);
union {
float vfloat;
int vint;
- vector_t vvec;
+ vector vvec;
char *vstring;
struct ir_value_s *vpointer;
} constval;
bool GMQCC_WARN ir_value_set_int(ir_value*, int i);
#endif
bool GMQCC_WARN ir_value_set_string(ir_value*, const char *s);
-bool GMQCC_WARN ir_value_set_vector(ir_value*, vector_t v);
+bool GMQCC_WARN ir_value_set_vector(ir_value*, vector v);
/*bool ir_value_set_pointer_v(ir_value*, ir_value* p); */
/*bool ir_value_set_pointer_i(ir_value*, int i); */
typedef struct ir_instr_s
{
int opcode;
- lex_ctx_t context;
+ lex_ctx context;
ir_value* (_ops[3]);
struct ir_block_s* (bops[2]);
typedef struct ir_block_s
{
char *label;
- lex_ctx_t context;
+ lex_ctx context;
bool final; /* once a jump is added we're done */
MEM_VECTOR_MAKE(ir_instr*, instr);
ir_block* first;
ir_block* last;
- lex_ctx_t context;
+ lex_ctx context;
/* for temp allocation */
size_t run_id;