mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-21 02:40:56 +00:00
multiple dots to start a field type, ie ..float for a fieldpointer field
This commit is contained in:
parent
b5d6f454a4
commit
2884556fe3
3 changed files with 23 additions and 0 deletions
19
parser.c
19
parser.c
|
@ -3198,6 +3198,7 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_va
|
|||
const char *name = NULL;
|
||||
bool isfield = false;
|
||||
bool wasarray = false;
|
||||
size_t morefields = 0;
|
||||
|
||||
ctx = parser_ctx(parser);
|
||||
|
||||
|
@ -3217,12 +3218,30 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_va
|
|||
}
|
||||
}
|
||||
|
||||
/* Further dots are handled seperately because they won't be part of the
|
||||
* basetype
|
||||
*/
|
||||
while (parser->tok == '.') {
|
||||
++morefields;
|
||||
if (!parser_next(parser)) {
|
||||
parseerror(parser, "expected typename for field definition");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* generate the basic type value */
|
||||
if (cached_typedef) {
|
||||
var = ast_value_copy(cached_typedef);
|
||||
ast_value_set_name(var, "<type(from_def)>");
|
||||
} else
|
||||
var = ast_value_new(ctx, "<type>", parser_token(parser)->constval.t);
|
||||
|
||||
for (; morefields; --morefields) {
|
||||
tmp = ast_value_new(ctx, "<.type>", TYPE_FIELD);
|
||||
tmp->expression.next = (ast_expression*)var;
|
||||
var = tmp;
|
||||
}
|
||||
|
||||
/* do not yet turn into a field - remember:
|
||||
* .void() foo; is a field too
|
||||
* .void()() foo; is a function
|
||||
|
|
|
@ -3,6 +3,7 @@ entity() spawn = #3;
|
|||
|
||||
.string a;
|
||||
.string b;
|
||||
..string ps;
|
||||
|
||||
void(entity e, .string s) callout = {
|
||||
print(e.s, "\n");
|
||||
|
@ -14,4 +15,6 @@ void() main = {
|
|||
e.a = "foo";
|
||||
e.b = "bar";
|
||||
callout(e, b);
|
||||
e.ps = a;
|
||||
print(e.(e.ps), "\n");
|
||||
};
|
||||
|
|
|
@ -6,3 +6,4 @@ E: $null
|
|||
F: field paramaters fail
|
||||
S: field paramaters work
|
||||
M: bar
|
||||
M: foo
|
||||
|
|
Loading…
Reference in a new issue