mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-27 21:50:53 +00:00
Allow fieldpointer parameters in functions, allow function fields again
This commit is contained in:
parent
1c81c27cee
commit
ec439d7880
2 changed files with 28 additions and 1 deletions
1
lexer.c
1
lexer.c
|
@ -635,7 +635,6 @@ int lex_do(lex_file *lex)
|
||||||
!strcmp(v, "do") ||
|
!strcmp(v, "do") ||
|
||||||
!strcmp(v, "if") ||
|
!strcmp(v, "if") ||
|
||||||
!strcmp(v, "else") ||
|
!strcmp(v, "else") ||
|
||||||
!strcmp(v, "var") ||
|
|
||||||
!strcmp(v, "local") ||
|
!strcmp(v, "local") ||
|
||||||
!strcmp(v, "return") ||
|
!strcmp(v, "return") ||
|
||||||
!strcmp(v, "const"))
|
!strcmp(v, "const"))
|
||||||
|
|
28
parser.c
28
parser.c
|
@ -292,6 +292,8 @@ static ast_value *parser_parse_type(parser_t *parser, int basetype, bool *isfunc
|
||||||
*isfunc = true;
|
*isfunc = true;
|
||||||
while (true) {
|
while (true) {
|
||||||
ast_value *param;
|
ast_value *param;
|
||||||
|
ast_value *fld;
|
||||||
|
bool isfield = false;
|
||||||
bool dummy;
|
bool dummy;
|
||||||
|
|
||||||
if (!parser_next(parser))
|
if (!parser_next(parser))
|
||||||
|
@ -300,6 +302,14 @@ static ast_value *parser_parse_type(parser_t *parser, int basetype, bool *isfunc
|
||||||
if (parser->tok == ')')
|
if (parser->tok == ')')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (parser->tok == '.') {
|
||||||
|
isfield = true;
|
||||||
|
if (!parser_next(parser)) {
|
||||||
|
parseerror(parser, "expected field parameter type");
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
temptype = parser_token(parser)->constval.t;
|
temptype = parser_token(parser)->constval.t;
|
||||||
if (!parser_next(parser))
|
if (!parser_next(parser))
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
@ -318,6 +328,12 @@ static ast_value *parser_parse_type(parser_t *parser, int basetype, bool *isfunc
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isfield) {
|
||||||
|
fld = ast_value_new(ctx, param->name, TYPE_FIELD);
|
||||||
|
fld->expression.next = (ast_expression*)param;
|
||||||
|
param = fld;
|
||||||
|
}
|
||||||
|
|
||||||
if (!paramlist_t_p_add(¶ms, param)) {
|
if (!paramlist_t_p_add(¶ms, param)) {
|
||||||
parseerror(parser, "Out of memory while parsing typename");
|
parseerror(parser, "Out of memory while parsing typename");
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
@ -2007,6 +2023,18 @@ static bool parser_do(parser_t *parser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isfunc) {
|
||||||
|
ast_value *fval;
|
||||||
|
fval = ast_value_new(ctx, var->name, TYPE_FUNCTION);
|
||||||
|
if (!fval) {
|
||||||
|
ast_value_delete(var);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fval->expression.next = (ast_expression*)var;
|
||||||
|
MEM_VECTOR_MOVE(&var->expression, params, &fval->expression, params);
|
||||||
|
var = fval;
|
||||||
|
}
|
||||||
|
|
||||||
/* turn it into a field */
|
/* turn it into a field */
|
||||||
fld = ast_value_new(ctx, parser_tokval(parser), TYPE_FIELD);
|
fld = ast_value_new(ctx, parser_tokval(parser), TYPE_FIELD);
|
||||||
fld->expression.next = (ast_expression*)var;
|
fld->expression.next = (ast_expression*)var;
|
||||||
|
|
Loading…
Reference in a new issue