jscript: Always use bytecode for switch statement.
This commit is contained in:
parent
f904bc8e78
commit
985c6a1943
|
@ -1327,11 +1327,8 @@ static HRESULT compile_switch_statement(compiler_ctx_t *ctx, switch_statement_t
|
||||||
BOOL have_default = FALSE;
|
BOOL have_default = FALSE;
|
||||||
statement_t *stat_iter;
|
statement_t *stat_iter;
|
||||||
case_clausule_t *iter;
|
case_clausule_t *iter;
|
||||||
unsigned off_backup;
|
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
off_backup = ctx->code_off;
|
|
||||||
|
|
||||||
hres = compile_expression(ctx, stat->expr);
|
hres = compile_expression(ctx, stat->expr);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
@ -1394,11 +1391,6 @@ static HRESULT compile_switch_statement(compiler_ctx_t *ctx, switch_statement_t
|
||||||
|
|
||||||
for(stat_iter = iter->stat; stat_iter && (!iter->next || iter->next->stat != stat_iter); stat_iter = stat_iter->next) {
|
for(stat_iter = iter->stat; stat_iter && (!iter->next || iter->next->stat != stat_iter); stat_iter = stat_iter->next) {
|
||||||
hres = compile_statement(ctx, &stat_ctx, stat_iter);
|
hres = compile_statement(ctx, &stat_ctx, stat_iter);
|
||||||
if(hres == E_NOTIMPL) {
|
|
||||||
ctx->code_off = off_backup;
|
|
||||||
stat->stat.eval = switch_statement_eval;
|
|
||||||
return compile_interp_fallback(ctx, &stat->stat);
|
|
||||||
}
|
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -915,74 +915,6 @@ static HRESULT interp_case(exec_ctx_t *ctx)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ECMA-262 3rd Edition 12.13 */
|
|
||||||
HRESULT switch_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
|
|
||||||
{
|
|
||||||
switch_statement_t *stat = (switch_statement_t*)_stat;
|
|
||||||
case_clausule_t *iter, *default_clausule = NULL;
|
|
||||||
statement_t *stat_iter;
|
|
||||||
VARIANT val, cval;
|
|
||||||
BOOL b;
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
TRACE("\n");
|
|
||||||
|
|
||||||
hres = expr_eval(ctx, stat->expr, &rt->ei, &val);
|
|
||||||
if(FAILED(hres))
|
|
||||||
return hres;
|
|
||||||
|
|
||||||
for(iter = stat->case_list; iter; iter = iter->next) {
|
|
||||||
if(!iter->expr) {
|
|
||||||
default_clausule = iter;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
hres = expr_eval(ctx, iter->expr, &rt->ei, &cval);
|
|
||||||
if(FAILED(hres))
|
|
||||||
break;
|
|
||||||
|
|
||||||
hres = equal2_values(&val, &cval, &b);
|
|
||||||
VariantClear(&cval);
|
|
||||||
if(FAILED(hres) || b)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
VariantClear(&val);
|
|
||||||
if(FAILED(hres))
|
|
||||||
return hres;
|
|
||||||
|
|
||||||
if(!iter)
|
|
||||||
iter = default_clausule;
|
|
||||||
|
|
||||||
V_VT(&val) = VT_EMPTY;
|
|
||||||
if(iter) {
|
|
||||||
VARIANT tmp;
|
|
||||||
|
|
||||||
for(stat_iter = iter->stat; stat_iter; stat_iter = stat_iter->next) {
|
|
||||||
hres = stat_eval(ctx, stat_iter, rt, &tmp);
|
|
||||||
if(FAILED(hres))
|
|
||||||
break;
|
|
||||||
|
|
||||||
VariantClear(&val);
|
|
||||||
val = tmp;
|
|
||||||
|
|
||||||
if(rt->type != RT_NORMAL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(FAILED(hres)) {
|
|
||||||
VariantClear(&val);
|
|
||||||
return hres;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rt->type == RT_BREAK)
|
|
||||||
rt->type = RT_NORMAL;
|
|
||||||
|
|
||||||
*ret = val;
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ECMA-262 3rd Edition 12.13 */
|
/* ECMA-262 3rd Edition 12.13 */
|
||||||
static HRESULT interp_throw(exec_ctx_t *ctx)
|
static HRESULT interp_throw(exec_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
|
|
|
@ -417,7 +417,6 @@ HRESULT while_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*)
|
||||||
HRESULT continue_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 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;
|
HRESULT return_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 try_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 {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in New Issue