Robert Shearman : widl: Do constant folding for the sizeof operator
on simple types.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jan 31 11:23:29 CST 2006
Module: wine
Branch: refs/heads/master
Commit: 513996fde4a410df154e042166950a391d87c514
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=513996fde4a410df154e042166950a391d87c514
Author: Robert Shearman <rob at codeweavers.com>
Date: Tue Jan 31 18:06:25 2006 +0100
widl: Do constant folding for the sizeof operator on simple types.
---
tools/widl/parser.y | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 49532a0..15f1367 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -877,6 +877,35 @@ static expr_t *make_exprt(enum expr_type
e->is_const = FALSE;
INIT_LINK(e);
/* check for cast of constant expression */
+ if (type == EXPR_SIZEOF) {
+ switch (tref->ref->type) {
+ case RPC_FC_BYTE:
+ case RPC_FC_CHAR:
+ case RPC_FC_SMALL:
+ case RPC_FC_USMALL:
+ e->is_const = TRUE;
+ e->cval = 1;
+ break;
+ case RPC_FC_WCHAR:
+ case RPC_FC_USHORT:
+ case RPC_FC_SHORT:
+ e->is_const = TRUE;
+ e->cval = 2;
+ break;
+ case RPC_FC_LONG:
+ case RPC_FC_ULONG:
+ case RPC_FC_FLOAT:
+ case RPC_FC_ERROR_STATUS_T:
+ e->is_const = TRUE;
+ e->cval = 4;
+ break;
+ case RPC_FC_HYPER:
+ case RPC_FC_DOUBLE:
+ e->is_const = TRUE;
+ e->cval = 8;
+ break;
+ }
+ }
if (type == EXPR_CAST && expr->is_const) {
e->is_const = TRUE;
e->cval = expr->cval;
More information about the wine-cvs
mailing list