Jacek Caban : vbscript: Added xor, imp and eqv expressions parser/ compiler implementation.

Alexandre Julliard julliard at winehq.org
Wed Sep 14 12:25:41 CDT 2011


Module: wine
Branch: master
Commit: 43d10693ca62cf811d65570ffc4f897b67e074fc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=43d10693ca62cf811d65570ffc4f897b67e074fc

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Sep 14 12:59:49 2011 +0200

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 8b75918..f74f5fe 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 7316501..e166b21 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 b4a91c8..7e1124c 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 48843e7..a6281d6 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> Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt
 %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
 %type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression
-%type <expression> NotExpression UnaryExpression AndExpression OrExpression
+%type <expression> NotExpression UnaryExpression AndExpression OrExpression XorExpression EqvExpression
 %type <member> MemberExpression
 %type <expression> Arguments_opt ArgumentList_opt ArgumentList
 %type <bool> 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 2a05998..5f1d6ce 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,




More information about the wine-cvs mailing list