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

Function fxProxyDefineOwnProperty

xs/sources/xsProxy.c:259–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259txBoolean fxProxyDefineOwnProperty(txMachine* the, txSlot* instance, txID id, txIndex index, txSlot* slot, txFlag mask)
260{
261 txBoolean result;
262 mxProxyDeclarations(_defineProperty);
263 if (function) {
264 /* THIS */
265 mxPushSlot(handler);
266 /* FUNCTION */
267 mxPushSlot(function);
268 mxCall();
269 /* ARGUMENTS */
270 mxPushSlot(target);
271 mxPushUndefined();
272 fxKeyAt(the, id, index, the->stack);
273 fxDescribeProperty(the, slot, mask);
274 mxRunCount(3);
275 result = fxToBoolean(the, the->stack);
276 mxPop();
277 if (result) {
278 mxPushUndefined();
279 if (mxBehaviorGetOwnProperty(the, target->value.reference, id, index, the->stack)) {
280 if (fxIsPropertyCompatible(the, the->stack, slot, mask)) {
281 if ((mask & XS_DONT_DELETE_FLAG) && (slot->flag & XS_DONT_DELETE_FLAG)) {
282 if (!(the->stack->flag & XS_DONT_DELETE_FLAG))
283 mxTypeError("(proxy).defineProperty: true with non-configurable descriptor for configurable property");
284 }
285 if (the->stack->flag & XS_DONT_DELETE_FLAG) {
286 if ((mask & XS_DONT_SET_FLAG) && (slot->flag & XS_DONT_SET_FLAG) && !(the->stack->flag & XS_DONT_SET_FLAG))
287 mxTypeError("(proxy).defineProperty: true with non-writable descriptor for non-configurable writable property");
288 }
289 }
290 else
291 mxTypeError("(proxy).defineProperty: true with incompatible descriptor for existent property");
292 }
293 else if (mxBehaviorIsExtensible(the, target->value.reference)) {
294 if ((mask & XS_DONT_DELETE_FLAG) && (slot->flag & XS_DONT_DELETE_FLAG))
295 mxTypeError("(proxy).defineProperty: true with non-configurable descriptor for non-existent property");
296 }
297 else
298 mxTypeError("(proxy).defineProperty: true with descriptor for non-existent property of non-extensible object");
299 mxPop();
300 }
301 }
302 else
303 result = mxBehaviorDefineOwnProperty(the, target->value.reference, id, index, slot, mask);
304 mxProxyPop();
305 return result;
306}
307
308txBoolean fxProxyDeleteProperty(txMachine* the, txSlot* instance, txID id, txIndex index)
309{

Callers

nothing calls this directly

Calls 4

fxKeyAtFunction · 0.85
fxDescribePropertyFunction · 0.85
fxToBooleanFunction · 0.85
fxIsPropertyCompatibleFunction · 0.85

Tested by

no test coverage detected