]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
ast_binary_new to initialize codegen function ptr, codegen proto for store and binary...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 26 Apr 2012 08:38:00 +0000 (10:38 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 26 Apr 2012 08:38:00 +0000 (10:38 +0200)
ast.c
ast.h

diff --git a/ast.c b/ast.c
index 5b4b1de228c95244430d9a65570b2f9e6e6553c8..9d55fed0e9f902ff5a3a3ea2399bb4c119766b7d 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -111,7 +111,36 @@ 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 */
+    switch (op) {
+    case INSTR_STORE_F:
+    case INSTR_STORE_V:
+    case INSTR_STORE_S:
+    case INSTR_STORE_ENT:
+    case INSTR_STORE_FLD:
+    case INSTR_STORE_FNC:
+    case INSTR_STOREP_F:
+    case INSTR_STOREP_V:
+    case INSTR_STOREP_S:
+    case INSTR_STOREP_ENT:
+    case INSTR_STOREP_FLD:
+    case INSTR_STOREP_FNC:
+#if 0
+    case INSTR_STORE_I:
+    case INSTR_STORE_IF:
+    case INSTR_STORE_FI:
+    case INSTR_STOREP_I:
+    case INSTR_STOREP_IF:
+    case INSTR_STOREP_FI:
+    case INSTR_STORE_P:
+    case INSTR_STOREP_P:
+    case INSTR_STOREP_C:
+#endif
+        ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_bin_store_codegen);
+        break;
+    default:
+        ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_binary_codegen);
+        break;
+    }
 
     self->op = op;
     self->left = left;
@@ -191,3 +220,13 @@ bool ast_block_codegen(ast_block *self, ast_function *func, ir_value **out)
 {
     return false;
 }
+
+bool ast_bin_store_codegen(ast_binary *self, ast_function *func, ir_value **out)
+{
+    return false;
+}
+
+bool ast_binary_codegen(ast_binary *self, ast_function *func, ir_value **out)
+{
+    return false;
+}
diff --git a/ast.h b/ast.h
index 4cbd453411e709d007f59c04cd18e2113c7f407f..041bff7959749b747ca125838bd54f9783474b25 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -122,15 +122,13 @@ ast_binary* ast_binary_new(lex_ctx_t  ctx,
                            ast_value *right);
 void ast_binary_delete(ast_binary*);
 
-/* hmm, seperate functions? */
-bool ast_bin_add_codegen(ast_binary*, ir_function*, ir_value**);
-/* ... */
-
+/* hmm, seperate functions?
+bool ast_block_codegen(ast_block*, ast_function*, ir_value**);
+ */
 /* maybe for this one */
-bool ast_bin_store_codegen(ast_binary*, ir_function*, ir_value**);
+bool ast_bin_store_codegen(ast_binary*, ast_function*, ir_value**);
 
-/* could decide what to use */
-bool ast_binary_codegen(ast_binary*, ir_function*, ir_value**);
+bool ast_binary_codegen(ast_binary*, ast_function*, ir_value**);
 
 /* Blocks
  *