From 6710e7ec6fbc4c68dbffabb02b7f78339d391b0b Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 29 Dec 2011 11:08:34 +0100 Subject: [PATCH] jscript: Get rid of stat_eval_table. --- dlls/jscript/compile.c | 10 ++++++++++ dlls/jscript/engine.h | 1 - dlls/jscript/parser.y | 21 +-------------------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 127d967f032..5d63dbe3d81 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -1289,6 +1289,13 @@ static HRESULT compile_break_statement(compiler_ctx_t *ctx, branch_statement_t * return push_instr_uint(ctx, OP_jmp, pop_ctx->break_label); } +/* ECMA-262 3rd Edition 12.9 */ +static HRESULT compile_return_statement(compiler_ctx_t *ctx, expression_statement_t *stat) +{ + stat->stat.eval = return_statement_eval; + return compile_interp_fallback(ctx, &stat->stat); +} + /* ECMA-262 3rd Edition 12.10 */ static HRESULT compile_with_statement(compiler_ctx_t *ctx, with_statement_t *stat) { @@ -1527,6 +1534,9 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx, case STAT_LABEL: hres = push_instr(ctx, OP_label) == -1 ? E_OUTOFMEMORY : S_OK; /* FIXME */ break; + case STAT_RETURN: + hres = compile_return_statement(ctx, (expression_statement_t*)stat); + break; case STAT_SWITCH: hres = compile_switch_statement(ctx, (switch_statement_t*)stat); break; diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 4ac5e6a693a..b42a2ba19d5 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -412,7 +412,6 @@ typedef struct { statement_t *finally_statement; } try_statement_t; -HRESULT compiled_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN; HRESULT continue_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN; HRESULT break_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN; HRESULT return_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN; diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 5cf0412a9c7..a3fe42a885f 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -835,25 +835,6 @@ static BOOL allow_auto_semicolon(parser_ctx_t *ctx) return ctx->nl || ctx->ptr == ctx->end || *(ctx->ptr-1) == '}'; } -static const statement_eval_t stat_eval_table[] = { - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - return_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval, - compiled_statement_eval -}; - static void *new_statement(parser_ctx_t *ctx, statement_type_t type, size_t size) { statement_t *stat; @@ -863,7 +844,7 @@ static void *new_statement(parser_ctx_t *ctx, statement_type_t type, size_t size return NULL; stat->type = type; - stat->eval = stat_eval_table[type]; + stat->eval = NULL; stat->instr_off = -1; stat->next = NULL;