Commit d27c7601 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Add support for arrays in expressions.

parent 03d50174
...@@ -559,6 +559,14 @@ void write_expr(FILE *h, const expr_t *e, int brackets) ...@@ -559,6 +559,14 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
fprintf(h, "&"); fprintf(h, "&");
write_expr(h, e->ref, 1); write_expr(h, e->ref, 1);
break; break;
case EXPR_ARRAY:
if (brackets) fprintf(h, "(");
write_expr(h, e->ref, 1);
fprintf(h, "[");
write_expr(h, e->u.ext, 1);
fprintf(h, "]");
if (brackets) fprintf(h, ")");
break;
} }
} }
......
...@@ -295,7 +295,7 @@ static void add_explicit_handle_if_necessary(func_t *func); ...@@ -295,7 +295,7 @@ static void add_explicit_handle_if_necessary(func_t *func);
%left '-' '+' %left '-' '+'
%left '*' '/' %left '*' '/'
%left SHL SHR %left SHL SHR
%left '.' MEMBERPTR %left '.' MEMBERPTR '[' ']'
%right '~' %right '~'
%right CAST %right CAST
%right PPTR %right PPTR
...@@ -644,6 +644,7 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); } ...@@ -644,6 +644,7 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
| expr '.' expr { $$ = make_expr2(EXPR_MEMBER, $1, $3); } | expr '.' expr { $$ = make_expr2(EXPR_MEMBER, $1, $3); }
| '(' type ')' expr %prec CAST { $$ = make_exprt(EXPR_CAST, $2, $4); } | '(' type ')' expr %prec CAST { $$ = make_exprt(EXPR_CAST, $2, $4); }
| tSIZEOF '(' type ')' { $$ = make_exprt(EXPR_SIZEOF, $3, NULL); } | tSIZEOF '(' type ')' { $$ = make_exprt(EXPR_SIZEOF, $3, NULL); }
| expr '[' expr ']' { $$ = make_expr2(EXPR_ARRAY, $1, $3); }
| '(' expr ')' { $$ = $2; } | '(' expr ')' { $$ = $2; }
; ;
......
...@@ -358,6 +358,7 @@ static int compare_expr(const expr_t *a, const expr_t *b) ...@@ -358,6 +358,7 @@ static int compare_expr(const expr_t *a, const expr_t *b)
case EXPR_SHR: case EXPR_SHR:
case EXPR_MEMBERPTR: case EXPR_MEMBERPTR:
case EXPR_MEMBER: case EXPR_MEMBER:
case EXPR_ARRAY:
ret = compare_expr(a->ref, b->ref); ret = compare_expr(a->ref, b->ref);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -3186,6 +3187,14 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets, ...@@ -3186,6 +3187,14 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
fprintf(h, "&"); fprintf(h, "&");
write_struct_expr(h, e->ref, 1, fields, structvar); write_struct_expr(h, e->ref, 1, fields, structvar);
break; break;
case EXPR_ARRAY:
if (brackets) fprintf(h, "(");
write_struct_expr(h, e->ref, 1, fields, structvar);
fprintf(h, "[");
write_struct_expr(h, e->u.ext, 1, fields, structvar);
fprintf(h, "]");
if (brackets) fprintf(h, ")");
break;
} }
} }
......
...@@ -163,6 +163,7 @@ enum expr_type ...@@ -163,6 +163,7 @@ enum expr_type
EXPR_ADDRESSOF, EXPR_ADDRESSOF,
EXPR_MEMBERPTR, EXPR_MEMBERPTR,
EXPR_MEMBER, EXPR_MEMBER,
EXPR_ARRAY,
}; };
enum type_kind enum type_kind
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment