| 2864 | } |
| 2865 | |
| 2866 | void fx_Compartment(txMachine* the) |
| 2867 | { |
| 2868 | txSlot* module = mxFunctionInstanceHome(mxFunction->value.reference)->value.home.module; |
| 2869 | txSlot* program = C_NULL; |
| 2870 | txSlot* parent; |
| 2871 | txSlot* realm; |
| 2872 | txSlot* global = C_NULL; |
| 2873 | txSlot* closures = C_NULL; |
| 2874 | txSlot* slot; |
| 2875 | txSlot* target; |
| 2876 | txSlot* own; |
| 2877 | txInteger id; |
| 2878 | |
| 2879 | if (!module) module = mxProgram.value.reference; |
| 2880 | mxTry(the) { |
| 2881 | if (!mxHasTarget) |
| 2882 | mxTypeError("call: Compartment"); |
| 2883 | |
| 2884 | mxPushSlot(mxTarget); |
| 2885 | fxGetPrototypeFromConstructor(the, &mxCompartmentPrototype); |
| 2886 | program = fxNewProgramInstance(the); |
| 2887 | mxPullSlot(mxResult); |
| 2888 | |
| 2889 | // PARENT |
| 2890 | parent = mxModuleInstanceInternal(module)->value.module.realm; |
| 2891 | mxPushReference(parent); |
| 2892 | |
| 2893 | // GLOBALS |
| 2894 | if (the->sharedMachine == C_NULL) { |
| 2895 | txSlot* instance; |
| 2896 | txSlot* property; |
| 2897 | txSlot* callback; |
| 2898 | mxPush(mxObjectPrototype); |
| 2899 | #ifdef mxLink |
| 2900 | global = fxNewObjectInstance(the); |
| 2901 | #else |
| 2902 | global = fxNewGlobalInstance(the); |
| 2903 | #endif |
| 2904 | slot = fxLastProperty(the, global); |
| 2905 | if (mxCompartmentGlobal.kind == XS_UNDEFINED_KIND) { |
| 2906 | for (id = XS_SYMBOL_ID_COUNT; id < _Infinity; id++) |
| 2907 | slot = fxNextSlotProperty(the, slot, &the->stackIntrinsics[-1 - id], mxID(id), XS_DONT_ENUM_FLAG); |
| 2908 | for (; id < _Compartment; id++) |
| 2909 | slot = fxNextSlotProperty(the, slot, &the->stackIntrinsics[-1 - id], mxID(id), XS_GET_ONLY); |
| 2910 | } |
| 2911 | else { |
| 2912 | txSlot* item = mxCompartmentGlobal.value.reference->next; |
| 2913 | for (id = XS_SYMBOL_ID_COUNT; id < _Infinity; id++) { |
| 2914 | mxPushSlot(item->value.array.address + id); |
| 2915 | slot = fxNextSlotProperty(the, slot, the->stack, mxID(id), XS_DONT_ENUM_FLAG); |
| 2916 | mxPop(); |
| 2917 | } |
| 2918 | for (; id < _Compartment; id++) { |
| 2919 | mxPushSlot(item->value.array.address + id); |
| 2920 | slot = fxNextSlotProperty(the, slot, the->stack, mxID(id), XS_GET_ONLY); |
| 2921 | mxPop(); |
| 2922 | } |
| 2923 | } |
nothing calls this directly
no test coverage detected