widl: Add support for arrays in expressions.
This commit is contained in:
parent
03d5017416
commit
d27c7601e5
|
@ -559,6 +559,14 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
|
|||
fprintf(h, "&");
|
||||
write_expr(h, e->ref, 1);
|
||||
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);
|
|||
%left '-' '+'
|
||||
%left '*' '/'
|
||||
%left SHL SHR
|
||||
%left '.' MEMBERPTR
|
||||
%left '.' MEMBERPTR '[' ']'
|
||||
%right '~'
|
||||
%right CAST
|
||||
%right PPTR
|
||||
|
@ -644,6 +644,7 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
|
|||
| expr '.' expr { $$ = make_expr2(EXPR_MEMBER, $1, $3); }
|
||||
| '(' type ')' expr %prec CAST { $$ = make_exprt(EXPR_CAST, $2, $4); }
|
||||
| tSIZEOF '(' type ')' { $$ = make_exprt(EXPR_SIZEOF, $3, NULL); }
|
||||
| expr '[' expr ']' { $$ = make_expr2(EXPR_ARRAY, $1, $3); }
|
||||
| '(' expr ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
|
|
|
@ -358,6 +358,7 @@ static int compare_expr(const expr_t *a, const expr_t *b)
|
|||
case EXPR_SHR:
|
||||
case EXPR_MEMBERPTR:
|
||||
case EXPR_MEMBER:
|
||||
case EXPR_ARRAY:
|
||||
ret = compare_expr(a->ref, b->ref);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
@ -3186,6 +3187,14 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
|
|||
fprintf(h, "&");
|
||||
write_struct_expr(h, e->ref, 1, fields, structvar);
|
||||
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
|
|||
EXPR_ADDRESSOF,
|
||||
EXPR_MEMBERPTR,
|
||||
EXPR_MEMBER,
|
||||
EXPR_ARRAY,
|
||||
};
|
||||
|
||||
enum type_kind
|
||||
|
|
Loading…
Reference in New Issue