Commit 4520815c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added null literal support.

parent 6d8f84e5
......@@ -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:
......
......@@ -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);
......
......@@ -22,6 +22,7 @@ typedef enum {
EXPR_EQUAL,
EXPR_MEMBER,
EXPR_NOT,
EXPR_NULL,
EXPR_STRING
} expression_type_t;
......
......@@ -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; }
......
......@@ -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()
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment