2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(jscript
);
28 builtin_invoke_t value_proc
;
31 source_elements_t
*source
;
32 parameter_t
*parameters
;
33 scope_chain_t
*scope_chain
;
41 static inline FunctionInstance
*function_from_vdisp(vdisp_t
*vdisp
)
43 return (FunctionInstance
*)vdisp
->u
.jsdisp
;
46 static inline FunctionInstance
*function_this(vdisp_t
*jsthis
)
48 return is_vclass(jsthis
, JSCLASS_FUNCTION
) ? function_from_vdisp(jsthis
) : NULL
;
51 static const WCHAR prototypeW
[] = {'p','r','o','t','o','t', 'y', 'p','e',0};
53 static const WCHAR lengthW
[] = {'l','e','n','g','t','h',0};
54 static const WCHAR toStringW
[] = {'t','o','S','t','r','i','n','g',0};
55 static const WCHAR applyW
[] = {'a','p','p','l','y',0};
56 static const WCHAR callW
[] = {'c','a','l','l',0};
57 static const WCHAR argumentsW
[] = {'a','r','g','u','m','e','n','t','s',0};
59 static IDispatch
*get_this(DISPPARAMS
*dp
)
63 for(i
=0; i
< dp
->cNamedArgs
; i
++) {
64 if(dp
->rgdispidNamedArgs
[i
] == DISPID_THIS
) {
65 if(V_VT(dp
->rgvarg
+i
) == VT_DISPATCH
)
66 return V_DISPATCH(dp
->rgvarg
+i
);
68 WARN("This is not VT_DISPATCH\n");
73 TRACE("no this passed\n");
77 static HRESULT
init_parameters(jsdisp_t
*var_disp
, FunctionInstance
*function
, DISPPARAMS
*dp
,
78 jsexcept_t
*ei
, IServiceProvider
*caller
)
85 V_VT(&var_empty
) = VT_EMPTY
;
88 for(param
= function
->parameters
; param
; param
= param
->next
) {
89 hres
= jsdisp_propput_name(var_disp
, param
->identifier
,
90 i
< cargs
? get_arg(dp
,i
) : &var_empty
, ei
, caller
);
100 static HRESULT
Arguments_value(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, DISPPARAMS
*dp
,
101 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*caller
)
107 static const builtin_info_t Arguments_info
= {
109 {NULL
, Arguments_value
, 0},
115 static HRESULT
create_arguments(script_ctx_t
*ctx
, IDispatch
*calee
, DISPPARAMS
*dp
,
116 jsexcept_t
*ei
, IServiceProvider
*caller
, jsdisp_t
**ret
)
123 static const WCHAR caleeW
[] = {'c','a','l','l','e','e',0};
125 args
= heap_alloc_zero(sizeof(jsdisp_t
));
127 return E_OUTOFMEMORY
;
129 hres
= init_dispex_from_constr(args
, ctx
, &Arguments_info
, ctx
->object_constr
);
135 for(i
=0; i
< arg_cnt(dp
); i
++) {
136 hres
= jsdisp_propput_idx(args
, i
, get_arg(dp
,i
), ei
, caller
);
141 if(SUCCEEDED(hres
)) {
143 V_I4(&var
) = arg_cnt(dp
);
144 hres
= jsdisp_propput_name(args
, lengthW
, &var
, ei
, caller
);
146 if(SUCCEEDED(hres
)) {
147 V_VT(&var
) = VT_DISPATCH
;
148 V_DISPATCH(&var
) = calee
;
149 hres
= jsdisp_propput_name(args
, caleeW
, &var
, ei
, caller
);
154 jsdisp_release(args
);
162 static HRESULT
create_var_disp(script_ctx_t
*ctx
, FunctionInstance
*function
, jsdisp_t
*arg_disp
,
163 DISPPARAMS
*dp
, jsexcept_t
*ei
, IServiceProvider
*caller
, jsdisp_t
**ret
)
169 hres
= create_dispex(ctx
, NULL
, NULL
, &var_disp
);
173 var_set_jsdisp(&var
, arg_disp
);
174 hres
= jsdisp_propput_name(var_disp
, argumentsW
, &var
, ei
, caller
);
176 hres
= init_parameters(var_disp
, function
, dp
, ei
, caller
);
178 jsdisp_release(var_disp
);
186 static HRESULT
invoke_source(script_ctx_t
*ctx
, FunctionInstance
*function
, IDispatch
*this_obj
, DISPPARAMS
*dp
,
187 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*caller
)
189 jsdisp_t
*var_disp
, *arg_disp
;
190 exec_ctx_t
*exec_ctx
;
191 scope_chain_t
*scope
;
194 if(!function
->source
) {
195 FIXME("no source\n");
199 hres
= create_arguments(ctx
, to_disp(&function
->dispex
),
200 dp
, ei
, caller
, &arg_disp
);
204 hres
= create_var_disp(ctx
, function
, arg_disp
, dp
, ei
, caller
, &var_disp
);
206 jsdisp_release(arg_disp
);
210 hres
= scope_push(function
->scope_chain
, var_disp
, &scope
);
211 if(SUCCEEDED(hres
)) {
212 hres
= create_exec_ctx(ctx
, this_obj
, var_disp
, scope
, FALSE
, &exec_ctx
);
213 scope_release(scope
);
215 jsdisp_release(var_disp
);
216 if(SUCCEEDED(hres
)) {
219 prev_args
= function
->arguments
;
220 function
->arguments
= arg_disp
;
221 hres
= exec_source(exec_ctx
, function
->parser
, function
->source
, FALSE
, ei
, retv
);
222 function
->arguments
= prev_args
;
224 jsdisp_release(arg_disp
);
225 exec_release(exec_ctx
);
231 static HRESULT
invoke_constructor(script_ctx_t
*ctx
, FunctionInstance
*function
, DISPPARAMS
*dp
,
232 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*caller
)
238 hres
= create_object(ctx
, &function
->dispex
, &this_obj
);
242 hres
= invoke_source(ctx
, function
, to_disp(this_obj
), dp
, &var
, ei
, caller
);
244 jsdisp_release(this_obj
);
248 if(V_VT(&var
) == VT_DISPATCH
) {
249 jsdisp_release(this_obj
);
250 V_VT(retv
) = VT_DISPATCH
;
251 V_DISPATCH(retv
) = V_DISPATCH(&var
);
254 var_set_jsdisp(retv
, this_obj
);
259 static HRESULT
invoke_value_proc(script_ctx_t
*ctx
, FunctionInstance
*function
, IDispatch
*this_disp
, WORD flags
, DISPPARAMS
*dp
,
260 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*caller
)
266 set_disp(&vthis
, this_disp
);
267 else if(ctx
->host_global
)
268 set_disp(&vthis
, ctx
->host_global
);
270 set_jsdisp(&vthis
, ctx
->global
);
272 hres
= function
->value_proc(ctx
, &vthis
, flags
, dp
, retv
, ei
, caller
);
274 vdisp_release(&vthis
);
278 static HRESULT
call_function(script_ctx_t
*ctx
, FunctionInstance
*function
, IDispatch
*this_obj
, DISPPARAMS
*args
,
279 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*caller
)
281 if(function
->value_proc
)
282 return invoke_value_proc(ctx
, function
, this_obj
, DISPATCH_METHOD
, args
, retv
, ei
, caller
);
284 return invoke_source(ctx
, function
, this_obj
, args
, retv
, ei
, caller
);
287 static HRESULT
function_to_string(FunctionInstance
*function
, BSTR
*ret
)
291 static const WCHAR native_prefixW
[] = {'\n','f','u','n','c','t','i','o','n',' '};
292 static const WCHAR native_suffixW
[] =
293 {'(',')',' ','{','\n',' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n','}','\n'};
295 if(function
->value_proc
) {
298 name_len
= strlenW(function
->name
);
299 str
= SysAllocStringLen(NULL
, sizeof(native_prefixW
) + name_len
*sizeof(WCHAR
) + sizeof(native_suffixW
));
301 return E_OUTOFMEMORY
;
303 memcpy(str
, native_prefixW
, sizeof(native_prefixW
));
304 memcpy(str
+ sizeof(native_prefixW
)/sizeof(WCHAR
), function
->name
, name_len
*sizeof(WCHAR
));
305 memcpy(str
+ sizeof(native_prefixW
)/sizeof(WCHAR
) + name_len
, native_suffixW
, sizeof(native_suffixW
));
307 str
= SysAllocStringLen(function
->src_str
, function
->src_len
);
309 return E_OUTOFMEMORY
;
316 static HRESULT
Function_length(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, DISPPARAMS
*dp
,
317 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*sp
)
319 FunctionInstance
*This
= function_from_vdisp(jsthis
);
321 TRACE("%p %d\n", This
, This
->length
);
324 case DISPATCH_PROPERTYGET
:
326 V_I4(retv
) = This
->length
;
329 FIXME("unimplemented flags %x\n", flags
);
336 static HRESULT
Function_toString(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, DISPPARAMS
*dp
,
337 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*sp
)
339 FunctionInstance
*function
;
345 if(!(function
= function_this(jsthis
)))
346 return throw_type_error(ctx
, ei
, JS_E_FUNCTION_EXPECTED
, NULL
);
348 hres
= function_to_string(function
, &str
);
353 V_VT(retv
) = VT_BSTR
;
361 static HRESULT
array_to_args(script_ctx_t
*ctx
, jsdisp_t
*arg_array
, jsexcept_t
*ei
, IServiceProvider
*caller
,
368 hres
= jsdisp_propget_name(arg_array
, lengthW
, &var
, ei
, NULL
/*FIXME*/);
372 hres
= to_uint32(ctx
, &var
, ei
, &length
);
377 argv
= heap_alloc(length
* sizeof(VARIANT
));
379 return E_OUTOFMEMORY
;
381 for(i
=0; i
<length
; i
++) {
382 hres
= jsdisp_get_idx(arg_array
, i
, argv
+i
, ei
, caller
);
383 if(hres
== DISP_E_UNKNOWNNAME
)
384 V_VT(argv
+i
) = VT_EMPTY
;
385 else if(FAILED(hres
)) {
387 VariantClear(argv
+i
);
393 args
->cArgs
= length
;
398 static HRESULT
Function_apply(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, DISPPARAMS
*dp
,
399 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*caller
)
401 FunctionInstance
*function
;
402 DISPPARAMS args
= {NULL
,NULL
,0,0};
404 IDispatch
*this_obj
= NULL
;
409 if(!(function
= function_this(jsthis
)))
410 return throw_type_error(ctx
, ei
, JS_E_FUNCTION_EXPECTED
, NULL
);
414 VARIANT
*v
= get_arg(dp
,0);
416 if(V_VT(v
) != VT_EMPTY
&& V_VT(v
) != VT_NULL
) {
417 hres
= to_object(ctx
, v
, &this_obj
);
424 jsdisp_t
*arg_array
= NULL
;
426 if(V_VT(get_arg(dp
,1)) == VT_DISPATCH
) {
427 arg_array
= iface_to_jsdisp((IUnknown
*)V_DISPATCH(get_arg(dp
,1)));
429 (!is_class(arg_array
, JSCLASS_ARRAY
) && !is_class(arg_array
, JSCLASS_ARGUMENTS
) )) {
430 jsdisp_release(arg_array
);
436 hres
= array_to_args(ctx
, arg_array
, ei
, caller
, &args
);
437 jsdisp_release(arg_array
);
439 FIXME("throw TypeError\n");
444 hres
= call_function(ctx
, function
, this_obj
, &args
, retv
, ei
, caller
);
447 IDispatch_Release(this_obj
);
448 for(i
=0; i
<args
.cArgs
; i
++)
449 VariantClear(args
.rgvarg
+i
);
450 heap_free(args
.rgvarg
);
454 static HRESULT
Function_call(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, DISPPARAMS
*dp
,
455 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*caller
)
457 FunctionInstance
*function
;
458 DISPPARAMS args
= {NULL
,NULL
,0,0};
459 IDispatch
*this_obj
= NULL
;
465 if(!(function
= function_this(jsthis
)))
466 return throw_type_error(ctx
, ei
, JS_E_FUNCTION_EXPECTED
, NULL
);
470 VARIANT
*v
= get_arg(dp
,0);
472 if(V_VT(v
) != VT_EMPTY
&& V_VT(v
) != VT_NULL
) {
473 hres
= to_object(ctx
, v
, &this_obj
);
482 args
.rgvarg
= dp
->rgvarg
+ dp
->cArgs
- args
.cArgs
-1;
484 hres
= call_function(ctx
, function
, this_obj
, &args
, retv
, ei
, caller
);
487 IDispatch_Release(this_obj
);
491 HRESULT
Function_value(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, DISPPARAMS
*dp
,
492 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*caller
)
494 FunctionInstance
*function
;
498 if(!is_vclass(jsthis
, JSCLASS_FUNCTION
)) {
499 ERR("dispex is not a function\n");
503 function
= (FunctionInstance
*)jsthis
->u
.jsdisp
;
506 case DISPATCH_METHOD
:
507 if(function
->value_proc
)
508 return invoke_value_proc(ctx
, function
, get_this(dp
), flags
, dp
, retv
, ei
, caller
);
510 return invoke_source(ctx
, function
, get_this(dp
), dp
, retv
, ei
, caller
);
512 case DISPATCH_PROPERTYGET
: {
516 hres
= function_to_string(function
, &str
);
520 V_VT(retv
) = VT_BSTR
;
525 case DISPATCH_CONSTRUCT
:
526 if(function
->value_proc
)
527 return invoke_value_proc(ctx
, function
, get_this(dp
), flags
, dp
, retv
, ei
, caller
);
529 return invoke_constructor(ctx
, function
, dp
, retv
, ei
, caller
);
532 FIXME("not implemented flags %x\n", flags
);
539 static HRESULT
Function_arguments(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
,
540 DISPPARAMS
*dp
, VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*sp
)
542 FunctionInstance
*function
= (FunctionInstance
*)jsthis
->u
.jsdisp
;
548 case DISPATCH_PROPERTYGET
: {
549 if(function
->arguments
) {
550 jsdisp_addref(function
->arguments
);
551 var_set_jsdisp(retv
, function
->arguments
);
553 V_VT(retv
) = VT_NULL
;
557 case DISPATCH_PROPERTYPUT
:
560 FIXME("unimplemented flags %x\n", flags
);
567 static void Function_destructor(jsdisp_t
*dispex
)
569 FunctionInstance
*This
= (FunctionInstance
*)dispex
;
572 parser_release(This
->parser
);
573 if(This
->scope_chain
)
574 scope_release(This
->scope_chain
);
578 static const builtin_prop_t Function_props
[] = {
579 {applyW
, Function_apply
, PROPF_METHOD
|2},
580 {argumentsW
, Function_arguments
, 0},
581 {callW
, Function_call
, PROPF_METHOD
|1},
582 {lengthW
, Function_length
, 0},
583 {toStringW
, Function_toString
, PROPF_METHOD
}
586 static const builtin_info_t Function_info
= {
588 {NULL
, Function_value
, 0},
589 sizeof(Function_props
)/sizeof(*Function_props
),
595 static HRESULT
create_function(script_ctx_t
*ctx
, const builtin_info_t
*builtin_info
, DWORD flags
,
596 BOOL funcprot
, jsdisp_t
*prototype
, FunctionInstance
**ret
)
598 FunctionInstance
*function
;
601 function
= heap_alloc_zero(sizeof(FunctionInstance
));
603 return E_OUTOFMEMORY
;
606 hres
= init_dispex(&function
->dispex
, ctx
, &Function_info
, prototype
);
607 else if(builtin_info
)
608 hres
= init_dispex_from_constr(&function
->dispex
, ctx
, builtin_info
, ctx
->function_constr
);
610 hres
= init_dispex_from_constr(&function
->dispex
, ctx
, &Function_info
, ctx
->function_constr
);
614 function
->flags
= flags
;
615 function
->length
= flags
& PROPF_ARGMASK
;
621 static HRESULT
set_prototype(script_ctx_t
*ctx
, jsdisp_t
*dispex
, jsdisp_t
*prototype
)
626 var_set_jsdisp(&var
, prototype
);
627 memset(&jsexcept
, 0, sizeof(jsexcept
));
629 return jsdisp_propput_name(dispex
, prototypeW
, &var
, &jsexcept
, NULL
/*FIXME*/);
632 HRESULT
create_builtin_function(script_ctx_t
*ctx
, builtin_invoke_t value_proc
, const WCHAR
*name
,
633 const builtin_info_t
*builtin_info
, DWORD flags
, jsdisp_t
*prototype
, jsdisp_t
**ret
)
635 FunctionInstance
*function
;
638 hres
= create_function(ctx
, builtin_info
, flags
, FALSE
, NULL
, &function
);
646 V_I4(&var
) = function
->length
;
647 hres
= jsdisp_propput_const(&function
->dispex
, lengthW
, &var
);
651 hres
= set_prototype(ctx
, &function
->dispex
, prototype
);
653 jsdisp_release(&function
->dispex
);
657 function
->value_proc
= value_proc
;
658 function
->name
= name
;
660 *ret
= &function
->dispex
;
664 HRESULT
create_source_function(parser_ctx_t
*ctx
, parameter_t
*parameters
, source_elements_t
*source
,
665 scope_chain_t
*scope_chain
, const WCHAR
*src_str
, DWORD src_len
, jsdisp_t
**ret
)
667 FunctionInstance
*function
;
673 hres
= create_object(ctx
->script
, NULL
, &prototype
);
677 hres
= create_function(ctx
->script
, NULL
, PROPF_CONSTR
, FALSE
, NULL
, &function
);
678 if(SUCCEEDED(hres
)) {
679 hres
= set_prototype(ctx
->script
, &function
->dispex
, prototype
);
681 jsdisp_release(&function
->dispex
);
683 jsdisp_release(prototype
);
687 function
->source
= source
;
688 function
->parameters
= parameters
;
691 scope_addref(scope_chain
);
692 function
->scope_chain
= scope_chain
;
696 function
->parser
= ctx
;
698 for(iter
= parameters
; iter
; iter
= iter
->next
)
700 function
->length
= length
;
702 function
->src_str
= src_str
;
703 function
->src_len
= src_len
;
705 *ret
= &function
->dispex
;
709 static HRESULT
construct_function(script_ctx_t
*ctx
, DISPPARAMS
*dp
, jsexcept_t
*ei
, IDispatch
**ret
)
711 function_expression_t
*expr
;
712 WCHAR
*str
= NULL
, *ptr
;
713 DWORD argc
, len
= 0, l
;
714 parser_ctx_t
*parser
;
720 static const WCHAR function_anonymousW
[] = {'f','u','n','c','t','i','o','n',' ','a','n','o','n','y','m','o','u','s','('};
721 static const WCHAR function_beginW
[] = {')',' ','{','\n'};
722 static const WCHAR function_endW
[] = {'\n','}',0};
726 params
= heap_alloc(argc
*sizeof(BSTR
));
728 return E_OUTOFMEMORY
;
731 len
= (argc
-2)*2; /* separating commas */
732 for(i
=0; i
< argc
; i
++) {
733 hres
= to_string(ctx
, get_arg(dp
,i
), ei
, params
+i
);
736 len
+= SysStringLen(params
[i
]);
740 if(SUCCEEDED(hres
)) {
741 len
+= (sizeof(function_anonymousW
) + sizeof(function_beginW
) + sizeof(function_endW
)) / sizeof(WCHAR
);
742 str
= heap_alloc(len
*sizeof(WCHAR
));
744 memcpy(str
, function_anonymousW
, sizeof(function_anonymousW
));
745 ptr
= str
+ sizeof(function_anonymousW
)/sizeof(WCHAR
);
748 l
= SysStringLen(params
[j
]);
749 memcpy(ptr
, params
[j
], l
*sizeof(WCHAR
));
757 memcpy(ptr
, function_beginW
, sizeof(function_beginW
));
758 ptr
+= sizeof(function_beginW
)/sizeof(WCHAR
);
760 l
= SysStringLen(params
[argc
-1]);
761 memcpy(ptr
, params
[argc
-1], l
*sizeof(WCHAR
));
764 memcpy(ptr
, function_endW
, sizeof(function_endW
));
766 TRACE("%s\n", debugstr_w(str
));
768 hres
= E_OUTOFMEMORY
;
773 SysFreeString(params
[i
]);
778 hres
= script_parse(ctx
, str
, NULL
, &parser
);
783 if(!parser
->source
|| !parser
->source
->functions
|| parser
->source
->functions
->next
|| parser
->source
->variables
) {
784 ERR("Invalid parser result!\n");
785 parser_release(parser
);
788 expr
= parser
->source
->functions
->expr
;
790 hres
= create_source_function(parser
, expr
->parameter_list
, expr
->source_elements
, NULL
, expr
->src_str
,
791 expr
->src_len
, &function
);
792 parser_release(parser
);
796 *ret
= to_disp(function
);
800 static HRESULT
FunctionConstr_value(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, DISPPARAMS
*dp
,
801 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*sp
)
808 case DISPATCH_CONSTRUCT
: {
811 hres
= construct_function(ctx
, dp
, ei
, &ret
);
815 V_VT(retv
) = VT_DISPATCH
;
816 V_DISPATCH(retv
) = ret
;
820 FIXME("unimplemented flags %x\n", flags
);
827 static HRESULT
FunctionProt_value(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, DISPPARAMS
*dp
,
828 VARIANT
*retv
, jsexcept_t
*ei
, IServiceProvider
*sp
)
834 HRESULT
init_function_constr(script_ctx_t
*ctx
, jsdisp_t
*object_prototype
)
836 FunctionInstance
*prot
, *constr
;
839 static const WCHAR FunctionW
[] = {'F','u','n','c','t','i','o','n',0};
841 hres
= create_function(ctx
, NULL
, PROPF_CONSTR
, TRUE
, object_prototype
, &prot
);
845 prot
->value_proc
= FunctionProt_value
;
846 prot
->name
= prototypeW
;
848 hres
= create_function(ctx
, NULL
, PROPF_CONSTR
|1, TRUE
, &prot
->dispex
, &constr
);
849 if(SUCCEEDED(hres
)) {
850 constr
->value_proc
= FunctionConstr_value
;
851 constr
->name
= FunctionW
;
852 hres
= set_prototype(ctx
, &constr
->dispex
, &prot
->dispex
);
854 jsdisp_release(&constr
->dispex
);
856 jsdisp_release(&prot
->dispex
);
860 ctx
->function_constr
= &constr
->dispex
;