Jacek Caban : vbscript: Added '<>' expression implementation.
Alexandre Julliard
julliard at winehq.org
Mon Sep 12 11:43:00 CDT 2011
Module: wine
Branch: master
Commit: 43f6a6842acd0b1374a5b200427768f8f631502d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=43f6a6842acd0b1374a5b200427768f8f631502d
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Sep 12 12:32:27 2011 +0200
vbscript: Added '<>' expression implementation.
---
dlls/vbscript/compile.c | 2 ++
dlls/vbscript/interp.c | 16 ++++++++++++++++
dlls/vbscript/parse.h | 1 +
dlls/vbscript/parser.y | 1 +
dlls/vbscript/tests/lang.vbs | 5 +++++
dlls/vbscript/vbscript.h | 1 +
6 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index 9e34c35..a91cb5d 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -250,6 +250,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return compile_member_expression(ctx, (member_expression_t*)expr, TRUE);
case EXPR_NEG:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
+ case EXPR_NEQUAL:
+ return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_nequal);
case EXPR_NOT:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_not);
case EXPR_NULL:
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 4585f88..51ec8e7 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -367,6 +367,22 @@ static HRESULT interp_equal(exec_ctx_t *ctx)
return stack_push(ctx, &v);
}
+static HRESULT interp_nequal(exec_ctx_t *ctx)
+{
+ VARIANT v;
+ HRESULT hres;
+
+ TRACE("\n");
+
+ hres = cmp_oper(ctx);
+ if(FAILED(hres))
+ return hres;
+
+ V_VT(&v) = VT_BOOL;
+ V_BOOL(&v) = hres != VARCMP_EQ ? VARIANT_TRUE : VARIANT_FALSE;
+ return stack_push(ctx, &v);
+}
+
static HRESULT interp_concat(exec_ctx_t *ctx)
{
variant_val_t r, l;
diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h
index 3d6d604..188b673 100644
--- a/dlls/vbscript/parse.h
+++ b/dlls/vbscript/parse.h
@@ -25,6 +25,7 @@ typedef enum {
EXPR_EQUAL,
EXPR_MEMBER,
EXPR_NEG,
+ EXPR_NEQUAL,
EXPR_NOT,
EXPR_NULL,
EXPR_STRING,
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 2f42ab6..ebfbbbc 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -139,6 +139,7 @@ NotExpression
EqualityExpression
: ConcatExpression { $$ = $1; }
| EqualityExpression '=' ConcatExpression { $$ = new_binary_expression(ctx, EXPR_EQUAL, $1, $3); CHECK_ERROR; }
+ | EqualityExpression tNEQ ConcatExpression { $$ = new_binary_expression(ctx, EXPR_NEQUAL, $1, $3); CHECK_ERROR; }
ConcatExpression
: AdditiveExpression { $$ = $1; }
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 9c37bb2..2e81643 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -40,6 +40,11 @@ Call ok(&hffFFffFF& = -1, "&hffFFffFF& <> -1")
Call ok(--1 = 1, "--1 = " & --1)
Call ok(-empty = 0, "-empty = " & (-empty))
+Call ok(true <> false, "true <> false is false")
+Call ok(not (true <> true), "true <> true is true")
+Call ok(not ("x" <> "x"), """x"" <> ""x"" is true")
+Call ok(not (empty <> empty), "empty <> empty is true")
+
Call ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL")
Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL")
Call ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR")
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index cf90b38..e2cfdea 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -98,6 +98,7 @@ typedef enum {
X(icallv, 1, ARG_BSTR, ARG_UINT) \
X(long, 1, ARG_INT, 0) \
X(neg, 1, 0, 0) \
+ X(nequal, 1, 0, 0) \
X(not, 1, 0, 0) \
X(null, 1, 0, 0) \
X(ret, 0, 0, 0) \
More information about the wine-cvs
mailing list