mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-24 12:51:04 +00:00
data/vars.qc - when declaring a function, and it had a prototype - use the new parameter names instead of the ones from the prototype, otherwise things get messy
This commit is contained in:
parent
99fe673f0a
commit
588cd5018f
2 changed files with 25 additions and 0 deletions
19
data/vars.qc
Normal file
19
data/vars.qc
Normal file
|
@ -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");
|
||||||
|
};
|
6
parser.c
6
parser.c
|
@ -1838,6 +1838,7 @@ static bool parser_variable(parser_t *parser, ast_block *localblock)
|
||||||
* messing with the parameter-vector etc. earlier
|
* messing with the parameter-vector etc. earlier
|
||||||
*/
|
*/
|
||||||
if (proto) {
|
if (proto) {
|
||||||
|
size_t param;
|
||||||
if (!ast_compare_type((ast_expression*)proto, (ast_expression*)fval)) {
|
if (!ast_compare_type((ast_expression*)proto, (ast_expression*)fval)) {
|
||||||
parseerror(parser, "conflicting types for `%s`, previous declaration was here: %s:%i",
|
parseerror(parser, "conflicting types for `%s`, previous declaration was here: %s:%i",
|
||||||
proto->name,
|
proto->name,
|
||||||
|
@ -1846,6 +1847,11 @@ static bool parser_variable(parser_t *parser, ast_block *localblock)
|
||||||
ast_value_delete(fval);
|
ast_value_delete(fval);
|
||||||
return false;
|
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_function_delete(func);
|
||||||
ast_value_delete(fval);
|
ast_value_delete(fval);
|
||||||
fval = proto;
|
fval = proto;
|
||||||
|
|
Loading…
Reference in a new issue