Jacek Caban : vbscript: Added multiplicative expression parser/ compiler implementation.

Alexandre Julliard julliard at winehq.org
Tue Sep 13 12:18:10 CDT 2011


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep 13 11:40:39 2011 +0200

vbscript: Added multiplicative expression parser/compiler implementation.

---

 dlls/vbscript/compile.c  |    4 ++++
 dlls/vbscript/interp.c   |   12 ++++++++++++
 dlls/vbscript/parse.h    |    2 ++
 dlls/vbscript/parser.y   |    9 ++++++++-
 dlls/vbscript/vbscript.h |    2 ++
 5 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index 98b8abd..d14e8de 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -353,6 +353,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
         return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value);
     case EXPR_CONCAT:
         return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_concat);
+    case EXPR_DIV:
+        return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_div);
     case EXPR_DOUBLE:
         return push_instr_double(ctx, OP_double, ((double_expression_t*)expr)->value);
     case EXPR_EMPTY:
@@ -365,6 +367,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
         return compile_member_expression(ctx, (member_expression_t*)expr, TRUE);
     case EXPR_MOD:
         return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mod);
+    case EXPR_MUL:
+        return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mul);
     case EXPR_NEG:
         return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
     case EXPR_NEQUAL:
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 925da12..4feb2a9 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -690,6 +690,18 @@ static HRESULT interp_idiv(exec_ctx_t *ctx)
     return stack_push(ctx, &v);
 }
 
+static HRESULT interp_div(exec_ctx_t *ctx)
+{
+    FIXME("\n");
+    return E_NOTIMPL;
+}
+
+static HRESULT interp_mul(exec_ctx_t *ctx)
+{
+    FIXME("\n");
+    return E_NOTIMPL;
+}
+
 static HRESULT interp_neg(exec_ctx_t *ctx)
 {
     variant_val_t val;
diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h
index 3d180ce..e15a851 100644
--- a/dlls/vbscript/parse.h
+++ b/dlls/vbscript/parse.h
@@ -20,12 +20,14 @@ typedef enum {
     EXPR_ADD,
     EXPR_BOOL,
     EXPR_CONCAT,
+    EXPR_DIV,
     EXPR_DOUBLE,
     EXPR_EMPTY,
     EXPR_EQUAL,
     EXPR_IDIV,
     EXPR_MEMBER,
     EXPR_MOD,
+    EXPR_MUL,
     EXPR_NEG,
     EXPR_NEQUAL,
     EXPR_NOT,
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 89cc569..7d574d1 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -91,7 +91,7 @@ static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*);
 
 %type <statement> Statement StatementNl StatementsNl IfStatement Else_opt
 %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
-%type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression
+%type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression
 %type <expression> NotExpression UnaryExpression
 %type <member> MemberExpression
 %type <expression> Arguments_opt ArgumentList_opt ArgumentList
@@ -203,6 +203,13 @@ IntdivExpression
                                                 { $$ = new_binary_expression(ctx, EXPR_IDIV, $1, $3); CHECK_ERROR; }
 
 MultiplicativeExpression
+    : ExpExpression                             { $$ = $1; }
+    | MultiplicativeExpression '*' ExpExpression
+                                                { $$ = new_binary_expression(ctx, EXPR_MUL, $1, $3); CHECK_ERROR; }
+    | MultiplicativeExpression '/' ExpExpression
+                                                { $$ = new_binary_expression(ctx, EXPR_DIV, $1, $3); CHECK_ERROR; }
+
+ExpExpression
     : UnaryExpression /* FIXME */   { $$ = $1; }
 
 UnaryExpression
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index a460233..690cad3 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -103,6 +103,7 @@ typedef enum {
     X(assign_member,  1, ARG_BSTR,    0)          \
     X(bool,           1, ARG_INT,     0)          \
     X(concat,         1, 0,           0)          \
+    X(div,            1, 0,           0)          \
     X(double,         1, ARG_DOUBLE,  0)          \
     X(empty,          1, 0,           0)          \
     X(equal,          1, 0,           0)          \
@@ -113,6 +114,7 @@ typedef enum {
     X(jmp_false,      0, ARG_ADDR,    0)          \
     X(long,           1, ARG_INT,     0)          \
     X(mod,            1, 0,           0)          \
+    X(mul,            1, 0,           0)          \
     X(neg,            1, 0,           0)          \
     X(nequal,         1, 0,           0)          \
     X(not,            1, 0,           0)          \




More information about the wine-cvs mailing list