vbscript: Added empty literal support.
This commit is contained in:
parent
ddc47d6974
commit
6d8f84e533
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
typedef enum {
|
||||
EXPR_BOOL,
|
||||
EXPR_EMPTY,
|
||||
EXPR_EQUAL,
|
||||
EXPR_MEMBER,
|
||||
EXPR_NOT,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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) \
|
||||
|
|
Loading…
Reference in New Issue