Jacek Caban : vbscript: Added null literal support.
Alexandre Julliard
julliard at winehq.org
Fri Sep 9 10:56:48 CDT 2011
Module: wine
Branch: master
Commit: 4520815c0229733eb578bdd048ff698a0e393687
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4520815c0229733eb578bdd048ff698a0e393687
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Sep 9 14:49:36 2011 +0200
vbscript: Added null literal support.
---
dlls/vbscript/compile.c | 2 ++
dlls/vbscript/interp.c | 20 ++++++++++++++++++--
dlls/vbscript/parse.h | 1 +
dlls/vbscript/parser.y | 1 +
dlls/vbscript/tests/lang.vbs | 1 +
dlls/vbscript/vbscript.h | 1 +
6 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index aa9881c..181f6c1 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -204,6 +204,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return compile_member_expression(ctx, (member_expression_t*)expr, TRUE);
case EXPR_NOT:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_not);
+ case EXPR_NULL:
+ return push_instr(ctx, OP_null) != -1 ? S_OK : E_OUTOFMEMORY;
case EXPR_STRING:
return push_instr_str(ctx, OP_string, ((string_expression_t*)expr)->value);
default:
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 4e16d74..d02516e 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -261,6 +261,16 @@ static HRESULT interp_empty(exec_ctx_t *ctx)
return stack_push(ctx, &v);
}
+static HRESULT interp_null(exec_ctx_t *ctx)
+{
+ VARIANT v;
+
+ TRACE("\n");
+
+ V_VT(&v) = VT_NULL;
+ return stack_push(ctx, &v);
+}
+
static HRESULT interp_not(exec_ctx_t *ctx)
{
variant_val_t val;
@@ -291,8 +301,14 @@ static HRESULT cmp_oper(exec_ctx_t *ctx)
return hres;
hres = stack_pop_val(ctx, &l);
- if(SUCCEEDED(hres))
- hres = VarCmp(l.v, r.v, ctx->script->lcid, 0);
+ if(SUCCEEDED(hres)) {
+ if(V_VT(l.v) == VT_NULL || V_VT(r.v) == VT_NULL) {
+ FIXME("comparing nulls is not implemented\n");
+ hres = E_NOTIMPL;
+ }else {
+ hres = VarCmp(l.v, r.v, ctx->script->lcid, 0);
+ }
+ }
release_val(&r);
release_val(&l);
diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h
index 409e737..56b3e1b 100644
--- a/dlls/vbscript/parse.h
+++ b/dlls/vbscript/parse.h
@@ -22,6 +22,7 @@ typedef enum {
EXPR_EQUAL,
EXPR_MEMBER,
EXPR_NOT,
+ EXPR_NULL,
EXPR_STRING
} expression_type_t;
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 36ebf17..c1c7e61 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -147,6 +147,7 @@ LiteralExpression
| tFALSE { $$ = new_bool_expression(ctx, VARIANT_FALSE); CHECK_ERROR; }
| tString { $$ = new_string_expression(ctx, $1); CHECK_ERROR; }
| tEMPTY { $$ = new_expression(ctx, EXPR_EMPTY, 0); CHECK_ERROR; }
+ | tNULL { $$ = new_expression(ctx, EXPR_NULL, 0); CHECK_ERROR; }
PrimaryExpression
: '(' Expression ')' { $$ = $2; }
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 3614f96..8a5a9c5 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -37,5 +37,6 @@ Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL")
Call ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR")
Call ok(getVT("test") = "VT_BSTR", "getVT(""test"") is not VT_BSTR")
Call ok(getVT(Empty) = "VT_EMPTY", "getVT(Empty) is not VT_EMPTY")
+Call ok(getVT(null) = "VT_NULL", "getVT(null) is not VT_NULL")
reportSuccess()
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index aa90f4c..199ca70 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -81,6 +81,7 @@ typedef enum {
X(icall, 1, ARG_BSTR, ARG_UINT) \
X(icallv, 1, ARG_BSTR, ARG_UINT) \
X(not, 1, 0, 0) \
+ X(null, 1, 0, 0) \
X(ret, 0, 0, 0) \
X(string, 1, ARG_STR, 0)
More information about the wine-cvs
mailing list