From d01d6294204f619f6794fe42f04d3bcd98ba9001 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 22 Aug 2019 19:31:41 +0200 Subject: [PATCH] vbscript: Handle long/short distinction in interpreter. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/vbscript/compile.c | 4 +--- dlls/vbscript/interp.c | 21 +++++++-------------- dlls/vbscript/lex.c | 7 +++---- dlls/vbscript/parse.h | 1 - dlls/vbscript/parser.y | 8 +++----- dlls/vbscript/vbscript.h | 1 - 6 files changed, 14 insertions(+), 28 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 3bd75c1c9d0..6fe01abbf02 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -536,8 +536,6 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) return push_instr_str(ctx, OP_string, ((string_expression_t*)expr)->value); case EXPR_SUB: return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_sub); - case EXPR_USHORT: - return push_instr_int(ctx, OP_short, ((int_expression_t*)expr)->value); case EXPR_ULONG: return push_instr_int(ctx, OP_long, ((int_expression_t*)expr)->value); case EXPR_XOR: @@ -781,7 +779,7 @@ static HRESULT compile_forto_statement(compile_ctx_t *ctx, forto_statement_t *st if(!push_instr(ctx, OP_val)) return E_OUTOFMEMORY; }else { - hres = push_instr_int(ctx, OP_short, 1); + hres = push_instr_int(ctx, OP_long, 1); if(FAILED(hres)) return hres; } diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 03cecd5a1a6..d9bf79ae57a 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1322,20 +1322,13 @@ static HRESULT interp_long(exec_ctx_t *ctx) TRACE("%d\n", arg); - V_VT(&v) = VT_I4; - V_I4(&v) = arg; - return stack_push(ctx, &v); -} - -static HRESULT interp_short(exec_ctx_t *ctx) -{ - const LONG arg = ctx->instr->arg1.lng; - VARIANT v; - - TRACE("%d\n", arg); - - V_VT(&v) = VT_I2; - V_I2(&v) = arg; + if(arg == (INT16)arg) { + V_VT(&v) = VT_I2; + V_I2(&v) = arg; + }else { + V_VT(&v) = VT_I4; + V_I4(&v) = arg; + } return stack_push(ctx, &v); } diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index db0006945d2..5c7ed2552b7 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -334,9 +334,8 @@ static int parse_numeric_literal(parser_ctx_t *ctx, void **ret) } if(use_int && (LONG)d == d) { - LONG l = d; - *(LONG*)ret = l; - return (short)l == l ? tShort : tLong; + *(LONG*)ret = d; + return tLong; } r = exp>=0 ? d*pow(10, exp) : d/pow(10, -exp); @@ -377,7 +376,7 @@ static int parse_hex_literal(parser_ctx_t *ctx, LONG *ret) ctx->ptr++; *ret = l; - return (short)l == l ? tShort : tLong; + return tLong; } static void skip_spaces(parser_ctx_t *ctx) diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index f0479b5be07..39ebf3bd3e6 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -50,7 +50,6 @@ typedef enum { EXPR_STRING, EXPR_SUB, EXPR_ULONG, - EXPR_USHORT, EXPR_XOR } expression_type_t; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 9b54517667f..8add9c91723 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -119,7 +119,7 @@ static statement_t *link_statements(statement_t*,statement_t*); %token tNEXT tON tRESUME tGOTO %token tIdentifier tString %token tDEFAULT tERROR tEXPLICIT tPROPERTY tSTEP -%token tLong tShort +%token tLong %token tDouble %type Statement SimpleStatement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt @@ -381,14 +381,12 @@ LiteralExpression | tNOTHING { $$ = new_expression(ctx, EXPR_NOTHING, 0); CHECK_ERROR; } NumericLiteralExpression - : tShort { $$ = new_long_expression(ctx, EXPR_USHORT, $1); CHECK_ERROR; } - | '0' { $$ = new_long_expression(ctx, EXPR_USHORT, 0); CHECK_ERROR; } + : '0' { $$ = new_long_expression(ctx, EXPR_ULONG, 0); CHECK_ERROR; } | tLong { $$ = new_long_expression(ctx, EXPR_ULONG, $1); CHECK_ERROR; } | tDouble { $$ = new_double_expression(ctx, $1); CHECK_ERROR; } IntegerValue - : tShort { $$ = $1; } - | '0' { $$ = 0; } + : '0' { $$ = 0; } | tLong { $$ = $1; } PrimaryExpression diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 1d9c52e7eda..0d8b0ede044 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -272,7 +272,6 @@ typedef enum { X(ret, 0, 0, 0) \ X(set_ident, 1, ARG_BSTR, ARG_UINT) \ X(set_member, 1, ARG_BSTR, ARG_UINT) \ - X(short, 1, ARG_INT, 0) \ X(step, 0, ARG_ADDR, ARG_BSTR) \ X(stop, 1, 0, 0) \ X(string, 1, ARG_STR, 0) \