typedef struct ast_member_s ast_member;
typedef struct ast_array_index_s ast_array_index;
typedef struct ast_breakcont_s ast_breakcont;
+typedef struct ast_switch_s ast_switch;
enum {
TYPE_ast_node,
TYPE_ast_return,
TYPE_ast_member,
TYPE_ast_array_index,
- TYPE_ast_breakcont
+ TYPE_ast_breakcont,
+ TYPE_ast_switch
};
#define ast_istype(x, t) ( ((ast_node_common*)x)->nodetype == (TYPE_##t) )
bool ast_breakcont_codegen(ast_breakcont*, ast_function*, bool lvalue, ir_value**);
+/* Switch Statements
+ *
+ * A few notes about this: with the original QCVM, no real optimization
+ * is possible. The SWITCH instruction set isn't really helping a lot, since
+ * it only collapes the EQ and IF instructions into one.
+ * Note: Declaring local variables inside caseblocks is normal.
+ * Since we don't have to deal with a stack there's no unnatural behaviour to
+ * be expected from it.
+ * TODO: Ticket #20
+ */
+typedef struct {
+ ast_expression *value; /* #20 will replace this */
+ ast_expression *code;
+} ast_switch_case;
+struct ast_switch_s
+{
+ ast_expression_common expression;
+
+ ast_expression *operand;
+ ast_switch_case *cases;
+};
+
+ast_switch* ast_switch_new(lex_ctx ctx, ast_expression *op);
+void ast_switch_delete(ast_switch*);
+
+bool ast_switch_codegen(ast_switch*, ast_function*, bool lvalue, ir_value**);
+
/* CALL node
*
* Contains an ast_expression as target, rather than an ast_function/value.