From fa3e6917b49075ac7662a3a8517357497e6d278f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 14 Oct 2009 14:41:50 +0200 Subject: [PATCH] jscript: Don't use VARTYPE as is in literal_t. --- dlls/jscript/engine.c | 30 ++++++++++++++++-------------- dlls/jscript/engine.h | 12 +++++++++++- dlls/jscript/lex.c | 6 +++--- dlls/jscript/parser.y | 8 ++++---- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index cecfd62b606..fa14fd925a5 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -349,31 +349,33 @@ static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret) static HRESULT literal_to_var(literal_t *literal, VARIANT *v) { - V_VT(v) = literal->vt; - - switch(V_VT(v)) { - case VT_EMPTY: - case VT_NULL: + switch(literal->type) { + case LT_UNDEFINED: + V_VT(v) = VT_EMPTY; break; - case VT_I4: + case LT_NULL: + V_VT(v) = VT_NULL; + break; + case LT_INT: + V_VT(v) = VT_I4; V_I4(v) = literal->u.lval; break; - case VT_R8: + case LT_DOUBLE: + V_VT(v) = VT_R8; V_R8(v) = literal->u.dval; break; - case VT_BSTR: + case LT_STRING: + V_VT(v) = VT_BSTR; V_BSTR(v) = SysAllocString(literal->u.wstr); break; - case VT_BOOL: + case LT_BOOL: + V_VT(v) = VT_BOOL; V_BOOL(v) = literal->u.bval; break; - case VT_DISPATCH: + case LT_DISPATCH: + V_VT(v) = VT_DISPATCH; IDispatch_AddRef(literal->u.disp); V_DISPATCH(v) = literal->u.disp; - break; - default: - ERR("wrong type %d\n", V_VT(v)); - return E_NOTIMPL; } return S_OK; diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 386f38b51fd..e1952a92d80 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -126,8 +126,18 @@ typedef struct _parameter_t parameter_t; HRESULT create_source_function(parser_ctx_t*,parameter_t*,source_elements_t*,scope_chain_t*, const WCHAR*,DWORD,DispatchEx**); +typedef enum { + LT_INT, + LT_DOUBLE, + LT_STRING, + LT_BOOL, + LT_DISPATCH, + LT_UNDEFINED, + LT_NULL +}literal_type_t; + typedef struct { - VARTYPE vt; + literal_type_t type; union { LONG lval; double dval; diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index 43089d3e210..cd53bd91fce 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -369,7 +369,7 @@ static literal_t *alloc_int_literal(parser_ctx_t *ctx, LONG l) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_I4; + ret->type = LT_INT; ret->u.lval = l; return ret; @@ -447,7 +447,7 @@ static int parse_double_literal(parser_ctx_t *ctx, LONG int_part, literal_t **li } *literal = parser_alloc(ctx, sizeof(literal_t)); - (*literal)->vt = VT_R8; + (*literal)->type = LT_DOUBLE; (*literal)->u.dval = (double)d*pow(10, exp); return tNumericLiteral; @@ -801,7 +801,7 @@ literal_t *parse_regexp(parser_ctx_t *ctx) add_object_literal(ctx, regexp); ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_DISPATCH; + ret->type = LT_DISPATCH; ret->u.disp = (IDispatch*)_IDispatchEx_(regexp); return ret; } diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index d4b49089424..ee3d1009e05 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -841,7 +841,7 @@ static literal_t *new_string_literal(parser_ctx_t *ctx, const WCHAR *str) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BSTR; + ret->type = LT_STRING; ret->u.wstr = str; return ret; @@ -851,7 +851,7 @@ static literal_t *new_null_literal(parser_ctx_t *ctx) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_NULL; + ret->type = LT_NULL; return ret; } @@ -860,7 +860,7 @@ static literal_t *new_undefined_literal(parser_ctx_t *ctx) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_EMPTY; + ret->type = LT_UNDEFINED; return ret; } @@ -869,7 +869,7 @@ static literal_t *new_boolean_literal(parser_ctx_t *ctx, VARIANT_BOOL bval) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BOOL; + ret->type = LT_BOOL; ret->u.bval = bval; return ret;