MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxBuildFunction

Function fxBuildFunction

xs/sources/xsFunction.c:45–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43static const txByte gxTailCode[1] = { XS_CODE_RUN_TAIL };
44
45void fxBuildFunction(txMachine* the)
46{
47 txSlot* slot;
48 txSlot* function;
49 txSlot* constructor;
50 mxPush(mxFunctionPrototype);
51 slot = fxLastProperty(the, the->stack->value.reference);
52 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Function_prototype_apply), 2, mxID(_apply), XS_DONT_ENUM_FLAG);
53 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Function_prototype_bind), 1, mxID(_bind), XS_DONT_ENUM_FLAG);
54 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Function_prototype_call), 1, mxID(_call), XS_DONT_ENUM_FLAG);
55 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Function_prototype_toString), 0, mxID(_toString), XS_DONT_ENUM_FLAG);
56 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Function_prototype_hasInstance), 1, mxID(_Symbol_hasInstance), XS_GET_ONLY);
57 function = mxThrowTypeErrorFunction.value.reference;
58 slot = slot->next = fxNewSlot(the);
59 slot->flag = XS_DONT_ENUM_FLAG;
60 slot->ID = mxID(_arguments);
61 slot->kind = XS_ACCESSOR_KIND;
62 slot->value.accessor.getter = function;
63 slot->value.accessor.setter = function;
64 slot = slot->next = fxNewSlot(the);
65 slot->flag = XS_DONT_ENUM_FLAG;
66 slot->ID = mxID(_caller);
67 slot->kind = XS_ACCESSOR_KIND;
68 slot->value.accessor.getter = function;
69 slot->value.accessor.setter = function;
70 constructor = fxBuildHostConstructor(the, mxCallback(fx_Function), 1, mxID(_Function));
71 mxFunctionConstructor = *the->stack;
72 mxPop();
73
74 mxPush(mxFunctionPrototype);
75 slot = fxLastProperty(the, fxNewObjectInstance(the));
76 slot = fxNextStringXProperty(the, slot, "AsyncFunction", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG);
77 mxAsyncFunctionPrototype = *the->stack;
78 slot = fxBuildHostConstructor(the, mxCallback(fx_AsyncFunction), 1, mxID(_AsyncFunction));
79 slot->value.instance.prototype = constructor;
80 mxPop();
81 slot = mxBehaviorGetProperty(the, mxAsyncFunctionPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
82 slot->flag |= XS_DONT_SET_FLAG;
83}
84
85void fxCheckCallable(txMachine* the, txSlot* slot)
86{

Callers 1

fxCreateMachineFunction · 0.85

Calls 6

fxLastPropertyFunction · 0.85
fxNewSlotFunction · 0.85
fxBuildHostConstructorFunction · 0.85
fxNewObjectInstanceFunction · 0.85
fxNextStringXPropertyFunction · 0.85

Tested by

no test coverage detected