]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
remove a redundant ir_function member
[xonotic/gmqcc.git] / parser.c
index ade4cc65bc0da0970c061d6758bc394ce223bce7..25c9c74c9fd18c7bc45bd3e6da80d00f7874b79f 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -20,6 +20,9 @@ typedef struct {
     ast_value    **imm_string;
     ast_value    **imm_vector;
 
+    /* must be deleted first, they reference immediates and values */
+    ast_value    **accessors;
+
     ast_value *imm_float_zero;
     ast_value *imm_vector_zero;
 
@@ -2422,6 +2425,8 @@ static bool parser_create_array_accessor(parser_t *parser, ast_value *array, con
     vec_push(func->blocks, body);
     *out = fval;
 
+    vec_push(parser->accessors, fval);
+
     return true;
 }
 
@@ -2632,8 +2637,8 @@ static ast_value *parse_parameter_list(parser_t *parser, ast_value *var)
     }
 
     /* sanity check */
-    if (vec_size(params) > 8)
-        parseerror(parser, "more than 8 parameters are currently not supported");
+    if (vec_size(params) > 8 && opts_standard == COMPILER_QCC)
+        (void)!parsewarning(parser, WARN_EXTENSIONS, "more than 8 parameters are not supported by this standard");
 
     /* parse-out */
     if (!parser_next(parser)) {
@@ -3414,7 +3419,17 @@ bool parser_compile_file(const char *filename)
 {
     parser->lex = lex_open(filename);
     if (!parser->lex) {
-        con_out("failed to open file \"%s\"\n", filename);
+        con_err("failed to open file \"%s\"\n", filename);
+        return false;
+    }
+    return parser_compile();
+}
+
+bool parser_compile_string_len(const char *name, const char *str, size_t len)
+{
+    parser->lex = lex_open_string(str, len, name);
+    if (!parser->lex) {
+        con_err("failed to create lexer for string \"%s\"\n", name);
         return false;
     }
     return parser_compile();
@@ -3424,7 +3439,7 @@ bool parser_compile_string(const char *name, const char *str)
 {
     parser->lex = lex_open_string(str, strlen(str), name);
     if (!parser->lex) {
-        con_out("failed to create lexer for string \"%s\"\n", name);
+        con_err("failed to create lexer for string \"%s\"\n", name);
         return false;
     }
     return parser_compile();
@@ -3433,6 +3448,11 @@ bool parser_compile_string(const char *name, const char *str)
 void parser_cleanup()
 {
     size_t i;
+    for (i = 0; i < vec_size(parser->accessors); ++i) {
+        ast_delete(parser->accessors[i]->constval.vfunc);
+        parser->accessors[i]->constval.vfunc = NULL;
+        ast_delete(parser->accessors[i]);
+    }
     for (i = 0; i < vec_size(parser->functions); ++i) {
         ast_delete(parser->functions[i]);
     }
@@ -3453,6 +3473,7 @@ void parser_cleanup()
         ast_delete(parser->globals[i].var);
         mem_d(parser->globals[i].name);
     }
+    vec_free(parser->accessors);
     vec_free(parser->functions);
     vec_free(parser->imm_vector);
     vec_free(parser->imm_string);