From 43d10693ca62cf811d65570ffc4f897b67e074fc Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 14 Sep 2011 12:59:49 +0200 Subject: [PATCH] vbscript: Added xor, imp and eqv expressions parser/compiler implementation. --- dlls/vbscript/compile.c | 6 ++++++ dlls/vbscript/interp.c | 18 ++++++++++++++++++ dlls/vbscript/parse.h | 5 ++++- dlls/vbscript/parser.y | 11 ++++++++++- dlls/vbscript/vbscript.h | 5 ++++- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 8b759180858..f74f5fe76b8 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -370,10 +370,14 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) 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_EQV: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eqv); case EXPR_EXP: return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_exp); case EXPR_IDIV: return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_idiv); + case EXPR_IMP: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_imp); case EXPR_MEMBER: return compile_member_expression(ctx, (member_expression_t*)expr, TRUE); case EXPR_MOD: @@ -398,6 +402,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) return push_instr_int(ctx, OP_short, ((int_expression_t*)expr)->value); case EXPR_ULONG: return push_instr_int(ctx, OP_long, ((int_expression_t*)expr)->value); + case EXPR_XOR: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_xor); default: FIXME("Unimplemented expression type %d\n", expr->type); return E_NOTIMPL; diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 73165013cff..e166b21ca84 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -612,6 +612,24 @@ static HRESULT interp_or(exec_ctx_t *ctx) return stack_push(ctx, &v); } +static HRESULT interp_xor(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + +static HRESULT interp_eqv(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + +static HRESULT interp_imp(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + static HRESULT cmp_oper(exec_ctx_t *ctx) { variant_val_t l, r; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index b4a91c892eb..7e1124c68c4 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -25,8 +25,10 @@ typedef enum { EXPR_DOUBLE, EXPR_EMPTY, EXPR_EQUAL, + EXPR_EQV, EXPR_EXP, EXPR_IDIV, + EXPR_IMP, EXPR_MEMBER, EXPR_MOD, EXPR_MUL, @@ -38,7 +40,8 @@ typedef enum { EXPR_STRING, EXPR_SUB, EXPR_ULONG, - EXPR_USHORT + EXPR_USHORT, + EXPR_XOR } expression_type_t; typedef struct _expression_t { diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 48843e74224..a6281d6eed8 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -98,7 +98,7 @@ static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL); %type Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt %type Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression -%type NotExpression UnaryExpression AndExpression OrExpression +%type NotExpression UnaryExpression AndExpression OrExpression XorExpression EqvExpression %type MemberExpression %type Arguments_opt ArgumentList_opt ArgumentList %type OptionExplicit_opt @@ -188,7 +188,16 @@ EmptyBrackets_opt | tEMPTYBRACKETS Expression + : EqvExpression { $$ = $1; } + | Expression tIMP EqvExpression { $$ = new_binary_expression(ctx, EXPR_IMP, $1, $3); CHECK_ERROR; } + +EqvExpression + : XorExpression { $$ = $1; } + | EqvExpression tEQV XorExpression { $$ = new_binary_expression(ctx, EXPR_EQV, $1, $3); CHECK_ERROR; } + +XorExpression : OrExpression { $$ = $1; } + | XorExpression tXOR OrExpression { $$ = new_binary_expression(ctx, EXPR_XOR, $1, $3); CHECK_ERROR; } OrExpression : AndExpression { $$ = $1; } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 2a05998857c..5f1d6ce413e 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -126,10 +126,12 @@ typedef enum { X(double, 1, ARG_DOUBLE, 0) \ X(empty, 1, 0, 0) \ X(equal, 1, 0, 0) \ + X(eqv, 1, 0, 0) \ X(exp, 1, 0, 0) \ X(icall, 1, ARG_BSTR, ARG_UINT) \ X(icallv, 1, ARG_BSTR, ARG_UINT) \ X(idiv, 1, 0, 0) \ + X(imp, 1, 0, 0) \ X(jmp, 0, ARG_ADDR, 0) \ X(jmp_false, 0, ARG_ADDR, 0) \ X(long, 1, ARG_INT, 0) \ @@ -143,7 +145,8 @@ typedef enum { X(ret, 0, 0, 0) \ X(short, 1, ARG_INT, 0) \ X(string, 1, ARG_STR, 0) \ - X(sub, 1, 0, 0) + X(sub, 1, 0, 0) \ + X(xor, 1, 0, 0) typedef enum { #define X(x,n,a,b) OP_##x,