Jacek Caban : jscript: Use bytecode for double literal.

Alexandre Julliard julliard at winehq.org
Wed Nov 23 13:40:06 CST 2011


Module: wine
Branch: master
Commit: a218e0685421e3a3ec48c2bce898c5cdc12f620c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a218e0685421e3a3ec48c2bce898c5cdc12f620c

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Nov 23 12:14:31 2011 +0100

jscript: Use bytecode for double literal.

---

 dlls/jscript/compile.c |   20 ++++++++++++++++++++
 dlls/jscript/engine.c  |   13 +++++++++++++
 dlls/jscript/engine.h  |    2 ++
 3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 5b7d9d0..85d38da 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 b894b44..e9dc976 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 1e463cc..2c099e4 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;




More information about the wine-cvs mailing list