From: Wolfgang (Blub) Bumiller Date: Mon, 12 Nov 2012 22:35:47 +0000 (+0100) Subject: allowing inexing of array-fields X-Git-Tag: 0.1~19^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d60a76abd178d04ab3aba684c7b56cf8fac67153;p=xonotic%2Fgmqcc.git allowing inexing of array-fields --- diff --git a/ast.c b/ast.c index bfdcf62..aa65da2 100644 --- a/ast.c +++ b/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; } diff --git a/parser.c b/parser.c index b81d06c..250a75a 100644 --- a/parser.c +++ b/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;