]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
support for ast_entfield nodes with specific output types, fixing array-field instant...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 12 Nov 2012 21:39:43 +0000 (22:39 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 12 Nov 2012 21:39:43 +0000 (22:39 +0100)
ast.c
ast.h
parser.c

diff --git a/ast.c b/ast.c
index da51a46a8d74ac28d5ce51f87942963cf26ea8d7..bfdcf621c80eb4a8d1c2a77bd8109589c15e4140 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -483,17 +483,17 @@ void ast_return_delete(ast_return *self)
 
 ast_entfield* ast_entfield_new(lex_ctx ctx, ast_expression *entity, ast_expression *field)
 {
-    const ast_expression *outtype;
-
-    ast_instantiate(ast_entfield, ctx, ast_entfield_delete);
-
     if (field->expression.vtype != TYPE_FIELD) {
         asterror(ctx, "ast_entfield_new with expression not of type field");
-        mem_d(self);
         return NULL;
     }
+    return ast_entfield_new_force(ctx, entity, field, field->expression.next);
+}
+
+ast_entfield* ast_entfield_new_force(lex_ctx ctx, ast_expression *entity, ast_expression *field, const ast_expression *outtype)
+{
+    ast_instantiate(ast_entfield, ctx, ast_entfield_delete);
 
-    outtype = field->expression.next;
     if (!outtype) {
         mem_d(self);
         /* Error: field has no type... */
diff --git a/ast.h b/ast.h
index b46aee16b6063d348926fadb887617885a9fd596..f2f05d6409d5a0f9a42fd240ddef2c0398a6ff1c 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -291,6 +291,7 @@ struct ast_entfield_s
     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**);
index de0bc52023a18a1e034e8c050ef521f5fe1f75b5..0fff1d95db5a60f36e1c04f386723e6c612c0ef3 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2353,7 +2353,10 @@ static ast_expression *array_field_setter_node(
         if (!subscript)
             return NULL;
 
-        entfield = ast_entfield_new(ctx, (ast_expression*)entity, (ast_expression*)subscript);
+        entfield = ast_entfield_new_force(ctx,
+                                          (ast_expression*)entity,
+                                          (ast_expression*)subscript,
+                                          (ast_expression*)subscript);
         if (!entfield) {
             ast_delete(subscript);
             return NULL;
@@ -3740,7 +3743,7 @@ bool parser_finish(const char *output)
                     !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);
+                    printf("failed to generate setter for %s\n", parser->fields[i].name);
                     ir_builder_delete(ir);
                     return false;
                 }
@@ -3750,7 +3753,7 @@ bool parser_finish(const char *output)
                     !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);
+                    printf("failed to generate getter for %s\n", parser->fields[i].name);
                     ir_builder_delete(ir);
                     return false;
                 }