Commit ccba279b authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Use compiler for handling expression statements.

parent 2f3e27f0
......@@ -865,11 +865,30 @@ static HRESULT compile_block_statement(compiler_ctx_t *ctx, statement_t *iter)
return S_OK;
}
/* ECMA-262 3rd Edition 12.4 */
static HRESULT compile_expression_statement(compiler_ctx_t *ctx, expression_statement_t *stat)
{
BOOL no_ret = FALSE;
HRESULT hres;
hres = compile_expression_noret(ctx, stat->expr, &no_ret);
if(FAILED(hres))
return hres;
/* FIXME: that's a big potential optimization */
if(no_ret && !push_instr(ctx, OP_undefined) == -1)
return E_OUTOFMEMORY;
return S_OK;
}
static HRESULT compile_statement(compiler_ctx_t *ctx, statement_t *stat)
{
switch(stat->type) {
case STAT_BLOCK:
return compile_block_statement(ctx, ((block_statement_t*)stat)->stat_list);
case STAT_EXPR:
return compile_expression_statement(ctx, (expression_statement_t*)stat);
default:
return compile_interp_fallback(ctx, stat);
}
......
......@@ -229,7 +229,7 @@ struct _exec_ctx_t {
unsigned top;
unsigned ip;
jsexcept_t ei;
jsexcept_t *ei;
return_type_t *rt; /* FIXME */
};
......@@ -400,7 +400,6 @@ typedef struct {
HRESULT compiled_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT var_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT empty_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT expression_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT if_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT while_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT for_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
......
......@@ -840,7 +840,7 @@ static const statement_eval_t stat_eval_table[] = {
break_statement_eval,
continue_statement_eval,
empty_statement_eval,
expression_statement_eval,
compiled_statement_eval,
for_statement_eval,
forin_statement_eval,
if_statement_eval,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment