Module: wine Branch: master Commit: 0ec93395334bdb069c2b206ad5e6d9c6053cbd56 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0ec93395334bdb069c2b206ad5...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Sep 12 12:31:58 2011 +0200
vbscript: Added additive expressions parser/compiler implementation.
---
dlls/vbscript/compile.c | 4 ++++ dlls/vbscript/interp.c | 12 ++++++++++++ dlls/vbscript/parse.h | 2 ++ dlls/vbscript/parser.y | 7 ++++++- dlls/vbscript/vbscript.h | 4 +++- 5 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index baaa078..9e34c35 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -234,6 +234,8 @@ static HRESULT compile_binary_expression(compile_ctx_t *ctx, binary_expression_t static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) { switch(expr->type) { + case EXPR_ADD: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add); case EXPR_BOOL: return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value); case EXPR_CONCAT: @@ -254,6 +256,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) 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); + case EXPR_SUB: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_sub); case EXPR_USHORT: return push_instr_int(ctx, OP_short, ((int_expression_t*)expr)->value); case EXPR_ULONG: diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 67230da..fb3adfe 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -391,6 +391,18 @@ static HRESULT interp_concat(exec_ctx_t *ctx) return stack_push(ctx, &v); }
+static HRESULT interp_add(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + +static HRESULT interp_sub(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 0c87209..3d6d604 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -17,6 +17,7 @@ */
typedef enum { + EXPR_ADD, EXPR_BOOL, EXPR_CONCAT, EXPR_DOUBLE, @@ -27,6 +28,7 @@ typedef enum { EXPR_NOT, EXPR_NULL, EXPR_STRING, + EXPR_SUB, EXPR_ULONG, EXPR_USHORT } expression_type_t; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 316957c..2f42ab6 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -83,7 +83,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
%type <statement> Statement StatementNl %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression -%type <expression> ConcatExpression AdditiveExpression +%type <expression> ConcatExpression AdditiveExpression ModExpression %type <expression> NotExpression UnaryExpression %type <member> MemberExpression %type <expression> Arguments_opt ArgumentList_opt ArgumentList @@ -145,6 +145,11 @@ ConcatExpression | ConcatExpression '&' AdditiveExpression { $$ = new_binary_expression(ctx, EXPR_CONCAT, $1, $3); CHECK_ERROR; }
AdditiveExpression + : ModExpression { $$ = $1; } + | AdditiveExpression '+' ModExpression { $$ = new_binary_expression(ctx, EXPR_ADD, $1, $3); CHECK_ERROR; } + | AdditiveExpression '-' ModExpression { $$ = new_binary_expression(ctx, EXPR_SUB, $1, $3); CHECK_ERROR; } + +ModExpression : UnaryExpression /* FIXME */ { $$ = $1; }
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 9db2692..cf90b38 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -88,6 +88,7 @@ typedef enum { } instr_arg_type_t;
#define OP_LIST \ + X(add, 1, 0, 0) \ X(bool, 1, ARG_INT, 0) \ X(concat, 1, 0, 0) \ X(double, 1, ARG_DOUBLE, 0) \ @@ -101,7 +102,8 @@ typedef enum { X(null, 1, 0, 0) \ X(ret, 0, 0, 0) \ X(short, 1, ARG_INT, 0) \ - X(string, 1, ARG_STR, 0) + X(string, 1, ARG_STR, 0) \ + X(sub, 1, 0, 0)
typedef enum { #define X(x,n,a,b) OP_##x,