jscript: Use bytecode for double literal.
This commit is contained in:
parent
e5e7803a55
commit
a218e06854
|
@ -112,6 +112,24 @@ static HRESULT push_instr_str(compiler_ctx_t *ctx, jsop_t op, const WCHAR *arg)
|
||||||
return S_OK;
|
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)
|
static HRESULT compile_binary_expression(compiler_ctx_t *ctx, binary_expression_t *expr, jsop_t op)
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
@ -157,6 +175,8 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_expression_t *expr)
|
||||||
switch(literal->type) {
|
switch(literal->type) {
|
||||||
case LT_BOOL:
|
case LT_BOOL:
|
||||||
return push_instr_int(ctx, OP_bool, literal->u.bval);
|
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:
|
case LT_INT:
|
||||||
return push_instr_int(ctx, OP_int, literal->u.lval);
|
return push_instr_int(ctx, OP_int, literal->u.lval);
|
||||||
case LT_STRING:
|
case LT_STRING:
|
||||||
|
|
|
@ -1747,6 +1747,19 @@ HRESULT interp_int(exec_ctx_t *ctx)
|
||||||
return stack_push(ctx, &v);
|
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 */
|
/* ECMA-262 3rd Edition 7.8.4 */
|
||||||
HRESULT interp_str(exec_ctx_t *ctx)
|
HRESULT interp_str(exec_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,6 +45,7 @@ typedef struct _func_stack {
|
||||||
X(add, 1, 0) \
|
X(add, 1, 0) \
|
||||||
X(bool, 1, 0) \
|
X(bool, 1, 0) \
|
||||||
X(bneg, 1, 0) \
|
X(bneg, 1, 0) \
|
||||||
|
X(double, 1, 0) \
|
||||||
X(eq2, 1, 0) \
|
X(eq2, 1, 0) \
|
||||||
X(in, 1, 0) \
|
X(in, 1, 0) \
|
||||||
X(int, 1, ARG_INT) \
|
X(int, 1, ARG_INT) \
|
||||||
|
@ -64,6 +65,7 @@ OP_LIST
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
expression_t *expr;
|
expression_t *expr;
|
||||||
|
double *dbl;
|
||||||
LONG lng;
|
LONG lng;
|
||||||
WCHAR *str;
|
WCHAR *str;
|
||||||
} instr_arg_t;
|
} instr_arg_t;
|
||||||
|
|
Loading…
Reference in New Issue