diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 5b7d9d0eefc..85d38da3f71 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -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: diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index b894b44b7eb..e9dc97616f6 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -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) { diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 1e463cc9aa7..2c099e4c598 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -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;