mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-03-23 11:11:22 +00:00
allowing inexing of array-fields
This commit is contained in:
parent
dbdcdb059e
commit
d60a76abd1
2 changed files with 13 additions and 1 deletions
9
ast.c
9
ast.c
|
@ -588,6 +588,15 @@ ast_array_index* ast_array_index_new(lex_ctx ctx, ast_expression *array, ast_exp
|
|||
ast_array_index_delete(self);
|
||||
return NULL;
|
||||
}
|
||||
if (array->expression.vtype == TYPE_FIELD && outtype->expression.vtype == TYPE_ARRAY) {
|
||||
if (self->expression.vtype != TYPE_ARRAY) {
|
||||
asterror(ast_ctx(self), "array_index node on type");
|
||||
ast_array_index_delete(self);
|
||||
return NULL;
|
||||
}
|
||||
self->array = outtype;
|
||||
self->expression.vtype = TYPE_FIELD;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
5
parser.c
5
parser.c
|
@ -464,7 +464,10 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
|||
break;
|
||||
|
||||
case opid1('['):
|
||||
if (exprs[0]->expression.vtype != TYPE_ARRAY) {
|
||||
if (exprs[0]->expression.vtype != TYPE_ARRAY &&
|
||||
!(exprs[0]->expression.vtype == TYPE_FIELD &&
|
||||
exprs[0]->expression.next->expression.vtype == TYPE_ARRAY))
|
||||
{
|
||||
ast_type_to_string(exprs[0], ty1, sizeof(ty1));
|
||||
parseerror(parser, "cannot index value of type %s", ty1);
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue