jscript: Avoid using dispex->ctx.
diff --git a/dlls/jscript/bool.c b/dlls/jscript/bool.c
index 76747bd..998c5d2 100644
--- a/dlls/jscript/bool.c
+++ b/dlls/jscript/bool.c
@@ -42,7 +42,7 @@
     TRACE("\n");
 
     if(!is_class(dispex, JSCLASS_BOOLEAN))
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_BOOL, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_BOOL, NULL);
 
     if(retv) {
         BoolInstance *bool = (BoolInstance*)dispex;
@@ -68,7 +68,7 @@
     TRACE("\n");
 
     if(!is_class(dispex, JSCLASS_BOOLEAN))
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_BOOL, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_BOOL, NULL);
 
     if(retv) {
         BoolInstance *bool = (BoolInstance*)dispex;
@@ -87,7 +87,7 @@
 
     switch(flags) {
     case INVOKE_FUNC:
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_FUNC, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_FUNC, NULL);
     default:
         FIXME("unimplemented flags %x\n", flags);
         return E_NOTIMPL;
@@ -127,7 +127,7 @@
     case DISPATCH_CONSTRUCT: {
         DispatchEx *bool;
 
-        hres = create_bool(dispex->ctx, value, &bool);
+        hres = create_bool(ctx, value, &bool);
         if(FAILED(hres))
             return hres;
 
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 1759994..a3007fc 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1583,14 +1583,14 @@
                 hres = disp_call(ctx->parser->script, V_DISPATCH(&exprval.u.var), DISPID_VALUE,
                         DISPATCH_METHOD, &dp, flags & EXPR_NOVAL ? NULL : &var, ei, NULL/*FIXME*/);
             else
-                hres = throw_type_error(ctx->var_disp->ctx, ei, IDS_NO_PROPERTY, NULL);
+                hres = throw_type_error(ctx->parser->script, ei, IDS_NO_PROPERTY, NULL);
             break;
         case EXPRVAL_IDREF:
             hres = disp_call(ctx->parser->script, exprval.u.idref.disp, exprval.u.idref.id,
                     DISPATCH_METHOD, &dp, flags & EXPR_NOVAL ? NULL : &var, ei, NULL/*FIXME*/);
             break;
         case EXPRVAL_INVALID:
-            hres = throw_type_error(ctx->var_disp->ctx, ei, IDS_OBJECT_EXPECTED, NULL);
+            hres = throw_type_error(ctx->parser->script, ei, IDS_OBJECT_EXPECTED, NULL);
             break;
         default:
             FIXME("unimplemented type %d\n", exprval.type);
diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c
index c749f2b..5932611 100644
--- a/dlls/jscript/error.c
+++ b/dlls/jscript/error.c
@@ -119,7 +119,7 @@
 
     switch(flags) {
     case INVOKE_FUNC:
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_FUNC, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_FUNC, NULL);
     default:
         FIXME("unimplemented flags %x\n", flags);
         return E_NOTIMPL;
@@ -223,7 +223,7 @@
     return S_OK;
 }
 
-static HRESULT error_constr(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
+static HRESULT error_constr(script_ctx_t *ctx, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, DispatchEx *constr) {
     DispatchEx *err;
     VARIANT numv;
@@ -234,9 +234,9 @@
     V_VT(&numv) = VT_NULL;
 
     if(arg_cnt(dp)) {
-        hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &numv);
+        hres = to_number(ctx, get_arg(dp, 0), ei, &numv);
         if(FAILED(hres) || (V_VT(&numv)==VT_R8 && isnan(V_R8(&numv))))
-            hres = to_string(dispex->ctx, get_arg(dp, 0), ei, &msg);
+            hres = to_string(ctx, get_arg(dp, 0), ei, &msg);
         else if(V_VT(&numv) == VT_I4)
             num = V_I4(&numv);
         else
@@ -247,7 +247,7 @@
     }
 
     if(arg_cnt(dp)>1 && !msg) {
-        hres = to_string(dispex->ctx, get_arg(dp, 1), ei, &msg);
+        hres = to_string(ctx, get_arg(dp, 1), ei, &msg);
         if(FAILED(hres))
             return hres;
     }
@@ -256,9 +256,9 @@
     case INVOKE_FUNC:
     case DISPATCH_CONSTRUCT:
         if(V_VT(&numv) == VT_NULL)
-            hres = create_error(dispex->ctx, constr, NULL, msg, &err);
+            hres = create_error(ctx, constr, NULL, msg, &err);
         else
-            hres = create_error(dispex->ctx, constr, &num, msg, &err);
+            hres = create_error(ctx, constr, &num, msg, &err);
 
         if(FAILED(hres))
             return hres;
@@ -282,64 +282,56 @@
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     TRACE("\n");
-    return error_constr(dispex, flags, dp, retv, ei,
-            dispex->ctx->error_constr);
+    return error_constr(ctx, flags, dp, retv, ei, ctx->error_constr);
 }
 
 static HRESULT EvalErrorConstr_value(script_ctx_t *ctx, DispatchEx *dispex, WORD flags,
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     TRACE("\n");
-    return error_constr(dispex, flags, dp, retv, ei,
-            dispex->ctx->eval_error_constr);
+    return error_constr(ctx, flags, dp, retv, ei, ctx->eval_error_constr);
 }
 
 static HRESULT RangeErrorConstr_value(script_ctx_t *ctx, DispatchEx *dispex, WORD flags,
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     TRACE("\n");
-    return error_constr(dispex, flags, dp, retv, ei,
-            dispex->ctx->range_error_constr);
+    return error_constr(ctx, flags, dp, retv, ei, ctx->range_error_constr);
 }
 
 static HRESULT ReferenceErrorConstr_value(script_ctx_t *ctx, DispatchEx *dispex, WORD flags,
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     TRACE("\n");
-    return error_constr(dispex, flags, dp, retv, ei,
-            dispex->ctx->reference_error_constr);
+    return error_constr(ctx, flags, dp, retv, ei, ctx->reference_error_constr);
 }
 
 static HRESULT RegExpErrorConstr_value(script_ctx_t *ctx, DispatchEx *dispex, WORD flags,
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     TRACE("\n");
-    return error_constr(dispex, flags, dp, retv, ei,
-            dispex->ctx->regexp_error_constr);
+    return error_constr(ctx, flags, dp, retv, ei, ctx->regexp_error_constr);
 }
 
 static HRESULT SyntaxErrorConstr_value(script_ctx_t *ctx, DispatchEx *dispex, WORD flags,
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     TRACE("\n");
-    return error_constr(dispex, flags, dp, retv, ei,
-            dispex->ctx->syntax_error_constr);
+    return error_constr(ctx, flags, dp, retv, ei, ctx->syntax_error_constr);
 }
 
 static HRESULT TypeErrorConstr_value(script_ctx_t *ctx, DispatchEx *dispex, WORD flags,
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     TRACE("\n");
-    return error_constr(dispex, flags, dp, retv, ei,
-            dispex->ctx->type_error_constr);
+    return error_constr(ctx, flags, dp, retv, ei, ctx->type_error_constr);
 }
 
 static HRESULT URIErrorConstr_value(script_ctx_t *ctx, DispatchEx *dispex, WORD flags,
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     TRACE("\n");
-    return error_constr(dispex, flags, dp, retv, ei,
-            dispex->ctx->uri_error_constr);
+    return error_constr(ctx, flags, dp, retv, ei, ctx->uri_error_constr);
 }
 
 HRESULT init_error_constr(script_ctx_t *ctx, DispatchEx *object_prototype)
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index 2264986..9c9deea 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -156,7 +156,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->array_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->array_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_Boolean(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -164,7 +164,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->bool_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->bool_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_Date(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -172,7 +172,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->date_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->date_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_Error(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -180,7 +180,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->error_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->error_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_EvalError(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -188,7 +188,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->eval_error_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->eval_error_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_RangeError(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -196,7 +196,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->range_error_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->range_error_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_ReferenceError(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -204,7 +204,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->reference_error_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->reference_error_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_SyntaxError(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -212,7 +212,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->syntax_error_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->syntax_error_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_TypeError(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -220,7 +220,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->type_error_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->type_error_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_URIError(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -228,7 +228,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->uri_error_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->uri_error_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_Function(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -236,7 +236,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->function_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->function_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_Number(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -244,7 +244,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->number_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->number_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_Object(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -252,7 +252,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->object_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->object_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_String(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -260,7 +260,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->string_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->string_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_RegExp(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -268,7 +268,7 @@
 {
     TRACE("\n");
 
-    return constructor_call(dispex->ctx->regexp_constr, flags, dp, retv, ei, sp);
+    return constructor_call(ctx->regexp_constr, flags, dp, retv, ei, sp);
 }
 
 static HRESULT JSGlobal_ActiveXObject(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -324,19 +324,19 @@
         return S_OK;
     }
 
-    if(!dispex->ctx->exec_ctx) {
+    if(!ctx->exec_ctx) {
         FIXME("No active exec_ctx\n");
         return E_UNEXPECTED;
     }
 
     TRACE("parsing %s\n", debugstr_w(V_BSTR(arg)));
-    hres = script_parse(dispex->ctx, V_BSTR(arg), NULL, &parser_ctx);
+    hres = script_parse(ctx, V_BSTR(arg), NULL, &parser_ctx);
     if(FAILED(hres)) {
         WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(arg)), hres);
-        return throw_syntax_error(dispex->ctx, ei, hres, NULL);
+        return throw_syntax_error(ctx, ei, hres, NULL);
     }
 
-    hres = exec_source(dispex->ctx->exec_ctx, parser_ctx, parser_ctx->source, ei, retv);
+    hres = exec_source(ctx->exec_ctx, parser_ctx, parser_ctx->source, ei, retv);
     parser_release(parser_ctx);
 
     return hres;
@@ -352,7 +352,7 @@
     TRACE("\n");
 
     if(arg_cnt(dp)) {
-        hres = to_number(dispex->ctx, get_arg(dp,0), ei, &num);
+        hres = to_number(ctx, get_arg(dp,0), ei, &num);
         if(FAILED(hres))
             return hres;
 
@@ -380,7 +380,7 @@
     if(arg_cnt(dp)) {
         VARIANT num;
 
-        hres = to_number(dispex->ctx, get_arg(dp,0), ei, &num);
+        hres = to_number(ctx, get_arg(dp,0), ei, &num);
         if(FAILED(hres))
             return hres;
 
@@ -422,7 +422,7 @@
     }
 
     if(arg_cnt(dp) >= 2) {
-        hres = to_int32(dispex->ctx, get_arg(dp, 1), ei, &radix);
+        hres = to_int32(ctx, get_arg(dp, 1), ei, &radix);
         if(FAILED(hres))
             return hres;
 
@@ -434,7 +434,7 @@
         }
     }
 
-    hres = to_string(dispex->ctx, get_arg(dp, 0), ei, &str);
+    hres = to_string(ctx, get_arg(dp, 0), ei, &str);
     if(FAILED(hres))
         return hres;
 
@@ -492,7 +492,7 @@
     }
 
     arg = get_arg(dp, 0);
-    hres = to_string(dispex->ctx, arg, ei, &val_str);
+    hres = to_string(ctx, arg, ei, &val_str);
     if(FAILED(hres))
         return hres;
 
@@ -605,7 +605,7 @@
         return S_OK;
     }
 
-    hres = to_string(dispex->ctx, get_arg(dp, 0), ei, &str);
+    hres = to_string(ctx, get_arg(dp, 0), ei, &str);
     if(FAILED(hres))
         return hres;
 
@@ -724,7 +724,7 @@
         return S_OK;
     }
 
-    hres = to_string(dispex->ctx, get_arg(dp,0), ei, &str);
+    hres = to_string(ctx, get_arg(dp,0), ei, &str);
     if(FAILED(hres))
         return hres;
 
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 9365ce9..c817821 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -244,9 +244,9 @@
     DWORD len;
 } match_result_t;
 
-HRESULT regexp_match_next(DispatchEx*,BOOL,const WCHAR*,DWORD,const WCHAR**,match_result_t**,
+HRESULT regexp_match_next(script_ctx_t*,DispatchEx*,BOOL,const WCHAR*,DWORD,const WCHAR**,match_result_t**,
         DWORD*,DWORD*,match_result_t*);
-HRESULT regexp_match(DispatchEx*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*);
+HRESULT regexp_match(script_ctx_t*,DispatchEx*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*);
 
 static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i)
 {
diff --git a/dlls/jscript/math.c b/dlls/jscript/math.c
index e89f08b..a0a75af 100644
--- a/dlls/jscript/math.c
+++ b/dlls/jscript/math.c
@@ -148,7 +148,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -171,7 +171,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -192,7 +192,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -213,7 +213,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -234,11 +234,11 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v1);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v1);
     if(FAILED(hres))
         return hres;
 
-    hres = to_number(dispex->ctx, get_arg(dp, 1), ei, &v2);
+    hres = to_number(ctx, get_arg(dp, 1), ei, &v2);
     if(FAILED(hres))
         return hres;
 
@@ -261,7 +261,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -283,7 +283,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -304,7 +304,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -326,7 +326,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -349,7 +349,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -375,13 +375,13 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
     max = num_val(&v);
     for(i=1; i < arg_cnt(dp); i++) {
-        hres = to_number(dispex->ctx, get_arg(dp, i), ei, &v);
+        hres = to_number(ctx, get_arg(dp, i), ei, &v);
         if(FAILED(hres))
             return hres;
 
@@ -412,13 +412,13 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
     min = num_val(&v);
     for(i=1; i < arg_cnt(dp); i++) {
-        hres = to_number(dispex->ctx, get_arg(dp, i), ei, &v);
+        hres = to_number(ctx, get_arg(dp, i), ei, &v);
         if(FAILED(hres))
             return hres;
 
@@ -446,11 +446,11 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &x);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &x);
     if(FAILED(hres))
         return hres;
 
-    hres = to_number(dispex->ctx, get_arg(dp, 1), ei, &y);
+    hres = to_number(ctx, get_arg(dp, 1), ei, &y);
     if(FAILED(hres))
         return hres;
 
@@ -490,7 +490,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -512,7 +512,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -533,7 +533,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
@@ -554,7 +554,7 @@
         return S_OK;
     }
 
-    hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v);
+    hres = to_number(ctx, get_arg(dp, 0), ei, &v);
     if(FAILED(hres))
         return hres;
 
diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c
index 45c1320..921b9e5 100644
--- a/dlls/jscript/number.c
+++ b/dlls/jscript/number.c
@@ -54,17 +54,17 @@
     TRACE("\n");
 
     if(!is_class(dispex, JSCLASS_NUMBER))
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_NUM, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_NUM, NULL);
 
     number = (NumberInstance*)dispex;
 
     if(arg_cnt(dp)) {
-        hres = to_int32(dispex->ctx, get_arg(dp, 0), ei, &radix);
+        hres = to_int32(ctx, get_arg(dp, 0), ei, &radix);
         if(FAILED(hres))
             return hres;
 
         if(radix<2 || radix>36)
-            return throw_type_error(dispex->ctx, ei, IDS_INVALID_CALL_ARG, NULL);
+            return throw_type_error(ctx, ei, IDS_INVALID_CALL_ARG, NULL);
     }
 
     if(V_VT(&number->num) == VT_I4)
@@ -73,7 +73,7 @@
         val = V_R8(&number->num);
 
     if(radix==10 || isnan(val) || isinf(val)) {
-        hres = to_string(dispex->ctx, &number->num, ei, &str);
+        hres = to_string(ctx, &number->num, ei, &str);
         if(FAILED(hres))
             return hres;
     }
@@ -204,7 +204,7 @@
     TRACE("\n");
 
     if(!is_class(dispex, JSCLASS_NUMBER))
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_NUM, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_NUM, NULL);
 
     if(retv) {
         NumberInstance *number = (NumberInstance*)dispex;
@@ -220,7 +220,7 @@
 
     switch(flags) {
     case INVOKE_FUNC:
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_FUNC, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_FUNC, NULL);
     case DISPATCH_PROPERTYGET:
         *retv = number->num;
         break;
@@ -269,7 +269,7 @@
             return S_OK;
         }
 
-        hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &num);
+        hres = to_number(ctx, get_arg(dp, 0), ei, &num);
         if(FAILED(hres))
             return hres;
 
@@ -281,7 +281,7 @@
         DispatchEx *obj;
 
         if(arg_cnt(dp)) {
-            hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &num);
+            hres = to_number(ctx, get_arg(dp, 0), ei, &num);
             if(FAILED(hres))
                 return hres;
         }else {
@@ -289,7 +289,7 @@
             V_I4(&num) = 0;
         }
 
-        hres = create_number(dispex->ctx, &num, &obj);
+        hres = create_number(ctx, &num, &obj);
         if(FAILED(hres))
             return hres;
 
diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c
index 993a89f..2ceaf09 100644
--- a/dlls/jscript/object.c
+++ b/dlls/jscript/object.c
@@ -124,7 +124,7 @@
 
     switch(flags) {
     case INVOKE_FUNC:
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_FUNC, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_FUNC, NULL);
     case DISPATCH_PROPERTYGET:
         V_VT(retv) = VT_BSTR;
         V_BSTR(retv) = SysAllocString(default_valueW);
@@ -177,7 +177,7 @@
             if(V_VT(arg) != VT_EMPTY && V_VT(arg) != VT_NULL) {
                 IDispatch *disp;
 
-                hres = to_object(dispex->ctx, arg, &disp);
+                hres = to_object(ctx, arg, &disp);
                 if(FAILED(hres))
                     return hres;
 
@@ -194,7 +194,7 @@
     case DISPATCH_CONSTRUCT: {
         DispatchEx *obj;
 
-        hres = create_object(dispex->ctx, NULL, &obj);
+        hres = create_object(ctx, NULL, &obj);
         if(FAILED(hres))
             return hres;
 
diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c
index 2b99e78..02470f7 100644
--- a/dlls/jscript/regexp.c
+++ b/dlls/jscript/regexp.c
@@ -3294,7 +3294,7 @@
     return re;
 }
 
-static HRESULT do_regexp_match_next(RegExpInstance *regexp, const WCHAR *str, DWORD len,
+static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, const WCHAR *str, DWORD len,
         const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, match_result_t *ret)
 {
     REMatchState *x, *result;
@@ -3305,7 +3305,7 @@
     gData.cpend = str + len;
     gData.start = *cp-str;
     gData.skipped = 0;
-    gData.pool = &regexp->dispex.ctx->tmp_heap;
+    gData.pool = &ctx->tmp_heap;
 
     x = InitMatch(NULL, &gData, regexp->jsregexp, gData.cpend - gData.cpbegin);
     if(!x) {
@@ -3355,7 +3355,7 @@
     return S_OK;
 }
 
-HRESULT regexp_match_next(DispatchEx *dispex, BOOL gcheck, const WCHAR *str, DWORD len,
+HRESULT regexp_match_next(script_ctx_t *ctx, DispatchEx *dispex, BOOL gcheck, const WCHAR *str, DWORD len,
         const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, match_result_t *ret)
 {
     RegExpInstance *regexp = (RegExpInstance*)dispex;
@@ -3365,16 +3365,16 @@
     if(gcheck && !(regexp->jsregexp->flags & JSREG_GLOB))
         return S_FALSE;
 
-    mark = jsheap_mark(&regexp->dispex.ctx->tmp_heap);
+    mark = jsheap_mark(&ctx->tmp_heap);
 
-    hres = do_regexp_match_next(regexp, str, len, cp, parens, parens_size, parens_cnt, ret);
+    hres = do_regexp_match_next(ctx, regexp, str, len, cp, parens, parens_size, parens_cnt, ret);
 
     jsheap_clear(mark);
     return hres;
 }
 
-HRESULT regexp_match(DispatchEx *dispex, const WCHAR *str, DWORD len, BOOL gflag, match_result_t **match_result,
-        DWORD *result_cnt)
+HRESULT regexp_match(script_ctx_t *ctx, DispatchEx *dispex, const WCHAR *str, DWORD len, BOOL gflag,
+        match_result_t **match_result, DWORD *result_cnt)
 {
     RegExpInstance *This = (RegExpInstance*)dispex;
     match_result_t *ret = NULL, cres;
@@ -3383,10 +3383,10 @@
     jsheap_t *mark;
     HRESULT hres;
 
-    mark = jsheap_mark(&This->dispex.ctx->tmp_heap);
+    mark = jsheap_mark(&ctx->tmp_heap);
 
     while(1) {
-        hres = do_regexp_match_next(This, str, len, &cp, NULL, NULL, NULL, &cres);
+        hres = do_regexp_match_next(ctx, This, str, len, &cp, NULL, NULL, NULL, &cres);
         if(hres == S_FALSE) {
             hres = S_OK;
             break;
@@ -3558,7 +3558,7 @@
     return S_OK;
 }
 
-static HRESULT run_exec(DispatchEx *dispex, VARIANT *arg, jsexcept_t *ei, BSTR *input,
+static HRESULT run_exec(script_ctx_t *ctx, DispatchEx *dispex, VARIANT *arg, jsexcept_t *ei, BSTR *input,
         match_result_t *match, match_result_t **parens, DWORD *parens_cnt, VARIANT_BOOL *ret)
 {
     RegExpInstance *regexp;
@@ -3575,7 +3575,7 @@
     regexp = (RegExpInstance*)dispex;
 
     if(arg) {
-        hres = to_string(regexp->dispex.ctx, arg, ei, &string);
+        hres = to_string(ctx, arg, ei, &string);
         if(FAILED(hres))
             return hres;
     }else {
@@ -3589,7 +3589,7 @@
         last_index = regexp->last_index;
 
     cp = string + last_index;
-    hres = regexp_match_next(&regexp->dispex, FALSE, string, length, &cp, parens, parens ? &parens_size : NULL,
+    hres = regexp_match_next(ctx, &regexp->dispex, FALSE, string, length, &cp, parens, parens ? &parens_size : NULL,
             parens_cnt, match);
     if(FAILED(hres)) {
         SysFreeString(string);
@@ -3620,7 +3620,7 @@
 
     TRACE("\n");
 
-    hres = run_exec(dispex, arg_cnt(dp) ? get_arg(dp,0) : NULL, ei, &string, &match, &parens, &parens_cnt, &b);
+    hres = run_exec(ctx, dispex, arg_cnt(dp) ? get_arg(dp,0) : NULL, ei, &string, &match, &parens, &parens_cnt, &b);
     if(FAILED(hres))
         return hres;
 
@@ -3628,7 +3628,7 @@
         if(b) {
             IDispatch *ret;
 
-            hres = create_match_array(dispex->ctx, string, &match, parens, parens_cnt, ei, &ret);
+            hres = create_match_array(ctx, string, &match, parens, parens_cnt, ei, &ret);
             if(SUCCEEDED(hres)) {
                 V_VT(retv) = VT_DISPATCH;
                 V_DISPATCH(retv) = ret;
@@ -3652,7 +3652,7 @@
 
     TRACE("\n");
 
-    hres = run_exec(dispex, arg_cnt(dp) ? get_arg(dp,0) : NULL, ei, NULL, &match, NULL, NULL, &b);
+    hres = run_exec(ctx, dispex, arg_cnt(dp) ? get_arg(dp,0) : NULL, ei, NULL, &match, NULL, NULL, &b);
     if(FAILED(hres))
         return hres;
 
@@ -3670,7 +3670,7 @@
 
     switch(flags) {
     case INVOKE_FUNC:
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_FUNC, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_FUNC, NULL);
     default:
         FIXME("unimplemented flags %x\n", flags);
         return E_NOTIMPL;
@@ -3843,7 +3843,7 @@
                     if(is_class(jsdisp, JSCLASS_REGEXP)) {
                         if(arg_cnt(dp) > 1 && V_VT(get_arg(dp,1)) != VT_EMPTY) {
                             jsdisp_release(jsdisp);
-                            return throw_regexp_error(dispex->ctx, ei, IDS_REGEXP_SYNTAX_ERROR, NULL);
+                            return throw_regexp_error(ctx, ei, IDS_REGEXP_SYNTAX_ERROR, NULL);
                         }
 
                         if(retv) {
@@ -3860,7 +3860,7 @@
         }
         /* fall through */
     case DISPATCH_CONSTRUCT:
-        return regexp_constructor(dispex->ctx, dp, retv);
+        return regexp_constructor(ctx, dp, retv);
     default:
         FIXME("unimplemented flags: %x\n", flags);
         return E_NOTIMPL;
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index b7d689f..7f12400 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -125,7 +125,7 @@
     return stringobj_to_string(dispex, retv);
 }
 
-static HRESULT do_attributeless_tag_format(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
+static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp, const WCHAR *tagname)
 {
     static const WCHAR tagfmt[] = {'<','%','s','>','%','s','<','/','%','s','>',0};
@@ -140,7 +140,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -171,7 +171,7 @@
     return S_OK;
 }
 
-static HRESULT do_attribute_tag_format(DispatchEx *dispex, WORD flags,
+static HRESULT do_attribute_tag_format(script_ctx_t *ctx, DispatchEx *dispex, WORD flags,
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp,
         const WCHAR *tagname, const WCHAR *attr)
 {
@@ -190,7 +190,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -205,7 +205,7 @@
     }
 
     if(arg_cnt(dp)) {
-        hres = to_string(dispex->ctx, get_arg(dp, 0), ei, &attr_value);
+        hres = to_string(ctx, get_arg(dp, 0), ei, &attr_value);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -245,28 +245,28 @@
     static const WCHAR fontW[] = {'A',0};
     static const WCHAR colorW[] = {'N','A','M','E',0};
 
-    return do_attribute_tag_format(dispex, flags, dp, retv, ei, sp, fontW, colorW);
+    return do_attribute_tag_format(ctx, dispex, flags, dp, retv, ei, sp, fontW, colorW);
 }
 
 static HRESULT String_big(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     static const WCHAR bigtagW[] = {'B','I','G',0};
-    return do_attributeless_tag_format(dispex, flags, dp, retv, ei, sp, bigtagW);
+    return do_attributeless_tag_format(ctx, dispex, flags, dp, retv, ei, sp, bigtagW);
 }
 
 static HRESULT String_blink(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     static const WCHAR blinktagW[] = {'B','L','I','N','K',0};
-    return do_attributeless_tag_format(dispex, flags, dp, retv, ei, sp, blinktagW);
+    return do_attributeless_tag_format(ctx, dispex, flags, dp, retv, ei, sp, blinktagW);
 }
 
 static HRESULT String_bold(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     static const WCHAR boldtagW[] = {'B',0};
-    return do_attributeless_tag_format(dispex, flags, dp, retv, ei, sp, boldtagW);
+    return do_attributeless_tag_format(ctx, dispex, flags, dp, retv, ei, sp, boldtagW);
 }
 
 /* ECMA-262 3rd Edition    15.5.4.5 */
@@ -287,7 +287,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -304,7 +304,7 @@
     if(arg_cnt(dp)) {
         VARIANT num;
 
-        hres = to_integer(dispex->ctx, get_arg(dp, 0), ei, &num);
+        hres = to_integer(ctx, get_arg(dp, 0), ei, &num);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -354,7 +354,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -371,7 +371,7 @@
     if(arg_cnt(dp) > 0) {
         VARIANT v;
 
-        hres = to_integer(dispex->ctx, get_arg(dp, 0), ei, &v);
+        hres = to_integer(ctx, get_arg(dp, 0), ei, &v);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -415,10 +415,10 @@
     V_VT(&var) = VT_DISPATCH;
     V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(dispex);
 
-    hres = to_string(dispex->ctx, &var, ei, strs);
+    hres = to_string(ctx, &var, ei, strs);
     if(SUCCEEDED(hres)) {
         for(i=0; i < arg_cnt(dp); i++) {
-            hres = to_string(dispex->ctx, get_arg(dp, i), ei, strs+i+1);
+            hres = to_string(ctx, get_arg(dp, i), ei, strs+i+1);
             if(FAILED(hres))
                 break;
         }
@@ -457,7 +457,7 @@
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     static const WCHAR fixedtagW[] = {'T','T',0};
-    return do_attributeless_tag_format(dispex, flags, dp, retv, ei, sp, fixedtagW);
+    return do_attributeless_tag_format(ctx, dispex, flags, dp, retv, ei, sp, fixedtagW);
 }
 
 static HRESULT String_fontcolor(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -466,7 +466,7 @@
     static const WCHAR fontW[] = {'F','O','N','T',0};
     static const WCHAR colorW[] = {'C','O','L','O','R',0};
 
-    return do_attribute_tag_format(dispex, flags, dp, retv, ei, sp, fontW, colorW);
+    return do_attribute_tag_format(ctx, dispex, flags, dp, retv, ei, sp, fontW, colorW);
 }
 
 static HRESULT String_fontsize(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -475,7 +475,7 @@
     static const WCHAR fontW[] = {'F','O','N','T',0};
     static const WCHAR colorW[] = {'S','I','Z','E',0};
 
-    return do_attribute_tag_format(dispex, flags, dp, retv, ei, sp, fontW, colorW);
+    return do_attribute_tag_format(ctx, dispex, flags, dp, retv, ei, sp, fontW, colorW);
 }
 
 static HRESULT String_indexOf(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -495,7 +495,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -518,7 +518,7 @@
         return S_OK;
     }
 
-    hres = to_string(dispex->ctx, get_arg(dp,0), ei, &search_str);
+    hres = to_string(ctx, get_arg(dp,0), ei, &search_str);
     if(FAILED(hres)) {
         SysFreeString(val_str);
         return hres;
@@ -527,7 +527,7 @@
     if(arg_cnt(dp) >= 2) {
         VARIANT ival;
 
-        hres = to_integer(dispex->ctx, get_arg(dp,1), ei, &ival);
+        hres = to_integer(ctx, get_arg(dp,1), ei, &ival);
         if(SUCCEEDED(hres)) {
             if(V_VT(&ival) == VT_I4)
                 pos = V_VT(&ival) > 0 ? V_I4(&ival) : 0;
@@ -564,7 +564,7 @@
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     static const WCHAR italicstagW[] = {'I',0};
-    return do_attributeless_tag_format(dispex, flags, dp, retv, ei, sp, italicstagW);
+    return do_attributeless_tag_format(ctx, dispex, flags, dp, retv, ei, sp, italicstagW);
 }
 
 /* ECMA-262 3rd Edition    15.5.4.8 */
@@ -590,7 +590,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -607,7 +607,7 @@
         return S_OK;
     }
 
-    hres = to_string(dispex->ctx, get_arg(dp,0), ei, &search_str);
+    hres = to_string(ctx, get_arg(dp,0), ei, &search_str);
     if(FAILED(hres)) {
         SysFreeString(val_str);
         return hres;
@@ -618,7 +618,7 @@
     if(arg_cnt(dp) >= 2) {
         VARIANT ival;
 
-        hres = to_integer(dispex->ctx, get_arg(dp,1), ei, &ival);
+        hres = to_integer(ctx, get_arg(dp,1), ei, &ival);
         if(SUCCEEDED(hres)) {
             if(V_VT(&ival) == VT_I4)
                 pos = V_VT(&ival) > 0 ? V_I4(&ival) : 0;
@@ -660,7 +660,7 @@
     static const WCHAR fontW[] = {'A',0};
     static const WCHAR colorW[] = {'H','R','E','F',0};
 
-    return do_attribute_tag_format(dispex, flags, dp, retv, ei, sp, fontW, colorW);
+    return do_attribute_tag_format(ctx, dispex, flags, dp, retv, ei, sp, fontW, colorW);
 }
 
 /* ECMA-262 3rd Edition    15.5.4.10 */
@@ -698,11 +698,11 @@
     default: {
         BSTR match_str;
 
-        hres = to_string(dispex->ctx, arg_var, ei, &match_str);
+        hres = to_string(ctx, arg_var, ei, &match_str);
         if(FAILED(hres))
             return hres;
 
-        hres = create_regexp_str(dispex->ctx, match_str, SysStringLen(match_str), NULL, 0, &regexp);
+        hres = create_regexp_str(ctx, match_str, SysStringLen(match_str), NULL, 0, &regexp);
         SysFreeString(match_str);
         if(FAILED(hres))
             return hres;
@@ -715,7 +715,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres)) {
             jsdisp_release(regexp);
             return hres;
@@ -731,7 +731,7 @@
         length = this->length;
     }
 
-    hres = regexp_match(regexp, str, length, FALSE, &match_result, &match_cnt);
+    hres = regexp_match(ctx, regexp, str, length, FALSE, &match_result, &match_cnt);
     jsdisp_release(regexp);
     if(FAILED(hres)) {
         SysFreeString(val_str);
@@ -748,7 +748,7 @@
         return S_OK;
     }
 
-    hres = create_array(dispex->ctx, match_cnt, &array);
+    hres = create_array(ctx, match_cnt, &array);
     if(FAILED(hres)) {
         SysFreeString(val_str);
         return hres;
@@ -814,8 +814,8 @@
     return S_OK;
 }
 
-static HRESULT rep_call(DispatchEx *func, const WCHAR *str, match_result_t *match, match_result_t *parens,
-        DWORD parens_cnt, BSTR *ret, jsexcept_t *ei, IServiceProvider *caller)
+static HRESULT rep_call(script_ctx_t *ctx, DispatchEx *func, const WCHAR *str, match_result_t *match,
+        match_result_t *parens, DWORD parens_cnt, BSTR *ret, jsexcept_t *ei, IServiceProvider *caller)
 {
     DISPPARAMS dp = {NULL, NULL, 0, 0};
     VARIANTARG *args, *arg;
@@ -870,7 +870,7 @@
     if(FAILED(hres))
         return hres;
 
-    hres = to_string(func->ctx, &var, ei, ret);
+    hres = to_string(ctx, &var, ei, ret);
     VariantClear(&var);
     return hres;
 }
@@ -897,7 +897,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -939,7 +939,7 @@
         }
 
     default:
-        hres = to_string(dispex->ctx, arg_var, ei, &match_str);
+        hres = to_string(ctx, arg_var, ei, &match_str);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -961,7 +961,7 @@
             }
 
         default:
-            hres = to_string(dispex->ctx, arg_var, ei, &rep_str);
+            hres = to_string(ctx, arg_var, ei, &rep_str);
             if(FAILED(hres))
                 break;
 
@@ -978,8 +978,8 @@
 
         while(1) {
             if(regexp) {
-                hres = regexp_match_next(regexp, gcheck, str, length, &cp, parens_ptr,
-                                         &parens_size, &parens_cnt, &match);
+                hres = regexp_match_next(ctx, regexp, gcheck, str, length, &cp, parens_ptr,
+                        &parens_size, &parens_cnt, &match);
                 gcheck = TRUE;
 
                 if(hres == S_FALSE) {
@@ -1004,7 +1004,7 @@
             if(rep_func) {
                 BSTR cstr;
 
-                hres = rep_call(rep_func, str, &match, parens, parens_cnt, &cstr, ei, caller);
+                hres = rep_call(ctx, rep_func, str, &match, parens, parens_cnt, &cstr, ei, caller);
                 if(FAILED(hres))
                     break;
 
@@ -1136,7 +1136,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -1151,7 +1151,7 @@
     }
 
     if(arg_cnt(dp)) {
-        hres = to_integer(dispex->ctx, get_arg(dp,0), ei, &v);
+        hres = to_integer(ctx, get_arg(dp,0), ei, &v);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -1174,7 +1174,7 @@
     }
 
     if(arg_cnt(dp) >= 2) {
-        hres = to_integer(dispex->ctx, get_arg(dp,1), ei, &v);
+        hres = to_integer(ctx, get_arg(dp,1), ei, &v);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -1218,7 +1218,7 @@
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     static const WCHAR smalltagW[] = {'S','M','A','L','L',0};
-    return do_attributeless_tag_format(dispex, flags, dp, retv, ei, sp, smalltagW);
+    return do_attributeless_tag_format(ctx, dispex, flags, dp, retv, ei, sp, smalltagW);
 }
 
 static HRESULT String_split(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -1245,7 +1245,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -1267,7 +1267,7 @@
         regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg));
         if(regexp) {
             if(is_class(regexp, JSCLASS_REGEXP)) {
-                hres = regexp_match(regexp, str, length, TRUE, &match_result, &match_cnt);
+                hres = regexp_match(ctx, regexp, str, length, TRUE, &match_result, &match_cnt);
                 jsdisp_release(regexp);
                 if(FAILED(hres)) {
                     SysFreeString(val_str);
@@ -1279,7 +1279,7 @@
         }
     }
     default:
-        hres = to_string(dispex->ctx, arg, ei, &match_str);
+        hres = to_string(ctx, arg, ei, &match_str);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -1292,7 +1292,7 @@
         }
     }
 
-    hres = create_array(dispex->ctx, 0, &array);
+    hres = create_array(ctx, 0, &array);
 
     if(SUCCEEDED(hres)) {
         ptr = str;
@@ -1366,14 +1366,14 @@
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     static const WCHAR striketagW[] = {'S','T','R','I','K','E',0};
-    return do_attributeless_tag_format(dispex, flags, dp, retv, ei, sp, striketagW);
+    return do_attributeless_tag_format(ctx, dispex, flags, dp, retv, ei, sp, striketagW);
 }
 
 static HRESULT String_sub(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     static const WCHAR subtagW[] = {'S','U','B',0};
-    return do_attributeless_tag_format(dispex, flags, dp, retv, ei, sp, subtagW);
+    return do_attributeless_tag_format(ctx, dispex, flags, dp, retv, ei, sp, subtagW);
 }
 
 /* ECMA-262 3rd Edition    15.5.4.15 */
@@ -1395,7 +1395,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -1410,7 +1410,7 @@
     }
 
     if(arg_cnt(dp) >= 1) {
-        hres = to_integer(dispex->ctx, get_arg(dp,0), ei, &v);
+        hres = to_integer(ctx, get_arg(dp,0), ei, &v);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -1428,7 +1428,7 @@
     }
 
     if(arg_cnt(dp) >= 2) {
-        hres = to_integer(dispex->ctx, get_arg(dp,1), ei, &v);
+        hres = to_integer(ctx, get_arg(dp,1), ei, &v);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -1488,7 +1488,7 @@
 
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -1497,7 +1497,7 @@
     }
 
     if(arg_cnt(dp) >= 1) {
-        hres = to_integer(dispex->ctx, get_arg(dp,0), ei, &v);
+        hres = to_integer(ctx, get_arg(dp,0), ei, &v);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -1515,7 +1515,7 @@
     }
 
     if(arg_cnt(dp) >= 2) {
-        hres = to_integer(dispex->ctx, get_arg(dp,1), ei, &v);
+        hres = to_integer(ctx, get_arg(dp,1), ei, &v);
         if(FAILED(hres)) {
             SysFreeString(val_str);
             return hres;
@@ -1550,7 +1550,7 @@
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
     static const WCHAR suptagW[] = {'S','U','P',0};
-    return do_attributeless_tag_format(dispex, flags, dp, retv, ei, sp, suptagW);
+    return do_attributeless_tag_format(ctx, dispex, flags, dp, retv, ei, sp, suptagW);
 }
 
 static HRESULT String_toLowerCase(script_ctx_t *ctx, DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
@@ -1569,7 +1569,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -1615,7 +1615,7 @@
         V_VT(&this) = VT_DISPATCH;
         V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
 
-        hres = to_string(dispex->ctx, &this, ei, &val_str);
+        hres = to_string(ctx, &this, ei, &val_str);
         if(FAILED(hres))
             return hres;
 
@@ -1675,7 +1675,7 @@
 
     switch(flags) {
     case INVOKE_FUNC:
-        return throw_type_error(dispex->ctx, ei, IDS_NOT_FUNC, NULL);
+        return throw_type_error(ctx, ei, IDS_NOT_FUNC, NULL);
     case DISPATCH_PROPERTYGET: {
         BSTR str = SysAllocString(This->str);
         if(!str)
@@ -1759,7 +1759,7 @@
         return E_OUTOFMEMORY;
 
     for(i=0; i<arg_cnt(dp); i++) {
-        hres = to_uint32(dispex->ctx, get_arg(dp, i), ei, &code);
+        hres = to_uint32(ctx, get_arg(dp, i), ei, &code);
         if(FAILED(hres)) {
             SysFreeString(ret);
             return hres;
@@ -1789,7 +1789,7 @@
         BSTR str;
 
         if(arg_cnt(dp)) {
-            hres = to_string(dispex->ctx, get_arg(dp, 0), ei, &str);
+            hres = to_string(ctx, get_arg(dp, 0), ei, &str);
             if(FAILED(hres))
                 return hres;
         }else {
@@ -1808,14 +1808,14 @@
         if(arg_cnt(dp)) {
             BSTR str;
 
-            hres = to_string(dispex->ctx, get_arg(dp, 0), ei, &str);
+            hres = to_string(ctx, get_arg(dp, 0), ei, &str);
             if(FAILED(hres))
                 return hres;
 
-            hres = create_string(dispex->ctx, str, SysStringLen(str), &ret);
+            hres = create_string(ctx, str, SysStringLen(str), &ret);
             SysFreeString(str);
         }else {
-            hres = create_string(dispex->ctx, NULL, 0, &ret);
+            hres = create_string(ctx, NULL, 0, &ret);
         }
 
         if(FAILED(hres))