void fxBuildFunction(txMachine* the) { static const txHostFunctionBuilder gx_Function_prototype_builders[] = { { fx_Function_prototype_apply, 2, _apply }, { fx_Function_prototype_bind, 1, _bind }, { fx_Function_prototype_call, 1, _call }, { fx_Function_prototype_hasInstance, 1, _Symbol_hasInstance }, { C_NULL, 0, 0 }, }; const txHostFunctionBuilder* builder; txSlot* slot; mxPush(mxFunctionPrototype); slot = fxLastProperty(the, the->stack->value.reference); slot = fxNextHostAccessorProperty(the, slot, fx_Function_prototype_get_length, fx_Function_prototype_set_length, mxID(_length), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); slot = fxNextHostAccessorProperty(the, slot, fx_Function_prototype_get_name, fx_Function_prototype_set_name, mxID(_name), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); slot = fxNextHostAccessorProperty(the, slot, fx_Function_prototype_get_prototype, fx_Function_prototype_set_prototype, mxID(_prototype), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG); for (builder = gx_Function_prototype_builders; builder->callback; builder++) slot = fxNextHostFunctionProperty(the, slot, builder->callback, builder->length, mxID(builder->id), XS_DONT_ENUM_FLAG); slot = fxNextStringProperty(the, slot, "Function", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); slot = fxNewHostConstructorGlobal(the, fx_Function, 1, mxID(_Function), XS_GET_ONLY); the->stack++; }
void fxBuildHost(txMachine* the) { txSlot* property; txSlot* slot; fxNewHostAccessorGlobal(the, fx_get_sandbox, C_NULL, fxID(the, "sandbox"), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); property = fxLastProperty(the, mxObjectPrototype.value.reference); property = fxNextHostAccessorProperty(the, property, fx_Object_prototype_get_sandbox, C_NULL, fxID(the, "sandbox"), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); mxPush(mxObjectPrototype); property = fxLastProperty(the, fxNewObjectInstance(the)); property = fxNextHostFunctionProperty(the, property, fx_xs_execute, 1, fxID(the, "execute"), XS_GET_ONLY); property = fxNextHostFunctionProperty(the, property, fx_xs_isInstanceOf, 2, fxID(the, "isInstanceOf"), XS_GET_ONLY); property = fxNextHostFunctionProperty(the, property, fx_xs_newInstanceOf, 1, fxID(the, "newInstanceOf"), XS_GET_ONLY); property = fxNextHostFunctionProperty(the, property, fx_xs_script, 1, fxID(the, "script"), XS_GET_ONLY); #ifdef mxProfile property = fxNextHostFunctionProperty(the, property, fx_xs_isProfiling, 0, fxID(the, "isProfiling"), XS_GET_ONLY); property = fxNextHostFunctionProperty(the, property, fx_xs_getProfilingDirectory, 0, fxID(the, "getProfilingDirectory"), XS_GET_ONLY); property = fxNextHostFunctionProperty(the, property, fx_xs_setProfilingDirectory, 1, fxID(the, "setProfilingDirectory"), XS_GET_ONLY); property = fxNextHostFunctionProperty(the, property, fx_xs_startProfiling, 0, fxID(the, "startProfiling"), XS_GET_ONLY); property = fxNextHostFunctionProperty(the, property, fx_xs_stopProfiling, 0, fxID(the, "stopProfiling"), XS_GET_ONLY); #endif #ifdef mxDebug mxPush(mxObjectPrototype); slot = fxLastProperty(the, fxNewObjectInstance(the)); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_getAddress, 0, fxID(the, "getAddress"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_setAddress, 1, fxID(the, "setAddress"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_getAutomatic, 0, fxID(the, "getAutomatic"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_setAutomatic, 1, fxID(the, "setAutomatic"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_getBreakOnException, 0, fxID(the, "getBreakOnException"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_setBreakOnException, 1, fxID(the, "setBreakOnException"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_getConnected, 0, fxID(the, "getConnected"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_setConnected, 1, fxID(the, "setConnected"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_clearAllBreakpoints, 0, fxID(the, "clearAllBreakpoints"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_clearBreakpoint, 2, fxID(the, "clearBreakpoint"), XS_GET_ONLY); slot = fxNextHostFunctionProperty(the, slot, fx_xs_debug_setBreakpoint, 2, fxID(the, "setBreakpoint"), XS_GET_ONLY); property = fxNextSlotProperty(the, property, the->stack, fxID(the, "debug"), XS_GET_ONLY); the->stack++; #endif slot = fxSetGlobalProperty(the, mxGlobal.value.reference, fxID(the, "xs"), C_NULL); slot->flag = XS_GET_ONLY; slot->kind = the->stack->kind; slot->value = the->stack->value; the->stack++; }
void fxBuildArray(txMachine* the) { static const txHostFunctionBuilder gx_Array_prototype_builders[] = { { fx_Array_prototype_concat, 1, _concat }, { fx_Array_prototype_copyWithin, 2, _copyWithin }, { fx_Array_prototype_entries, 0, _entries }, { fx_Array_prototype_every, 1, _every }, { fx_Array_prototype_fill, 1, _fill }, { fx_Array_prototype_filter, 1, _filter }, { fx_Array_prototype_find, 1, _find }, { fx_Array_prototype_findIndex, 1, _findIndex }, { fx_Array_prototype_forEach, 1, _forEach }, { fx_Array_prototype_indexOf, 1, _indexOf }, { fx_Array_prototype_join, 1, _join }, { fx_Array_prototype_keys, 0, _keys }, { fx_Array_prototype_lastIndexOf, 1, _lastIndexOf }, { fx_Array_prototype_map, 1, _map }, { fx_Array_prototype_pop, 0, _pop }, { fx_Array_prototype_push, 1, _push }, { fx_Array_prototype_reduce, 1, _reduce }, { fx_Array_prototype_reduceRight, 1, _reduceRight }, { fx_Array_prototype_reverse, 0, _reverse }, { fx_Array_prototype_shift, 0, _shift }, { fx_Array_prototype_slice, 2, _slice }, { fx_Array_prototype_some, 1, _some }, { fx_Array_prototype_sort, 1, _sort }, { fx_Array_prototype_splice, 2, _splice }, { fx_Array_prototype_join, 0, _toString }, { fx_Array_prototype_join, 0, _toLocaleString }, { fx_Array_prototype_unshift, 1, _unshift }, { fx_Array_prototype_values, 0, _values }, { fx_Array_prototype_values, 0, _Symbol_iterator }, { C_NULL, 0, 0 }, }; static const txHostFunctionBuilder gx_Array_builders[] = { { fx_Array_from, 1, _from }, { fx_Array_isArray, 1, _isArray }, { fx_Array_of, 1, _of }, { C_NULL, 0, 0 }, }; const txHostFunctionBuilder* builder; txSlot* slot; txSlot* unscopable; mxPush(mxObjectPrototype); slot = fxLastProperty(the, fxNewArrayInstance(the)); slot = fxNextHostAccessorProperty(the, slot, fx_Array_prototype_length_get, fx_Array_prototype_length_set, mxID(_length), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG); for (builder = gx_Array_prototype_builders; builder->callback; builder++) slot = fxNextHostFunctionProperty(the, slot, builder->callback, builder->length, mxID(builder->id), XS_DONT_ENUM_FLAG); slot = fxNextBooleanProperty(the, slot, 1, mxID(_Symbol_isConcatSpreadable), XS_DONT_ENUM_FLAG); slot = fxNextStringProperty(the, slot, "Array", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); mxPush(mxObjectPrototype); unscopable = fxLastProperty(the, fxNewObjectInstance(the)); unscopable = fxNextBooleanProperty(the, unscopable, 1, mxID(_find), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); unscopable = fxNextBooleanProperty(the, unscopable, 1, mxID(_findIndex), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); unscopable = fxNextBooleanProperty(the, unscopable, 1, mxID(_fill), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); unscopable = fxNextBooleanProperty(the, unscopable, 1, mxID(_copyWithin), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); unscopable = fxNextBooleanProperty(the, unscopable, 1, mxID(_entries), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); unscopable = fxNextBooleanProperty(the, unscopable, 1, mxID(_keys), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); unscopable = fxNextBooleanProperty(the, unscopable, 1, mxID(_values), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); slot = fxNextSlotProperty(the, slot, the->stack++, mxID(_Symbol_unscopables), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); mxArrayPrototype = *the->stack; slot = fxLastProperty(the, fxNewHostConstructorGlobal(the, fx_Array, 1, mxID(_Array), XS_GET_ONLY)); for (builder = gx_Array_builders; builder->callback; builder++) slot = fxNextHostFunctionProperty(the, slot, builder->callback, builder->length, mxID(builder->id), XS_DONT_ENUM_FLAG); slot = fxNextHostAccessorProperty(the, slot, fx_species_get, C_NULL, mxID(_Symbol_species), XS_DONT_ENUM_FLAG); the->stack++; mxPush(mxIteratorPrototype); slot = fxLastProperty(the, fxNewObjectInstance(the)); slot = fxNextHostFunctionProperty(the, slot, fx_Array_prototype_entries_next, 0, mxID(_next), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG); slot = fxNextStringProperty(the, slot, "Array Iterator", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); mxPull(mxArrayEntriesIteratorPrototype); mxPush(mxIteratorPrototype); slot = fxLastProperty(the, fxNewObjectInstance(the)); slot = fxNextHostFunctionProperty(the, slot, fx_Array_prototype_keys_next, 0, mxID(_next), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG); slot = fxNextStringProperty(the, slot, "Array Iterator", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); mxPull(mxArrayKeysIteratorPrototype); mxPush(mxIteratorPrototype); slot = fxLastProperty(the, fxNewObjectInstance(the)); slot = fxNextHostFunctionProperty(the, slot, fx_Array_prototype_values_next, 0, mxID(_next), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG); slot = fxNextStringProperty(the, slot, "Array Iterator", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); mxPull(mxArrayValuesIteratorPrototype); mxPush(mxObjectPrototype); slot = fxLastProperty(the, fxNewObjectInstance(the)); slot = fxNextStringProperty(the, slot, "Arguments", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); mxParametersPrototype = *the->stack; the->stack++; mxPush(mxObjectPrototype); slot = fxLastProperty(the, fxNewObjectInstance(the)); slot = fxNextHostAccessorProperty(the, slot, fx_Arguments_prototype_callee, fx_Arguments_prototype_callee, mxID(_callee), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); slot = fxNextHostAccessorProperty(the, slot, fx_Arguments_prototype_caller, fx_Arguments_prototype_caller, mxID(_caller), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); slot = fxNextHostFunctionProperty(the, slot, fx_Array_prototype_values, 0, mxID(_Symbol_iterator), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG); slot = fxNextStringProperty(the, slot, "Arguments", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG); mxArgumentsStrictPrototype = *the->stack; the->stack++; }