Francois Gouget : vbscript: Add support for integer values in conditional jumps.

Alexandre Julliard julliard at winehq.org
Wed May 23 13:22:55 CDT 2012


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

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Wed May 23 15:36:04 2012 +0200

vbscript: Add support for integer values in conditional jumps.

---

 dlls/vbscript/interp.c       |   52 +++++++++++++++++++++++++++--------------
 dlls/vbscript/tests/lang.vbs |    8 ++++++
 2 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 67e1070..3f3e9c8 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -350,6 +350,34 @@ static inline void release_val(variant_val_t *v)
         VariantClear(v->v);
 }
 
+static int stack_pop_bool(exec_ctx_t *ctx, BOOL *b)
+{
+    variant_val_t val;
+    HRESULT hres;
+
+    hres = stack_pop_val(ctx, &val);
+    if(FAILED(hres))
+        return hres;
+
+    switch (V_VT(val.v))
+    {
+    case VT_BOOL:
+        *b = V_BOOL(val.v);
+        break;
+    case VT_I2:
+        *b = V_I2(val.v);
+        break;
+    case VT_I4:
+        *b = V_I4(val.v);
+        break;
+    default:
+        FIXME("unsupported for %s\n", debugstr_variant(val.v));
+        release_val(&val);
+        return E_NOTIMPL;
+    }
+    return S_OK;
+}
+
 static HRESULT stack_pop_disp(exec_ctx_t *ctx, IDispatch **ret)
 {
     VARIANT *v = stack_pop(ctx);
@@ -886,22 +914,16 @@ static HRESULT interp_jmp(exec_ctx_t *ctx)
 static HRESULT interp_jmp_false(exec_ctx_t *ctx)
 {
     const unsigned arg = ctx->instr->arg1.uint;
-    variant_val_t val;
     HRESULT hres;
+    BOOL b;
 
     TRACE("%u\n", arg);
 
-    hres = stack_pop_val(ctx, &val);
+    hres = stack_pop_bool(ctx, &b);
     if(FAILED(hres))
         return hres;
 
-    if(V_VT(val.v) != VT_BOOL) {
-        FIXME("unsupported for %s\n", debugstr_variant(val.v));
-        release_val(&val);
-        return E_NOTIMPL;
-    }
-
-    if(V_BOOL(val.v))
+    if(b)
         ctx->instr++;
     else
         instr_jmp(ctx, ctx->instr->arg1.uint);
@@ -911,22 +933,16 @@ static HRESULT interp_jmp_false(exec_ctx_t *ctx)
 static HRESULT interp_jmp_true(exec_ctx_t *ctx)
 {
     const unsigned arg = ctx->instr->arg1.uint;
-    variant_val_t val;
     HRESULT hres;
+    BOOL b;
 
     TRACE("%u\n", arg);
 
-    hres = stack_pop_val(ctx, &val);
+    hres = stack_pop_bool(ctx, &b);
     if(FAILED(hres))
         return hres;
 
-    if(V_VT(val.v) != VT_BOOL) {
-        FIXME("unsupported for %s\n", debugstr_variant(val.v));
-        release_val(&val);
-        return E_NOTIMPL;
-    }
-
-    if(V_BOOL(val.v))
+    if(b)
         instr_jmp(ctx, ctx->instr->arg1.uint);
     else
         ctx->instr++;
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 1015e34..4900a52 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -260,6 +260,14 @@ End If
 Call ok(x, "elseif not called?")
 
 x = false
+if 1 then x = true
+Call ok(x, "if 1 not run?")
+
+x = false
+if &h10000& then x = true
+Call ok(x, "if &h10000& not run?")
+
+x = false
 y = false
 while not (x and y)
     if x then




More information about the wine-cvs mailing list