Jacek Caban : vbscript: Added On Error statement parser implementation.

Alexandre Julliard julliard at winehq.org
Mon Sep 19 13:48:44 CDT 2011


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Sep 19 14:10:19 2011 +0200

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(+), 0 deletions(-)

diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index b2c0cc1..6ee86e1 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 16feabe..074dae1 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 bff48bb..976de53 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,
@@ -195,6 +196,11 @@ typedef struct {
 } while_statement_t;
 
 typedef struct {
+    statement_t stat;
+    BOOL resume_next;
+} onerror_statement_t;
+
+typedef struct {
     const WCHAR *code;
     const WCHAR *ptr;
     const WCHAR *end;
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index a3fb134..d3ed732 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 a1e07b9..e1c7fa1 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)          \




More information about the wine-cvs mailing list