Jacek Caban : jscript: Use jsstr_t as string argument type in OP_obj_prop.

Alexandre Julliard julliard at winehq.org
Mon Mar 4 15:08:24 CST 2019


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Mar  1 17:43:52 2019 +0100

jscript: Use jsstr_t as string argument type in OP_obj_prop.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/jscript/compile.c | 39 ++++++++++++++++++++-------------------
 dlls/jscript/engine.c  |  8 ++++++--
 dlls/jscript/engine.h  |  2 +-
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 006386a..5c60ab0 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -262,6 +262,19 @@ static HRESULT push_instr_str(compiler_ctx_t *ctx, jsop_t op, const WCHAR *arg)
     return S_OK;
 }
 
+static HRESULT push_instr_str_uint(compiler_ctx_t *ctx, jsop_t op, jsstr_t *str, unsigned arg2)
+{
+    unsigned instr;
+
+    instr = push_instr(ctx, op);
+    if(!instr)
+        return E_OUTOFMEMORY;
+
+    instr_ptr(ctx, instr)->u.arg[0].str = str;
+    instr_ptr(ctx, instr)->u.arg[1].uint = arg2;
+    return S_OK;
+}
+
 static HRESULT push_instr_bstr(compiler_ctx_t *ctx, jsop_t op, const WCHAR *arg)
 {
     unsigned instr;
@@ -833,26 +846,14 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_t *literal)
     return E_FAIL;
 }
 
-static HRESULT literal_as_bstr(compiler_ctx_t *ctx, literal_t *literal, BSTR *str)
+static HRESULT literal_as_string(compiler_ctx_t *ctx, literal_t *literal, jsstr_t **str)
 {
     switch(literal->type) {
     case LT_STRING:
-        *str = compiler_alloc_bstr(ctx, literal->u.wstr);
+        *str = compiler_alloc_string(ctx, literal->u.wstr);
         break;
-    case LT_DOUBLE: {
-        jsstr_t *jsstr;
-        HRESULT hres;
-
-        hres = double_to_string(literal->u.dval, &jsstr);
-        if(FAILED(hres))
-            return hres;
-
-        *str = compiler_alloc_bstr_len(ctx, NULL, jsstr_length(jsstr));
-        if(*str)
-            jsstr_flush(jsstr, *str);
-        jsstr_release(jsstr);
-        break;
-    }
+    case LT_DOUBLE:
+        return double_to_string(literal->u.dval, str);
     DEFAULT_UNREACHABLE;
     }
 
@@ -889,14 +890,14 @@ static HRESULT compile_array_literal(compiler_ctx_t *ctx, array_literal_expressi
 static HRESULT compile_object_literal(compiler_ctx_t *ctx, property_value_expression_t *expr)
 {
     property_definition_t *iter;
-    BSTR name;
+    jsstr_t *name;
     HRESULT hres;
 
     if(!push_instr(ctx, OP_new_obj))
         return E_OUTOFMEMORY;
 
     for(iter = expr->property_list; iter; iter = iter->next) {
-        hres = literal_as_bstr(ctx, iter->name, &name);
+        hres = literal_as_string(ctx, iter->name, &name);
         if(FAILED(hres))
             return hres;
 
@@ -904,7 +905,7 @@ static HRESULT compile_object_literal(compiler_ctx_t *ctx, property_value_expres
         if(FAILED(hres))
             return hres;
 
-        hres = push_instr_bstr_uint(ctx, OP_obj_prop, name, iter->type);
+        hres = push_instr_str_uint(ctx, OP_obj_prop, name, iter->type);
         if(FAILED(hres))
             return hres;
     }
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 0f9e3a5..c71ac07 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1444,16 +1444,20 @@ static HRESULT interp_new_obj(script_ctx_t *ctx)
 /* ECMA-262 3rd Edition    11.1.5 */
 static HRESULT interp_obj_prop(script_ctx_t *ctx)
 {
-    const BSTR name = get_op_bstr(ctx, 0);
+    jsstr_t *name_arg = get_op_str(ctx, 0);
     unsigned type = get_op_uint(ctx, 1);
+    const WCHAR *name;
     jsdisp_t *obj;
     jsval_t val;
     HRESULT hres;
 
-    TRACE("%s\n", debugstr_w(name));
+    TRACE("%s\n", debugstr_jsstr(name_arg));
 
     val = stack_pop(ctx);
 
+    /* FIXME: we should pass it as jsstr_t */
+    name = jsstr_flatten(name_arg);
+
     assert(is_object_instance(stack_top(ctx)));
     obj = as_jsdisp(get_object(stack_top(ctx)));
 
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index eb287d5..a3b598e 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -66,7 +66,7 @@
     X(new,        1, ARG_UINT,   0)        \
     X(new_obj,    1, 0,0)                  \
     X(null,       1, 0,0)                  \
-    X(obj_prop,   1, ARG_BSTR,   ARG_UINT) \
+    X(obj_prop,   1, ARG_STR,    ARG_UINT) \
     X(or,         1, 0,0)                  \
     X(pop,        1, ARG_UINT,   0)        \
     X(pop_except, 0, ARG_ADDR,   0)        \




More information about the wine-cvs mailing list