Commit f6278456 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

widl: Add support for the builtin constants "TRUE" and "FALSE".

parent 5f453db5
......@@ -410,6 +410,12 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
case EXPR_HEXNUM:
fprintf(h, "0x%lx", e->u.lval);
break;
case EXPR_TRUEFALSE:
if (e->u.lval == 0)
fprintf(h, "FALSE");
else
fprintf(h, "TRUE");
break;
case EXPR_IDENTIFIER:
fprintf(h, "%s", e->u.sval);
break;
......
......@@ -172,6 +172,8 @@ static struct keyword {
int token;
int val;
} keywords[] = {
{"FALSE", tFALSE},
{"TRUE", tTRUE},
{"__cdecl", tCDECL},
{"__int64", tINT64},
{"__stdcall", tSTDCALL},
......@@ -307,7 +309,7 @@ static struct keyword {
{"version", tVERSION},
{"void", tVOID},
{"wchar_t", tWCHAR},
{"wire_marshal", tWIREMARSHAL}
{"wire_marshal", tWIREMARSHAL},
};
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
#define KWP(p) ((const struct keyword *)(p))
......
......@@ -141,6 +141,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tENDPOINT
%token tENTRY tENUM tERRORSTATUST
%token tEXPLICITHANDLE tEXTERN
%token tFALSE
%token tFLOAT
%token tHANDLE
%token tHANDLET
......@@ -188,6 +189,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
%token tSTRING tSTRUCT
%token tSWITCH tSWITCHIS tSWITCHTYPE
%token tTRANSMITAS
%token tTRUE
%token tTYPEDEF
%token tUNION
%token tUNIQUE
......@@ -496,6 +498,8 @@ m_expr: { $$ = make_expr(EXPR_VOID); }
expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
| aHEXNUM { $$ = make_exprl(EXPR_HEXNUM, $1); }
| tFALSE { $$ = make_exprl(EXPR_TRUEFALSE, 0); }
| tTRUE { $$ = make_exprl(EXPR_TRUEFALSE, 1); }
| aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); }
| expr '?' expr ':' expr { $$ = make_expr3(EXPR_COND, $1, $3, $5); }
| expr '|' expr { $$ = make_expr2(EXPR_OR , $1, $3); }
......@@ -859,7 +863,9 @@ static expr_t *make_exprl(enum expr_type type, long val)
e->is_const = FALSE;
INIT_LINK(e);
/* check for numeric constant */
if (type == EXPR_NUM || type == EXPR_HEXNUM) {
if (type == EXPR_NUM || type == EXPR_HEXNUM || type == EXPR_TRUEFALSE) {
/* make sure true/false value is valid */
assert(type != EXPR_TRUEFALSE || val == 0 || val == 1);
e->is_const = TRUE;
e->cval = val;
}
......
......@@ -73,6 +73,7 @@ static int compare_expr(const expr_t *a, const expr_t *b)
{
case EXPR_NUM:
case EXPR_HEXNUM:
case EXPR_TRUEFALSE:
return a->u.lval - b->u.lval;
case EXPR_IDENTIFIER:
return strcmp(a->u.sval, b->u.sval);
......@@ -1957,6 +1958,12 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
case EXPR_HEXNUM:
fprintf(h, "0x%lx", e->u.lval);
break;
case EXPR_TRUEFALSE:
if (e->u.lval == 0)
fprintf(h, "FALSE");
else
fprintf(h, "TRUE");
break;
case EXPR_IDENTIFIER:
{
const var_t *field;
......
......@@ -156,6 +156,7 @@ enum expr_type
EXPR_AND,
EXPR_OR,
EXPR_COND,
EXPR_TRUEFALSE,
};
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