]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
code to instantiate field-array accessors
authorWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 12 Nov 2012 21:24:11 +0000 (22:24 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 12 Nov 2012 21:24:11 +0000 (22:24 +0100)
parser.c

index 49bb107455aeb9b386b6ec52c92da4aa129cf272..07052f92d38b322f32369e8a78708d23645f1c6d 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3599,6 +3599,35 @@ bool parser_finish(const char *output)
                 }
             }
         }
+        for (i = 0; i < parser->fields_count; ++i) {
+            ast_value *asvalue;
+            asvalue = (ast_value*)(parser->fields[i].var->expression.next);
+
+            if (!ast_istype((ast_expression*)asvalue, ast_value))
+                continue;
+            if (asvalue->expression.vtype != TYPE_ARRAY)
+                continue;
+            if (asvalue->setter) {
+                if (!ast_global_codegen(asvalue->setter, ir, false) ||
+                    !ast_function_codegen(asvalue->setter->constval.vfunc, ir) ||
+                    !ir_function_finalize(asvalue->setter->constval.vfunc->ir_func))
+                {
+                    printf("failed to generate setter for %s\n", parser->globals[i].name);
+                    ir_builder_delete(ir);
+                    return false;
+                }
+            }
+            if (asvalue->getter) {
+                if (!ast_global_codegen(asvalue->getter, ir, false) ||
+                    !ast_function_codegen(asvalue->getter->constval.vfunc, ir) ||
+                    !ir_function_finalize(asvalue->getter->constval.vfunc->ir_func))
+                {
+                    printf("failed to generate getter for %s\n", parser->globals[i].name);
+                    ir_builder_delete(ir);
+                    return false;
+                }
+            }
+        }
         for (i = 0; i < parser->functions_count; ++i) {
             if (!ast_function_codegen(parser->functions[i], ir)) {
                 printf("failed to generate function %s\n", parser->functions[i]->name);