From 95ac84e20bb552498bdb0dbeffea539fbfb583a0 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Tue, 22 Apr 2008 11:36:00 +0100 Subject: [PATCH] widl: Remove EXPR_MEMBERPTR and implement it using EXPR_PPTR and EXPR_MEMBER instead. --- tools/widl/header.c | 19 +++++++++++++++---- tools/widl/parser.y | 4 ++-- tools/widl/typegen.c | 19 +++++++++++++++---- tools/widl/widltypes.h | 1 - 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/tools/widl/header.c b/tools/widl/header.c index ce291da5a15..dea766912a0 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -539,8 +539,6 @@ void write_expr(FILE *h, const expr_t *e, int brackets) case EXPR_SUB: case EXPR_AND: case EXPR_OR: - case EXPR_MEMBERPTR: - case EXPR_MEMBER: case EXPR_LOGOR: case EXPR_LOGAND: case EXPR_XOR: @@ -562,8 +560,6 @@ void write_expr(FILE *h, const expr_t *e, int brackets) case EXPR_SUB: fprintf(h, " - "); break; case EXPR_AND: fprintf(h, " & "); break; case EXPR_OR: fprintf(h, " | "); break; - case EXPR_MEMBERPTR: fprintf(h, "->"); break; - case EXPR_MEMBER: fprintf(h, "."); break; case EXPR_LOGOR: fprintf(h, " || "); break; case EXPR_LOGAND: fprintf(h, " && "); break; case EXPR_XOR: fprintf(h, " ^ "); break; @@ -578,6 +574,21 @@ void write_expr(FILE *h, const expr_t *e, int brackets) write_expr(h, e->u.ext, 1); if (brackets) fprintf(h, ")"); break; + case EXPR_MEMBER: + if (brackets) fprintf(h, "("); + if (e->ref->type == EXPR_PPTR) + { + write_expr(h, e->ref->ref, 1); + fprintf(h, "->"); + } + else + { + write_expr(h, e->ref, 1); + fprintf(h, "."); + } + write_expr(h, e->u.ext, 1); + if (brackets) fprintf(h, ")"); + break; case EXPR_COND: if (brackets) fprintf(h, "("); write_expr(h, e->ref, 1); diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 54f98043f23..a7654156996 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -657,8 +657,8 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); } | '-' expr %prec NEG { $$ = make_expr1(EXPR_NEG, $2); } | '&' expr %prec ADDRESSOF { $$ = make_expr1(EXPR_ADDRESSOF, $2); } | '*' expr %prec PPTR { $$ = make_expr1(EXPR_PPTR, $2); } - | expr MEMBERPTR expr { $$ = make_expr2(EXPR_MEMBERPTR, $1, $3); } - | expr '.' expr { $$ = make_expr2(EXPR_MEMBER, $1, $3); } + | expr MEMBERPTR aIDENTIFIER { $$ = make_expr2(EXPR_MEMBER, make_expr1(EXPR_PPTR, $1), make_exprs(EXPR_IDENTIFIER, $3)); } + | expr '.' aIDENTIFIER { $$ = make_expr2(EXPR_MEMBER, $1, make_exprs(EXPR_IDENTIFIER, $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); } diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 8c8722e9767..d725920c857 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -357,7 +357,6 @@ static int compare_expr(const expr_t *a, const expr_t *b) case EXPR_DIV: case EXPR_SHL: case EXPR_SHR: - case EXPR_MEMBERPTR: case EXPR_MEMBER: case EXPR_ARRAY: case EXPR_LOGOR: @@ -3179,8 +3178,6 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets, case EXPR_SUB: case EXPR_AND: case EXPR_OR: - case EXPR_MEMBERPTR: - case EXPR_MEMBER: case EXPR_LOGOR: case EXPR_LOGAND: case EXPR_XOR: @@ -3202,7 +3199,6 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets, case EXPR_SUB: fprintf(h, " - "); break; case EXPR_AND: fprintf(h, " & "); break; case EXPR_OR: fprintf(h, " | "); break; - case EXPR_MEMBERPTR: fprintf(h, "->"); break; case EXPR_MEMBER: fprintf(h, "."); break; case EXPR_LOGOR: fprintf(h, " || "); break; case EXPR_LOGAND: fprintf(h, " && "); break; @@ -3218,6 +3214,21 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets, write_struct_expr(h, e->u.ext, 1, fields, structvar); if (brackets) fprintf(h, ")"); break; + case EXPR_MEMBER: + if (brackets) fprintf(h, "("); + if (e->ref->type == EXPR_PPTR) + { + write_expr(h, e->ref->ref, 1); + fprintf(h, "->"); + } + else + { + write_expr(h, e->ref, 1); + fprintf(h, "."); + } + write_expr(h, e->u.ext, 1); + if (brackets) fprintf(h, ")"); + break; case EXPR_COND: if (brackets) fprintf(h, "("); write_struct_expr(h, e->ref, 1, fields, structvar); diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 35f31d94b45..37a883a9a71 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -161,7 +161,6 @@ enum expr_type EXPR_COND, EXPR_TRUEFALSE, EXPR_ADDRESSOF, - EXPR_MEMBERPTR, EXPR_MEMBER, EXPR_ARRAY, EXPR_MOD,