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

Function fx_lockdown

xs/sources/xsLockdown.c:74–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void fx_lockdown(txMachine* the)
75{
76#define mxHardenBuiltInCall \
77 mxPush(mxGlobal); \
78 mxPushSlot(harden); \
79 mxCall()
80#define mxHardenBuiltInRun \
81 mxRunCount(1); \
82 mxPop()
83
84 txSlot* instance;
85 txSlot* property;
86 txSlot* item;
87 txSlot* harden;
88 txInteger id;
89
90 if (mxProgram.value.reference->flag & XS_DONT_MARSHALL_FLAG)
91 mxTypeError("lockdown already called");
92 mxProgram.value.reference->flag |= XS_DONT_MARSHALL_FLAG;
93
94 property = mxBehaviorSetProperty(the, mxAsyncFunctionPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
95 fx_lockdown_aux(the, 1, &mxAsyncFunctionPrototype, property);
96 property = mxBehaviorSetProperty(the, mxAsyncGeneratorFunctionPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
97 fx_lockdown_aux(the, 1, &mxAsyncGeneratorFunctionPrototype, property);
98 property = mxBehaviorSetProperty(the, mxFunctionPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
99 fx_lockdown_aux(the, 1, &mxFunctionPrototype, property);
100 property = mxBehaviorSetProperty(the, mxGeneratorFunctionPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
101 fx_lockdown_aux(the, 1, &mxGeneratorFunctionPrototype, property);
102 property = mxBehaviorSetProperty(the, mxCompartmentPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
103 fx_lockdown_aux(the, 1, &mxCompartmentPrototype, property);
104
105 instance = fxNewArray(the, _Compartment);
106 property = the->stackIntrinsics - 1;
107 item = instance->next->value.array.address;
108 for (id = 0; id < XS_SYMBOL_ID_COUNT; id++) {
109 *((txIndex*)item) = id;
110 property--;
111 item++;
112 }
113 for (; id < _Compartment; id++) {
114 *((txIndex*)item) = id;
115 item->kind = property->kind;
116 item->value = property->value;
117 property--;
118 item++;
119 }
120
121 fxDuplicateInstance(the, mxDateConstructor.value.reference);
122 property = mxFunctionInstanceCode(the->stack->value.reference);
123 property->value.callback.address = mxCallback(fx_Date_secure);
124 property = mxBehaviorSetProperty(the, the->stack->value.reference, mxID(_now), 0, XS_OWN);
125 fxSetHostFunctionProperty(the, property, mxCallback(fx_Date_now_secure), 0, mxID(_now));
126 property = mxBehaviorSetProperty(the, mxDatePrototype.value.reference, mxID(_constructor), 0, XS_OWN);
127 fx_lockdown_aux(the, 7, &mxDatePrototype, property);
128 mxPull(instance->next->value.array.address[_Date]);
129
130 fxDuplicateInstance(the, mxMathObject.value.reference);
131 property = mxBehaviorSetProperty(the, the->stack->value.reference, mxID(_random), 0, XS_OWN);

Callers

nothing calls this directly

Calls 6

fx_lockdown_auxFunction · 0.85
fxNewArrayFunction · 0.85
fxDuplicateInstanceFunction · 0.85
fxGetIDFunction · 0.85
fxIDFunction · 0.85

Tested by

no test coverage detected