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

Function fxNewFunctionInstance

xs/sources/xsFunction.c:131–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131txSlot* fxNewFunctionInstance(txMachine* the, txID name)
132{
133 txSlot* instance;
134 txSlot* property;
135
136 instance = fxNewObjectInstance(the);
137 instance->flag |= XS_CAN_CALL_FLAG;
138
139 /* CODE */
140 property = instance->next = fxNewSlot(the);
141 property->flag = XS_INTERNAL_FLAG;
142 property->kind = mxEmptyCode.kind;
143 property->value.code.address = mxEmptyCode.value.code.address;
144 property->value.code.closures = C_NULL;
145
146 /* HOME */
147 property = property->next = fxNewSlot(the);
148 property->flag = XS_INTERNAL_FLAG;
149 property->kind = XS_HOME_KIND;
150 property->value.home.object = C_NULL;
151 if (the->frame && (mxFunction->kind == XS_REFERENCE_KIND) && (mxIsFunction(mxFunction->value.reference))) {
152 txSlot* slot = mxFunctionInstanceHome(mxFunction->value.reference);
153 property->value.home.module = slot->value.home.module;
154 }
155 else
156 property->value.home.module = C_NULL;
157
158 /* LENGTH */
159 if (gxDefaults.newFunctionLength)
160 gxDefaults.newFunctionLength(the, instance, 0);
161
162 /* NAME */
163 fxRenameFunction(the, instance, name, 0, XS_NO_ID, C_NULL);
164
165 return instance;
166}
167
168void fxDefaultFunctionPrototype(txMachine* the)
169{

Callers 6

xsRun.cFile · 0.85
fxRunScriptFunction · 0.85
fxDebugEvalBufferFunction · 0.85
fxBuildGlobalFunction · 0.85

Calls 3

fxNewObjectInstanceFunction · 0.85
fxNewSlotFunction · 0.85
fxRenameFunctionFunction · 0.85

Tested by

no test coverage detected