diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 36334930d03..ceed2288de8 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -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)) diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 80486b8f8ea..9f4a5a7d4da 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -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"); diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 3e58db21ad3..2f0ba538f1c 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -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) \