Jacek Caban : vbscript: Handle long/short distinction in interpreter.

Alexandre Julliard julliard at winehq.org
Thu Aug 22 15:09:54 CDT 2019


Module: wine
Branch: master
Commit: d01d6294204f619f6794fe42f04d3bcd98ba9001
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d01d6294204f619f6794fe42f04d3bcd98ba9001

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Aug 22 19:31:41 2019 +0200

vbscript: Handle long/short distinction in interpreter.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 3bd75c1..6fe01ab 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 03cecd5..d9bf79a 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 db00069..5c7ed25 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 f0479b5..39ebf3b 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 9b54517..8add9c9 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 <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
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 1d9c52e..0d8b0ed 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)          \




More information about the wine-cvs mailing list