]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
Introduce an ast_store rather than splitting ast_binary
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index c52a8644556ec58312c8512fc647c153f6c19e31..595dea16f2d4327f7f0ae8397a6d2c13937fded8 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -111,7 +111,7 @@ ast_binary* ast_binary_new(lex_ctx_t ctx, int op,
                            ast_value* left, ast_value* right)
 {
     ast_instantiate(ast_binary, ctx, ast_binary_delete);
-    ast_expression_init((ast_expression*)self, NULL); /* FIXME */
+    ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_binary_codegen);
 
     self->op = op;
     self->left = left;
@@ -125,6 +125,24 @@ void ast_binary_delete(ast_binary *self)
     mem_d(self);
 }
 
+ast_store* ast_store_new(lex_ctx_t ctx, int op,
+                         ast_value *dest, ast_value *source)
+{
+    ast_instantiate(ast_store, ctx, ast_store_delete);
+    ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_store_codegen);
+
+    self->op = op;
+    self->dest = dest;
+    self->source = source;
+
+    return self;
+}
+
+void ast_store_delete(ast_store *self)
+{
+    mem_d(self);
+}
+
 ast_block* ast_block_new(lex_ctx_t ctx)
 {
     ast_instantiate(ast_block, ctx, ast_block_delete);
@@ -181,4 +199,23 @@ void ast_function_delete(ast_function *self)
 /* AST codegen aprt
  */
 
-/* TODO */
+/* Some dummies so it compiles... */
+bool ast_value_codegen(ast_value *self, ast_function *func, ir_value **out)
+{
+    return false;
+}
+
+bool ast_block_codegen(ast_block *self, ast_function *func, ir_value **out)
+{
+    return false;
+}
+
+bool ast_store_codegen(ast_store *self, ast_function *func, ir_value **out)
+{
+    return false;
+}
+
+bool ast_binary_codegen(ast_binary *self, ast_function *func, ir_value **out)
+{
+    return false;
+}