jscript: Use bytecode for bool literal implementation.

This commit is contained in:
Jacek Caban 2011-11-23 12:13:57 +01:00 committed by Alexandre Julliard
parent b3feafab41
commit 13d96df4bd
3 changed files with 13 additions and 0 deletions

View File

@ -121,6 +121,8 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_expression_t *expr)
literal_t *literal = expr->literal; literal_t *literal = expr->literal;
switch(literal->type) { switch(literal->type) {
case LT_BOOL:
return push_instr_int(ctx, OP_bool, literal->u.bval);
case LT_INT: case LT_INT:
return push_instr_int(ctx, OP_int, literal->u.lval); return push_instr_int(ctx, OP_int, literal->u.lval);
default: default:

View File

@ -1724,6 +1724,16 @@ HRESULT identifier_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD
return hres; return hres;
} }
/* ECMA-262 3rd Edition 7.8.2 */
HRESULT interp_bool(exec_ctx_t *ctx)
{
const LONG arg = ctx->parser->code->instrs[ctx->ip].arg1.lng;
TRACE("%s\n", arg ? "true" : "false");
return stack_push_bool(ctx, arg);
}
/* ECMA-262 3rd Edition 7.8.3 */ /* ECMA-262 3rd Edition 7.8.3 */
HRESULT interp_int(exec_ctx_t *ctx) HRESULT interp_int(exec_ctx_t *ctx)
{ {

View File

@ -43,6 +43,7 @@ typedef struct _func_stack {
#define OP_LIST \ #define OP_LIST \
X(add, 1, 0) \ X(add, 1, 0) \
X(bool, 1, 0) \
X(bneg, 1, 0) \ X(bneg, 1, 0) \
X(eq2, 1, 0) \ X(eq2, 1, 0) \
X(in, 1, 0) \ X(in, 1, 0) \