jscript: Use bytecode for double literal.

This commit is contained in:
Jacek Caban 2011-11-23 12:14:31 +01:00 committed by Alexandre Julliard
parent e5e7803a55
commit a218e06854
3 changed files with 35 additions and 0 deletions

View file

@ -112,6 +112,24 @@ static HRESULT push_instr_str(compiler_ctx_t *ctx, jsop_t op, const WCHAR *arg)
return S_OK;
}
static HRESULT push_instr_double(compiler_ctx_t *ctx, jsop_t op, double arg)
{
unsigned instr;
DOUBLE *dbl;
dbl = compiler_alloc(ctx->code, sizeof(arg));
if(!dbl)
return E_OUTOFMEMORY;
*dbl = arg;
instr = push_instr(ctx, op);
if(instr == -1)
return E_OUTOFMEMORY;
instr_ptr(ctx, instr)->arg1.dbl = dbl;
return S_OK;
}
static HRESULT compile_binary_expression(compiler_ctx_t *ctx, binary_expression_t *expr, jsop_t op)
{
HRESULT hres;
@ -157,6 +175,8 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_expression_t *expr)
switch(literal->type) {
case LT_BOOL:
return push_instr_int(ctx, OP_bool, literal->u.bval);
case LT_DOUBLE:
return push_instr_double(ctx, OP_double, literal->u.dval);
case LT_INT:
return push_instr_int(ctx, OP_int, literal->u.lval);
case LT_STRING:

View file

@ -1747,6 +1747,19 @@ HRESULT interp_int(exec_ctx_t *ctx)
return stack_push(ctx, &v);
}
/* ECMA-262 3rd Edition 7.8.3 */
HRESULT interp_double(exec_ctx_t *ctx)
{
const double arg = *ctx->parser->code->instrs[ctx->ip].arg1.dbl;
VARIANT v;
TRACE("%lf\n", arg);
V_VT(&v) = VT_R8;
V_R8(&v) = arg;
return stack_push(ctx, &v);
}
/* ECMA-262 3rd Edition 7.8.4 */
HRESULT interp_str(exec_ctx_t *ctx)
{

View file

@ -45,6 +45,7 @@ typedef struct _func_stack {
X(add, 1, 0) \
X(bool, 1, 0) \
X(bneg, 1, 0) \
X(double, 1, 0) \
X(eq2, 1, 0) \
X(in, 1, 0) \
X(int, 1, ARG_INT) \
@ -64,6 +65,7 @@ OP_LIST
typedef union {
expression_t *expr;
double *dbl;
LONG lng;
WCHAR *str;
} instr_arg_t;