]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
data/vars.qc - when declaring a function, and it had a prototype - use the new parame...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 18 Aug 2012 18:16:51 +0000 (20:16 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 18 Aug 2012 18:16:51 +0000 (20:16 +0200)
data/vars.qc [new file with mode: 0644]
parser.c

diff --git a/data/vars.qc b/data/vars.qc
new file mode 100644 (file)
index 0000000..7438a10
--- /dev/null
@@ -0,0 +1,19 @@
+/* this is the WIP test for the parser...
+ * constantly adding stuff here to see if things break
+ */
+void(string)        print  = #1;
+void(string,string) print2 = #1;
+void(string,string,string) print3 = #1;
+string(float)       ftos   = #2;
+entity()            spawn  = #3;
+void(entity)        kill   = #4;
+
+float(vector different_name, vector b) dot;
+
+float(vector a, vector b) dot = {
+    return a * b;
+};
+
+void() main = {
+    print3("should be 1: ", ftos(dot('1 1 0', '1 0 0')), "\n");
+};
index a2b3f060eed51e5edc7bbd7f1876b2fa7fd6f686..7ef5c9b43085efd410c51d17fed63cd62df5e50d 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1838,6 +1838,7 @@ static bool parser_variable(parser_t *parser, ast_block *localblock)
              * messing with the parameter-vector etc. earlier
              */
             if (proto) {
+                size_t param;
                 if (!ast_compare_type((ast_expression*)proto, (ast_expression*)fval)) {
                     parseerror(parser, "conflicting types for `%s`, previous declaration was here: %s:%i",
                                proto->name,
@@ -1846,6 +1847,11 @@ static bool parser_variable(parser_t *parser, ast_block *localblock)
                     ast_value_delete(fval);
                     return false;
                 }
+                /* copy over the parameter names */
+                for (param = 0; param < fval->expression.params_count; ++param)
+                    ast_value_set_name(proto->expression.params[param], fval->expression.params[param]->name);
+
+                /* now ditch the rest of the new data */
                 ast_function_delete(func);
                 ast_value_delete(fval);
                 fval = proto;