Commit 6afc32c9 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added On Error statement parser implementation.

parent afffa2c5
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment