vbscript: Handle long/short distinction in interpreter.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-08-22 19:31:41 +02:00 committed by Alexandre Julliard
parent a390b7e870
commit d01d629420
6 changed files with 14 additions and 28 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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)

View File

@ -50,7 +50,6 @@ typedef enum {
EXPR_STRING,
EXPR_SUB,
EXPR_ULONG,
EXPR_USHORT,
EXPR_XOR
} expression_type_t;

View File

@ -119,7 +119,7 @@ static statement_t *link_statements(statement_t*,statement_t*);
%token <string> tNEXT tON tRESUME tGOTO
%token <string> tIdentifier tString
%token <string> tDEFAULT tERROR tEXPLICIT tPROPERTY tSTEP
%token <lng> tLong tShort
%token <lng> tLong
%token <dbl> tDouble
%type <statement> 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

View File

@ -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) \