Jacek Caban : vbscript: Added empty literal support.
Alexandre Julliard
julliard at winehq.org
Fri Sep 9 10:56:48 CDT 2011
Module: wine
Branch: master
Commit: 6d8f84e5333bbb822127e636e1b4554f88629679
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6d8f84e5333bbb822127e636e1b4554f88629679
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Sep 9 14:49:26 2011 +0200
vbscript: Added empty literal support.
---
dlls/vbscript/compile.c | 2 ++
dlls/vbscript/interp.c | 10 ++++++++++
dlls/vbscript/parse.h | 1 +
dlls/vbscript/parser.y | 4 +++-
dlls/vbscript/tests/lang.vbs | 3 +++
dlls/vbscript/vbscript.h | 1 +
6 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index e9b651d..aa9881c 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -196,6 +196,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
switch(expr->type) {
case EXPR_BOOL:
return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value);
+ case EXPR_EMPTY:
+ return push_instr(ctx, OP_empty) != -1 ? S_OK : E_OUTOFMEMORY;
case EXPR_EQUAL:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_equal);
case EXPR_MEMBER:
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index ec56fa9..4e16d74 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -251,6 +251,16 @@ static HRESULT interp_string(exec_ctx_t *ctx)
return stack_push(ctx, &v);
}
+static HRESULT interp_empty(exec_ctx_t *ctx)
+{
+ VARIANT v;
+
+ TRACE("\n");
+
+ V_VT(&v) = VT_EMPTY;
+ return stack_push(ctx, &v);
+}
+
static HRESULT interp_not(exec_ctx_t *ctx)
{
variant_val_t val;
diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h
index 607bdec..409e737 100644
--- a/dlls/vbscript/parse.h
+++ b/dlls/vbscript/parse.h
@@ -18,6 +18,7 @@
typedef enum {
EXPR_BOOL,
+ EXPR_EMPTY,
EXPR_EQUAL,
EXPR_MEMBER,
EXPR_NOT,
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 7bfdae9..36ebf17 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -35,6 +35,7 @@ static int parser_error(const char*);
static void source_add_statement(parser_ctx_t*,statement_t*);
+static void *new_expression(parser_ctx_t*,expression_type_t,size_t);
static expression_t *new_bool_expression(parser_ctx_t*,VARIANT_BOOL);
static expression_t *new_string_expression(parser_ctx_t*,const WCHAR*);
static expression_t *new_unary_expression(parser_ctx_t*,expression_type_t,expression_t*);
@@ -145,6 +146,7 @@ LiteralExpression
: tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; }
| 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; }
PrimaryExpression
: '(' Expression ')' { $$ = $2; }
@@ -172,7 +174,7 @@ static void parse_complete(parser_ctx_t *ctx, BOOL option_explicit)
ctx->option_explicit = option_explicit;
}
-static void *new_expression(parser_ctx_t *ctx, expression_type_t type, unsigned size)
+static void *new_expression(parser_ctx_t *ctx, expression_type_t type, size_t size)
{
expression_t *expr;
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 1c9512a..3614f96 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -29,10 +29,13 @@ Call ok(true = true, "true = true is false")
Call ok(false = false, "false = false is false")
Call ok(not (true = false), "true = false is true")
Call ok("x" = "x", """x"" = ""x"" is false")
+Call ok(empty = empty, "empty = empty is false")
+Call ok(empty = "", "empty = """" is false")
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")
Call ok(getVT("test") = "VT_BSTR", "getVT(""test"") is not VT_BSTR")
+Call ok(getVT(Empty) = "VT_EMPTY", "getVT(Empty) is not VT_EMPTY")
reportSuccess()
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 0219334..aa90f4c 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -76,6 +76,7 @@ typedef enum {
#define OP_LIST \
X(bool, 1, ARG_INT, 0) \
+ X(empty, 1, 0, 0) \
X(equal, 1, 0, 0) \
X(icall, 1, ARG_BSTR, ARG_UINT) \
X(icallv, 1, ARG_BSTR, ARG_UINT) \
More information about the wine-cvs
mailing list