jscript: Use bytecode for execution main code block in exec_source.

This commit is contained in:
Jacek Caban 2011-12-19 14:59:12 +01:00 committed by Alexandre Julliard
parent f6023c428a
commit 2f3e27f09a
3 changed files with 13 additions and 15 deletions

View File

@ -931,7 +931,7 @@ HRESULT compile_subscript(parser_ctx_t *parser, expression_t *expr, BOOL do_ret,
return push_instr(parser->compiler, OP_ret) == -1 ? E_OUTOFMEMORY : S_OK;
}
HRESULT compile_subscript_stat(parser_ctx_t *parser, statement_t *stat, unsigned *ret_off)
HRESULT compile_subscript_stat(parser_ctx_t *parser, statement_t *stat, BOOL compile_block, unsigned *ret_off)
{
HRESULT hres;
@ -942,7 +942,10 @@ HRESULT compile_subscript_stat(parser_ctx_t *parser, statement_t *stat, unsigned
return hres;
*ret_off = parser->compiler->code_off;
hres = compile_statement(parser->compiler, stat);
if(compile_block && stat->next)
hres = compile_block_statement(parser->compiler, stat);
else
hres = compile_statement(parser->compiler, stat);
if(FAILED(hres))
return hres;

View File

@ -513,8 +513,7 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so
function_declaration_t *func;
parser_ctx_t *prev_parser;
var_list_t *var;
VARIANT val, tmp;
statement_t *stat;
VARIANT val;
exec_ctx_t *prev_ctx;
return_type_t rt;
HRESULT hres = S_OK;
@ -560,15 +559,11 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so
memset(&rt, 0, sizeof(rt));
rt.type = RT_NORMAL;
for(stat = source->statement; stat; stat = stat->next) {
hres = stat_eval(script, stat, &rt, &tmp);
if(FAILED(hres))
break;
VariantClear(&val);
val = tmp;
if(rt.type != RT_NORMAL)
break;
if(source->statement) {
if(source->statement->instr_off == -1)
hres = compile_subscript_stat(ctx->parser, source->statement, TRUE, &source->statement->instr_off);
if(SUCCEEDED(hres))
hres = compiled_statement_eval(script, source->statement, &rt, &val);
}
script->exec_ctx = prev_ctx;
@ -3005,7 +3000,7 @@ HRESULT compiled_statement_eval(script_ctx_t *ctx, statement_t *stat, return_typ
TRACE("\n");
if(stat->instr_off == -1) {
hres = compile_subscript_stat(exec_ctx->parser, stat, &stat->instr_off);
hres = compile_subscript_stat(exec_ctx->parser, stat, FALSE, &stat->instr_off);
if(FAILED(hres))
return hres;
}

View File

@ -590,4 +590,4 @@ typedef struct {
} property_value_expression_t;
HRESULT compile_subscript(parser_ctx_t*,expression_t*,BOOL,unsigned*) DECLSPEC_HIDDEN;
HRESULT compile_subscript_stat(parser_ctx_t*,statement_t*,unsigned*) DECLSPEC_HIDDEN;
HRESULT compile_subscript_stat(parser_ctx_t*,statement_t*,BOOL,unsigned*) DECLSPEC_HIDDEN;