From 6afc32c97d080fa3b8933cdc0cae3338da5d7d0e Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 19 Sep 2011 14:10:19 +0200 Subject: [PATCH] vbscript: Added On Error statement parser implementation. --- dlls/vbscript/compile.c | 8 ++++++++ dlls/vbscript/interp.c | 7 +++++++ dlls/vbscript/parse.h | 6 ++++++ dlls/vbscript/parser.y | 15 +++++++++++++++ dlls/vbscript/vbscript.h | 1 + 5 files changed, 37 insertions(+) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index b2c0cc12497..6ee86e1e3fb 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -697,6 +697,11 @@ static HRESULT compile_exitprop_statement(compile_ctx_t *ctx) return push_instr_addr(ctx, OP_jmp, ctx->prop_end_label); } +static HRESULT compile_onerror_statement(compile_ctx_t *ctx, onerror_statement_t *stat) +{ + return push_instr_int(ctx, OP_errmode, stat->resume_next); +} + static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) { HRESULT hres; @@ -734,6 +739,9 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) case STAT_IF: hres = compile_if_statement(ctx, (if_statement_t*)stat); break; + case STAT_ONERROR: + hres = compile_onerror_statement(ctx, (onerror_statement_t*)stat); + break; case STAT_SET: hres = compile_assign_statement(ctx, (assign_statement_t*)stat, TRUE); break; diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 16feabe483f..074dae1e175 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -732,6 +732,13 @@ static HRESULT interp_bool(exec_ctx_t *ctx) return stack_push(ctx, &v); } +static HRESULT interp_errmode(exec_ctx_t *ctx) +{ + const int err_mode = ctx->instr->arg1.uint; + FIXME("%d\n", err_mode); + return E_NOTIMPL; +} + static HRESULT interp_string(exec_ctx_t *ctx) { VARIANT v; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index bff48bbe7fa..976de53c0d9 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -107,6 +107,7 @@ typedef enum { STAT_EXITSUB, STAT_FUNC, STAT_IF, + STAT_ONERROR, STAT_SET, STAT_STOP, STAT_UNTIL, @@ -194,6 +195,11 @@ typedef struct { statement_t *body; } while_statement_t; +typedef struct { + statement_t stat; + BOOL resume_next; +} onerror_statement_t; + typedef struct { const WCHAR *code; const WCHAR *ptr; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index a3fb134b63c..d3ed7322138 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -55,6 +55,7 @@ static statement_t *new_dim_statement(parser_ctx_t*,dim_decl_t*); static statement_t *new_while_statement(parser_ctx_t*,statement_type_t,expression_t*,statement_t*); static statement_t *new_if_statement(parser_ctx_t*,expression_t*,statement_t*,elseif_decl_t*,statement_t*); static statement_t *new_function_statement(parser_ctx_t*,function_decl_t*); +static statement_t *new_onerror_statement(parser_ctx_t*,BOOL); static dim_decl_t *new_dim_decl(parser_ctx_t*,const WCHAR*,dim_decl_t*); static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*); @@ -170,6 +171,8 @@ Statement | tSET MemberExpression Arguments_opt '=' Expression { $2->args = $3; $$ = new_set_statement(ctx, $2, $5); CHECK_ERROR; } | tSTOP { $$ = new_statement(ctx, STAT_STOP, 0); CHECK_ERROR; } + | tON tERROR tRESUME tNEXT { $$ = new_onerror_statement(ctx, TRUE); CHECK_ERROR; } + | tON tERROR tGOTO '0' { $$ = new_onerror_statement(ctx, FALSE); CHECK_ERROR; } MemberExpression : tIdentifier { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; } @@ -614,6 +617,18 @@ static statement_t *new_if_statement(parser_ctx_t *ctx, expression_t *expr, stat return &stat->stat; } +static statement_t *new_onerror_statement(parser_ctx_t *ctx, BOOL resume_next) +{ + onerror_statement_t *stat; + + stat = new_statement(ctx, STAT_ONERROR, sizeof(*stat)); + if(!stat) + return NULL; + + stat->resume_next = resume_next; + return &stat->stat; +} + static arg_decl_t *new_argument_decl(parser_ctx_t *ctx, const WCHAR *name, BOOL by_ref) { arg_decl_t *arg_decl; diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index a1e07b90f81..e1c7fa117bc 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -186,6 +186,7 @@ typedef enum { X(double, 1, ARG_DOUBLE, 0) \ X(empty, 1, 0, 0) \ X(equal, 1, 0, 0) \ + X(errmode, 1, ARG_INT, 0) \ X(eqv, 1, 0, 0) \ X(exp, 1, 0, 0) \ X(gt, 1, 0, 0) \