Module: wine Branch: master Commit: 114ffc8720a5ece8700802b33be97f9ae839fd99 URL: http://source.winehq.org/git/wine.git/?a=commit;h=114ffc8720a5ece8700802b33b...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Sep 9 14:48:48 2011 +0200
vbscript: Added compiler/parser support for call expressions.
---
dlls/vbscript/compile.c | 8 +++++--- dlls/vbscript/interp.c | 6 ++++++ dlls/vbscript/parser.y | 8 ++++++-- dlls/vbscript/vbscript.h | 1 + 4 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 5ed19c4..e9b651d 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -146,7 +146,7 @@ static HRESULT compile_args(compile_ctx_t *ctx, expression_t *args, unsigned *re return S_OK; }
-static HRESULT compile_member_expression(compile_ctx_t *ctx, member_expression_t *expr) +static HRESULT compile_member_expression(compile_ctx_t *ctx, member_expression_t *expr, BOOL ret_val) { unsigned arg_cnt = 0; HRESULT hres; @@ -159,7 +159,7 @@ static HRESULT compile_member_expression(compile_ctx_t *ctx, member_expression_t FIXME("obj_expr not implemented\n"); hres = E_NOTIMPL; }else { - hres = push_instr_bstr_uint(ctx, OP_icallv, expr->identifier, arg_cnt); + hres = push_instr_bstr_uint(ctx, ret_val ? OP_icall : OP_icallv, expr->identifier, arg_cnt); }
return hres; @@ -198,6 +198,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_EQUAL: return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_equal); + case EXPR_MEMBER: + return compile_member_expression(ctx, (member_expression_t*)expr, TRUE); case EXPR_NOT: return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_not); case EXPR_STRING: @@ -217,7 +219,7 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) while(stat) { switch(stat->type) { case STAT_CALL: - hres = compile_member_expression(ctx, ((call_statement_t*)stat)->expr); + hres = compile_member_expression(ctx, ((call_statement_t*)stat)->expr, FALSE); break; default: FIXME("Unimplemented statement type %d\n", stat->type); diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 42bef36..d88439a 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -168,6 +168,12 @@ static void vbstack_to_dp(exec_ctx_t *ctx, unsigned arg_cnt, DISPPARAMS *dp) } }
+static HRESULT interp_icall(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + static HRESULT interp_icallv(exec_ctx_t *ctx) { BSTR identifier = ctx->instr->arg1.bstr; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 7703402..7bfdae9 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -75,7 +75,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); %token <string> tIdentifier tString
%type <statement> Statement StatementNl -%type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression +%type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type <expression> ConcatExpression %type <expression> NotExpression %type <member> MemberExpression @@ -135,7 +135,11 @@ EqualityExpression
ConcatExpression : LiteralExpression /* FIXME */ { $$ = $1; } - | PrimaryExpression /* FIXME */ { $$ = $1; } + | CallExpression /* FIXME */ { $$ = $1; } + +CallExpression + : PrimaryExpression { $$ = $1; } + | MemberExpression Arguments_opt { $1->args = $2; $$ = &$1->expr; }
LiteralExpression : tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index e717872..0219334 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -77,6 +77,7 @@ typedef enum { #define OP_LIST \ X(bool, 1, ARG_INT, 0) \ X(equal, 1, 0, 0) \ + X(icall, 1, ARG_BSTR, ARG_UINT) \ X(icallv, 1, ARG_BSTR, ARG_UINT) \ X(not, 1, 0, 0) \ X(ret, 0, 0, 0) \