jscript: Added new jmp_z opcode, more appropriate for branches.

oldstable
Jacek Caban 2011-12-20 11:47:37 +01:00 committed by Alexandre Julliard
parent e5d7d50faa
commit 95677c5099
3 changed files with 24 additions and 4 deletions

View File

@ -915,7 +915,7 @@ static HRESULT compile_if_statement(compiler_ctx_t *ctx, if_statement_t *stat)
if(FAILED(hres))
return hres;
jmp_else = push_instr(ctx, OP_cnd_z);
jmp_else = push_instr(ctx, OP_jmp_z);
if(jmp_else == -1)
return E_OUTOFMEMORY;
@ -929,9 +929,6 @@ static HRESULT compile_if_statement(compiler_ctx_t *ctx, if_statement_t *stat)
instr_ptr(ctx, jmp_else)->arg1.uint = ctx->code_off;
if(push_instr(ctx, OP_pop) == -1)
return E_OUTOFMEMORY;
if(stat->else_stat) {
hres = compile_statement(ctx, stat->else_stat);
if(FAILED(hres))

View File

@ -2884,6 +2884,28 @@ static HRESULT interp_jmp(exec_ctx_t *ctx)
return S_OK;
}
static HRESULT interp_jmp_z(exec_ctx_t *ctx)
{
const unsigned arg = ctx->parser->code->instrs[ctx->ip].arg1.uint;
VARIANT_BOOL b;
VARIANT *v;
HRESULT hres;
TRACE("\n");
v = stack_pop(ctx);
hres = to_boolean(v, &b);
VariantClear(v);
if(FAILED(hres))
return hres;
if(b)
ctx->ip++;
else
ctx->ip = arg;
return S_OK;
}
static HRESULT interp_pop(exec_ctx_t *ctx)
{
TRACE("\n");

View File

@ -69,6 +69,7 @@ typedef struct _func_stack {
X(instanceof, 1, 0,0) \
X(int, 1, ARG_INT, 0) \
X(jmp, 0, ARG_ADDR, 0) \
X(jmp_z, 0, ARG_ADDR, 0) \
X(lshift, 1, 0,0) \
X(lt, 1, 0,0) \
X(lteq, 1, 0,0) \