typedef struct ast_goto_s ast_goto;
enum {
- TYPE_ast_node,
- TYPE_ast_expression,
- TYPE_ast_value,
- TYPE_ast_function,
- TYPE_ast_block,
- TYPE_ast_binary,
- TYPE_ast_store,
- TYPE_ast_binstore,
- TYPE_ast_entfield,
- TYPE_ast_ifthen,
- TYPE_ast_ternary,
- TYPE_ast_loop,
- TYPE_ast_call,
- TYPE_ast_unary,
- TYPE_ast_return,
- TYPE_ast_member,
- TYPE_ast_array_index,
- TYPE_ast_breakcont,
- TYPE_ast_switch,
- TYPE_ast_label,
- TYPE_ast_goto
+ TYPE_ast_node, /* 0 */
+ TYPE_ast_expression, /* 1 */
+ TYPE_ast_value, /* 2 */
+ TYPE_ast_function, /* 3 */
+ TYPE_ast_block, /* 4 */
+ TYPE_ast_binary, /* 5 */
+ TYPE_ast_store, /* 6 */
+ TYPE_ast_binstore, /* 7 */
+ TYPE_ast_entfield, /* 8 */
+ TYPE_ast_ifthen, /* 9 */
+ TYPE_ast_ternary, /* 10 */
+ TYPE_ast_loop, /* 11 */
+ TYPE_ast_call, /* 12 */
+ TYPE_ast_unary, /* 13 */
+ TYPE_ast_return, /* 14 */
+ TYPE_ast_member, /* 15 */
+ TYPE_ast_array_index, /* 16 */
+ TYPE_ast_breakcont, /* 17 */
+ TYPE_ast_switch, /* 18 */
+ TYPE_ast_label, /* 19 */
+ TYPE_ast_goto /* 20 */
};
#define ast_istype(x, t) ( ((ast_node_common*)x)->nodetype == (TYPE_##t) )
/* arrays get a member-count */
size_t count;
ast_value* *params;
- bool variadic;
+ uint32_t flags;
/* The codegen functions should store their output values
* so we can call it multiple times without re-evaluating.
* Store lvalue and rvalue seperately though. So that
ir_value *outl;
ir_value *outr;
} ast_expression_common;
+#define AST_FLAG_VARIADIC (1<<0)
+#define AST_FLAG_NORETURN (1<<1)
/* Value
*
ast_value *next;
*/
- bool constant;
+ bool cvq; /* const/var qualifier */
+ bool isfield; /* this declares a field */
bool hasvalue;
union {
double vfloat;
const char *vstring;
int ventity;
ast_function *vfunc;
+ ast_value *vfield;
} constval;
/* usecount for the parser */
int opbin;
ast_expression *dest;
ast_expression *source;
+ /* for &~= which uses the destination in a binary in source we can use this */
+ bool keep_dest;
};
ast_binstore* ast_binstore_new(lex_ctx ctx,
int storeop,
ast_goto* ast_goto_new(lex_ctx ctx, const char *name);
void ast_goto_delete(ast_goto*);
-void ast_goto_setlabel(ast_goto*, ast_label*);
+void ast_goto_set_label(ast_goto*, ast_label*);
bool ast_goto_codegen(ast_goto*, ast_function*, bool lvalue, ir_value**);
bool ast_block_codegen(ast_block*, ast_function*, bool lvalue, ir_value**);
void ast_block_collect(ast_block*, ast_expression*);
-void ast_block_add_expr(ast_block*, ast_expression*);
+bool GMQCC_WARN ast_block_add_expr(ast_block*, ast_expression*);
/* Function
*
const char* ast_function_label(ast_function*, const char *prefix);
bool ast_function_codegen(ast_function *self, ir_builder *builder);
+bool ast_generate_accessors(ast_value *asvalue, ir_builder *ir);
/* Expression union
*/