+bool ast_binary_codegen(ast_binary*, ast_function*, bool lvalue, ir_value**);
+
+/* Binstore
+ *
+ * An assignment including a binary expression with the source as left operand.
+ * Eg. a += b; is a binstore { INSTR_STORE, INSTR_ADD, a, b }
+ */
+struct ast_binstore_s
+{
+ ast_expression_common expression;
+
+ int opstore;
+ 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,
+ int op,
+ ast_expression *left,
+ ast_expression *right);
+void ast_binstore_delete(ast_binstore*);
+
+bool ast_binstore_codegen(ast_binstore*, ast_function*, bool lvalue, ir_value**);
+
+/* Unary
+ *
+ * Regular unary expressions: not,neg
+ */
+struct ast_unary_s
+{
+ ast_expression_common expression;
+
+ int op;
+ ast_expression *operand;
+};
+ast_unary* ast_unary_new(lex_ctx ctx,
+ int op,
+ ast_expression *expr);
+void ast_unary_delete(ast_unary*);
+
+bool ast_unary_codegen(ast_unary*, ast_function*, bool lvalue, ir_value**);
+
+/* Return
+ *
+ * Make sure 'return' only happens at the end of a block, otherwise the IR
+ * will refuse to create further instructions.
+ * This should be honored by the parser.
+ */
+struct ast_return_s
+{
+ ast_expression_common expression;
+ ast_expression *operand;
+};
+ast_return* ast_return_new(lex_ctx ctx,
+ ast_expression *expr);
+void ast_return_delete(ast_return*);
+
+bool ast_return_codegen(ast_return*, ast_function*, bool lvalue, ir_value**);
+
+/* Entity-field
+ *
+ * This must do 2 things:
+ * -) Provide a way to fetch an entity field value. (Rvalue)
+ * -) Provide a pointer to an entity field. (Lvalue)
+ * The problem:
+ * In original QC, there's only a STORE via pointer, but
+ * no LOAD via pointer.
+ * So we must know beforehand if we are going to read or assign
+ * the field.
+ * For this we will have to extend the codegen() functions with
+ * a flag saying whether or not we need an L or an R-value.
+ */
+struct ast_entfield_s
+{
+ ast_expression_common expression;
+ /* The entity can come from an expression of course. */
+ ast_expression *entity;
+ /* As can the field, it just must result in a value of TYPE_FIELD */
+ ast_expression *field;
+};
+ast_entfield* ast_entfield_new(lex_ctx ctx, ast_expression *entity, ast_expression *field);
+ast_entfield* ast_entfield_new_force(lex_ctx ctx, ast_expression *entity, ast_expression *field, const ast_expression *outtype);
+void ast_entfield_delete(ast_entfield*);
+
+bool ast_entfield_codegen(ast_entfield*, ast_function*, bool lvalue, ir_value**);
+
+/* Member access:
+ *
+ * For now used for vectors. If we get structs or unions
+ * we can have them handled here as well.
+ */
+struct ast_member_s
+{
+ ast_expression_common expression;
+ ast_expression *owner;
+ unsigned int field;
+ const char *name;
+};
+ast_member* ast_member_new(lex_ctx ctx, ast_expression *owner, unsigned int field, const char *name);
+void ast_member_delete(ast_member*);
+
+bool ast_member_codegen(ast_member*, ast_function*, bool lvalue, ir_value**);
+
+/* Array index access:
+ *
+ * QC forces us to take special action on arrays:
+ * an ast_store on an ast_array_index must not codegen the index,
+ * but call its setter - unless we have an instruction set which supports
+ * what we need.
+ * Any other array index access will be codegened to a call to the getter.
+ * In any case, accessing an element via a compiletime-constant index will
+ * result in quick access to that variable.
+ */
+struct ast_array_index_s
+{
+ ast_expression_common expression;
+ ast_expression *array;
+ ast_expression *index;
+};
+ast_array_index* ast_array_index_new(lex_ctx ctx, ast_expression *array, ast_expression *index);
+void ast_array_index_delete(ast_array_index*);
+
+bool ast_array_index_codegen(ast_array_index*, ast_function*, bool lvalue, ir_value**);
+
+/* Store
+ *
+ * Stores left<-right and returns left.
+ * Specialized binary expression node
+ */
+struct ast_store_s
+{
+ ast_expression_common expression;
+ int op;
+ ast_expression *dest;
+ ast_expression *source;
+};
+ast_store* ast_store_new(lex_ctx ctx, int op,
+ ast_expression *d, ast_expression *s);
+void ast_store_delete(ast_store*);
+
+bool ast_store_codegen(ast_store*, ast_function*, bool lvalue, ir_value**);
+
+/* If
+ *
+ * A general 'if then else' statement, either side can be NULL and will
+ * thus be omitted. It is an error for *both* cases to be NULL at once.
+ *
+ * During its 'codegen' it'll be changing the ast_function's block.
+ *
+ * An if is also an "expression". Its codegen will put NULL into the
+ * output field though. For ternary expressions an ast_ternary will be
+ * added.
+ */
+struct ast_ifthen_s
+{
+ ast_expression_common expression;
+ ast_expression *cond;
+ /* It's all just 'expressions', since an ast_block is one too. */
+ ast_expression *on_true;
+ ast_expression *on_false;
+};
+ast_ifthen* ast_ifthen_new(lex_ctx ctx, ast_expression *cond, ast_expression *ontrue, ast_expression *onfalse);
+void ast_ifthen_delete(ast_ifthen*);
+
+bool ast_ifthen_codegen(ast_ifthen*, ast_function*, bool lvalue, ir_value**);
+
+/* Ternary expressions...
+ *
+ * Contrary to 'if-then-else' nodes, ternary expressions actually
+ * return a value, otherwise they behave the very same way.
+ * The difference in 'codegen' is that it'll return the value of
+ * a PHI node.
+ *
+ * The other difference is that in an ast_ternary, NEITHER side
+ * must be NULL, there's ALWAYS an else branch.
+ *
+ * This is the only ast_node beside ast_value which contains
+ * an ir_value. Theoretically we don't need to remember it though.
+ */
+struct ast_ternary_s
+{
+ ast_expression_common expression;
+ ast_expression *cond;
+ /* It's all just 'expressions', since an ast_block is one too. */
+ ast_expression *on_true;
+ ast_expression *on_false;
+};
+ast_ternary* ast_ternary_new(lex_ctx ctx, ast_expression *cond, ast_expression *ontrue, ast_expression *onfalse);
+void ast_ternary_delete(ast_ternary*);
+
+bool ast_ternary_codegen(ast_ternary*, ast_function*, bool lvalue, ir_value**);
+
+/* A general loop node
+ *
+ * For convenience it contains 4 parts:
+ * -) (ini) = initializing expression
+ * -) (pre) = pre-loop condition
+ * -) (pst) = post-loop condition
+ * -) (inc) = "increment" expression
+ * The following is a psudo-representation of this loop
+ * note that '=>' bears the logical meaning of "implies".
+ * (a => b) equals (!a || b)
+
+{ini};
+while (has_pre => {pre})
+{
+ {body};
+
+continue: // a 'continue' will jump here
+ if (has_pst => {pst})
+ break;
+
+ {inc};
+}
+ */
+struct ast_loop_s
+{
+ ast_expression_common expression;
+ ast_expression *initexpr;
+ ast_expression *precond;
+ ast_expression *postcond;
+ ast_expression *increment;
+ ast_expression *body;
+};
+ast_loop* ast_loop_new(lex_ctx ctx,
+ ast_expression *initexpr,
+ ast_expression *precond,
+ ast_expression *postcond,
+ ast_expression *increment,
+ ast_expression *body);
+void ast_loop_delete(ast_loop*);
+
+bool ast_loop_codegen(ast_loop*, ast_function*, bool lvalue, ir_value**);
+
+/* Break/Continue
+ */
+struct ast_breakcont_s
+{
+ ast_expression_common expression;
+ bool is_continue;
+};
+ast_breakcont* ast_breakcont_new(lex_ctx ctx, bool iscont);
+void ast_breakcont_delete(ast_breakcont*);
+
+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**);
+
+/* Label nodes
+ *
+ * Introduce a label which can be used together with 'goto'
+ */
+struct ast_label_s
+{
+ ast_expression_common expression;
+ const char *name;
+ ir_block *irblock;
+ ast_goto **gotos;
+};
+
+ast_label* ast_label_new(lex_ctx ctx, const char *name);
+void ast_label_delete(ast_label*);
+void ast_label_register_goto(ast_label*, ast_goto*);
+
+bool ast_label_codegen(ast_label*, ast_function*, bool lvalue, ir_value**);
+
+/* GOTO nodes
+ *
+ * Go to a label, the label node is filled in at a later point!
+ */
+struct ast_goto_s
+{
+ ast_expression_common expression;
+ const char *name;
+ ast_label *target;
+ ir_block *irblock_from;
+};