jscript: Don't leave current scope in return statement before evaluating the expression.
This commit is contained in:
parent
dd8f54a49f
commit
fdbd536983
|
@ -1287,25 +1287,30 @@ static HRESULT compile_forin_statement(compiler_ctx_t *ctx, forin_statement_t *s
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT pop_to_stat(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx)
|
static HRESULT pop_to_stat(compiler_ctx_t *ctx, BOOL var_stack, BOOL scope_stack, statement_ctx_t *stat_ctx)
|
||||||
{
|
{
|
||||||
unsigned stack_pop = 0;
|
unsigned stack_pop = 0;
|
||||||
statement_ctx_t *iter;
|
statement_ctx_t *iter;
|
||||||
|
|
||||||
for(iter = ctx->stat_ctx; iter != stat_ctx; iter = iter->next) {
|
for(iter = ctx->stat_ctx; iter != stat_ctx; iter = iter->next) {
|
||||||
if(iter->using_scope && !push_instr(ctx, OP_pop_scope))
|
if(scope_stack) {
|
||||||
return E_OUTOFMEMORY;
|
if(iter->using_scope && !push_instr(ctx, OP_pop_scope))
|
||||||
if(iter->using_except && !push_instr(ctx, OP_pop_except))
|
return E_OUTOFMEMORY;
|
||||||
return E_OUTOFMEMORY;
|
if(iter->using_except && !push_instr(ctx, OP_pop_except))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
stack_pop += iter->stack_use;
|
stack_pop += iter->stack_use;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: optimize */
|
if(var_stack) {
|
||||||
while(stack_pop--) {
|
/* FIXME: optimize */
|
||||||
if(!push_instr(ctx, OP_pop))
|
while(stack_pop--) {
|
||||||
return E_OUTOFMEMORY;
|
if(!push_instr(ctx, OP_pop))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,7 +1358,7 @@ static HRESULT compile_continue_statement(compiler_ctx_t *ctx, branch_statement_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = pop_to_stat(ctx, pop_ctx);
|
hres = pop_to_stat(ctx, TRUE, TRUE, pop_ctx);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
@ -1393,7 +1398,7 @@ static HRESULT compile_break_statement(compiler_ctx_t *ctx, branch_statement_t *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = pop_to_stat(ctx, pop_ctx->next);
|
hres = pop_to_stat(ctx, TRUE, TRUE, pop_ctx->next);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
@ -1408,7 +1413,7 @@ static HRESULT compile_return_statement(compiler_ctx_t *ctx, expression_statemen
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
hres = pop_to_stat(ctx, NULL);
|
hres = pop_to_stat(ctx, TRUE, FALSE, NULL);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
@ -1418,6 +1423,10 @@ static HRESULT compile_return_statement(compiler_ctx_t *ctx, expression_statemen
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hres = pop_to_stat(ctx, FALSE, TRUE, NULL);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return hres;
|
||||||
|
|
||||||
return push_instr(ctx, OP_ret) ? S_OK : E_OUTOFMEMORY;
|
return push_instr(ctx, OP_ret) ? S_OK : E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1355,6 +1355,13 @@ ok(name_override_func === 3, "name_override_func = " + name_override_func);
|
||||||
function name_override_func() {};
|
function name_override_func() {};
|
||||||
ok(name_override_func === 3, "name_override_func = " + name_override_func);
|
ok(name_override_func === 3, "name_override_func = " + name_override_func);
|
||||||
|
|
||||||
|
tmp = (function() {
|
||||||
|
var ret = false;
|
||||||
|
with({ret: true})
|
||||||
|
return ret;
|
||||||
|
})();
|
||||||
|
ok(tmp, "tmp = " + tmp);
|
||||||
|
|
||||||
/* NoNewline rule parser tests */
|
/* NoNewline rule parser tests */
|
||||||
while(true) {
|
while(true) {
|
||||||
if(true) break
|
if(true) break
|
||||||
|
|
Loading…
Reference in New Issue