jscript: Use bytecode for throw statement.

oldstable
Jacek Caban 2011-12-28 12:06:17 +01:00 committed by Alexandre Julliard
parent 3f4f9f0f40
commit 02ff8d1853
4 changed files with 18 additions and 12 deletions

View File

@ -1299,6 +1299,18 @@ static HRESULT compile_switch_statement(compiler_ctx_t *ctx, switch_statement_t
return S_OK;
}
/* ECMA-262 3rd Edition 12.13 */
static HRESULT compile_throw_statement(compiler_ctx_t *ctx, expression_statement_t *stat)
{
HRESULT hres;
hres = compile_expression(ctx, stat->expr);
if(FAILED(hres))
return hres;
return push_instr(ctx, OP_throw) == -1 ? E_OUTOFMEMORY : S_OK;
}
static HRESULT compile_statement(compiler_ctx_t *ctx, statement_t *stat)
{
switch(stat->type) {
@ -1318,6 +1330,8 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_t *stat)
return push_instr(ctx, OP_label) == -1 ? E_OUTOFMEMORY : S_OK; /* FIXME */
case STAT_SWITCH:
return compile_switch_statement(ctx, (switch_statement_t*)stat);
case STAT_THROW:
return compile_throw_statement(ctx, (expression_statement_t*)stat);
case STAT_VAR:
return compile_var_statement(ctx, (var_statement_t*)stat);
case STAT_WHILE:

View File

@ -1234,19 +1234,11 @@ HRESULT switch_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type
}
/* ECMA-262 3rd Edition 12.13 */
HRESULT throw_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
static HRESULT interp_throw(exec_ctx_t *ctx)
{
expression_statement_t *stat = (expression_statement_t*)_stat;
VARIANT val;
HRESULT hres;
TRACE("\n");
hres = expr_eval(ctx, stat->expr, &rt->ei, &val);
if(FAILED(hres))
return hres;
rt->ei.var = val;
ctx->rt->ei.var = *stack_pop(ctx);
return DISP_E_EXCEPTION;
}

View File

@ -99,6 +99,7 @@ typedef struct _func_stack {
X(rshift2, 1, 0,0) \
X(str, 1, ARG_STR, 0) \
X(this, 1, 0,0) \
X(throw, 0, 0,0) \
X(throw_ref, 0, ARG_UINT, 0) \
X(throw_type, 0, ARG_UINT, ARG_STR) \
X(tonum, 1, 0,0) \
@ -413,7 +414,6 @@ HRESULT break_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*)
HRESULT return_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT with_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT switch_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT throw_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT try_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
typedef struct {

View File

@ -847,7 +847,7 @@ static const statement_eval_t stat_eval_table[] = {
compiled_statement_eval,
return_statement_eval,
compiled_statement_eval,
throw_statement_eval,
compiled_statement_eval,
try_statement_eval,
compiled_statement_eval,
compiled_statement_eval,