prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
612 lines (439 loc) • 26.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _index = require("../../domains/index.js");
var _errors = require("../../errors.js");
var _realm = require("../../realm.js");
var _index2 = require("../../values/index.js");
var _index3 = require("../../methods/index.js");
var _singletons = require("../../singletons.js");
var _generator = require("../../utils/generator.js");
var _invariant = _interopRequireDefault(require("../../invariant.js"));
var _descriptors = require("../../descriptors.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
//import { AbruptCompletion } from "../../completions.js";
function snapshotToObjectAndRemoveProperties(to, delayedSources) {
// If to has properties, we better remove them because after the temporal call to Object.assign we don't know their values anymore
if (to.hasStringOrSymbolProperties()) {
// Preserve them in a snapshot and add the snapshot to the sources
delayedSources.push(to.getSnapshot({
removeProperties: true
}));
}
}
function handleObjectAssignSnapshot(to, frm, frm_was_partial, delayedSources) {
if (to instanceof _index2.AbstractObjectValue && to.values.isTop()) {
// We don't know which objects to make partial and making all objects partial is failure in itself
_index2.AbstractValue.reportIntrospectionError(to);
throw new _errors.FatalError();
} else {
if (frm instanceof _index2.ObjectValue && frm.mightBeLeakedObject()) {
// "frm" is leaked, so it might contain properties that potentially overwrite
// properties already on the "to" object.
snapshotToObjectAndRemoveProperties(to, delayedSources); // it's not safe to trust any of its values
delayedSources.push(frm);
} else if (frm_was_partial) {
// "frm" is partial, so it might contain properties that potentially overwrite
// properties already on the "to" object.
snapshotToObjectAndRemoveProperties(to, delayedSources);
if (frm instanceof _index2.AbstractObjectValue && frm.kind === "explicit conversion to object") {
// Make it implicit again since it is getting delayed into an Object.assign call.
delayedSources.push(frm.args[0]);
} else {
let frmSnapshot = frm.getSnapshot();
frm.temporalAlias = frmSnapshot;
frm.makePartial();
delayedSources.push(frmSnapshot);
}
} else {
return false;
}
}
return true;
}
function copyKeys(realm, keys, from, to) {
// c. Repeat for each element nextKey of keys in List order,
for (let nextKey of keys) {
// i. Let desc be ? from.[[GetOwnProperty]](nextKey).
let desc = from.$GetOwnProperty(nextKey); // ii. If desc is not undefined and desc.[[Enumerable]] is true, then
if (desc && desc.throwIfNotConcrete(realm).enumerable) {
_singletons.Properties.ThrowIfMightHaveBeenDeleted(desc); // 1. Let propValue be ? Get(from, nextKey).
let propValue = (0, _index3.Get)(realm, from, nextKey); // 2. Perform ? Set(to, nextKey, propValue, true).
_singletons.Properties.Set(realm, to, nextKey, propValue, true);
}
}
}
function applyObjectAssignSource(realm, nextSource, to, delayedSources, to_must_be_partial) {
let keys, frm; // a. If nextSource is undefined or null, let keys be a new empty List.
if ((0, _index3.HasSomeCompatibleType)(nextSource, _index2.NullValue, _index2.UndefinedValue)) {
return to_must_be_partial;
} // b. Else,
// i. Let from be ToObject(nextSource).
frm = _singletons.To.ToObject(realm, nextSource); // ii. Let keys be ? from.[[OwnPropertyKeys]]().
let frm_was_partial = frm.isPartialObject();
if (frm_was_partial) {
if (!to.isSimpleObject() || !frm.isSimpleObject()) {
// If an object is not a simple object, it may have getters on it that can
// mutate any state as a result. We don't yet support this.
_index2.AbstractValue.reportIntrospectionError(nextSource);
throw new _errors.FatalError();
}
to_must_be_partial = true;
}
keys = frm.$OwnPropertyKeys(true);
if (to_must_be_partial) {
handleObjectAssignSnapshot(to, frm, frm_was_partial, delayedSources);
} // c. Repeat for each element nextKey of keys in List order,
(0, _invariant.default)(frm, "from required");
(0, _invariant.default)(keys, "keys required");
copyKeys(realm, keys, frm, to);
return to_must_be_partial;
}
function tryAndApplySourceOrRecover(realm, nextSource, to, delayedSources, to_must_be_partial) {
(0, _invariant.default)(!realm.instantRender.enabled);
let effects;
let savedSuppressDiagnostics = realm.suppressDiagnostics;
try {
realm.suppressDiagnostics = true;
effects = realm.evaluateForEffects(() => {
to_must_be_partial = applyObjectAssignSource(realm, nextSource, to, delayedSources, to_must_be_partial);
return realm.intrinsics.undefined;
}, undefined, "tryAndApplySourceOrRecover");
} catch (e) {
(0, _invariant.default)(nextSource !== realm.intrinsics.null && nextSource !== realm.intrinsics.undefined);
let frm = _singletons.To.ToObject(realm, nextSource);
if (e instanceof _errors.FatalError && to.isSimpleObject()) {
to_must_be_partial = true;
let frm_was_partial = frm.isPartialObject();
let didSnapshot = handleObjectAssignSnapshot(to, frm, frm_was_partial, delayedSources);
if (!didSnapshot) {
delayedSources.push(frm);
} // Leak the frm value because it can have getters on it
_singletons.Leak.value(realm, frm);
return to_must_be_partial;
}
throw e;
} finally {
realm.suppressDiagnostics = savedSuppressDiagnostics;
}
realm.applyEffects(effects);
realm.returnOrThrowCompletion(effects.result);
return to_must_be_partial;
}
function _default(realm) {
// ECMA262 19.1.1.1
let func = new _index2.NativeFunctionValue(realm, "Object", "Object", 1, (context, [value], argCount, NewTarget) => {
// 1. If NewTarget is neither undefined nor the active function, then
if (NewTarget && NewTarget !== func) {
// a. Return ? OrdinaryCreateFromConstructor(NewTarget, "%ObjectPrototype%").
return _singletons.Create.OrdinaryCreateFromConstructor(realm, NewTarget, "ObjectPrototype");
} // 2. If value is null, undefined or not supplied, return ObjectCreate(%ObjectPrototype%).
if ((0, _index3.HasSomeCompatibleType)(value, _index2.NullValue, _index2.UndefinedValue)) {
return _singletons.Create.ObjectCreate(realm, realm.intrinsics.ObjectPrototype);
} // 3. Return ToObject(value).
return _singletons.To.ToObject(realm, value);
});
function performConditionalObjectAssign(condValue, consequentVal, alternateVal, to, prefixSources, suffixSources) {
// After applying a Object.assign on one path of the conditional value,
// that path may have had snapshotting applied to the "to" value. If
// that is the case and the other path has not had snapshotting applied
// then we need to make sure we materialize out the properties of the object.
let conditionallySnapshotted = false;
const evaluateForEffects = (val, materializeIfSnapshottingIsConditional) => realm.evaluateForEffects(() => {
let wasSnapshotedBeforehand = to instanceof _index2.ObjectValue && to.temporalAlias !== undefined;
performObjectAssign(to, [...prefixSources, val, ...suffixSources]); // Check if snapshotting occured
if (to instanceof _index2.ObjectValue) {
if (materializeIfSnapshottingIsConditional && to.temporalAlias === undefined && conditionallySnapshotted) {
// We don't really want to leak, but rather materialize the object
// so we assign its bindings correctly.
_singletons.Materialize.materializeObject(realm, to);
} else if (!wasSnapshotedBeforehand && to.temporalAlias !== undefined && !conditionallySnapshotted) {
conditionallySnapshotted = true;
}
}
return realm.intrinsics.undefined;
}, null, "performConditionalObjectAssign consequent"); // First evaluate both sides to see if snapshotting occurs on either side
evaluateForEffects(consequentVal, false);
evaluateForEffects(alternateVal, false); // Now evaluate both sides again, but this time materialize if snapshotting is
// being used conditionally.
realm.evaluateWithAbstractConditional(condValue, () => evaluateForEffects(consequentVal, true), () => evaluateForEffects(alternateVal, true));
}
function performObjectAssign(target, sources) {
// 1. Let to be ? ToObject(target).
let to = _singletons.To.ToObject(realm, target);
let to_must_be_partial = false; // 2. If only one argument was passed, return to.
if (!sources.length) return to; // Check if any sources are conditionals and if so, fork the work
// into many subsequent objectAssign calls for each branch of the conditional
for (let i = 0; i < sources.length; i++) {
let nextSource = sources[i];
if (nextSource instanceof _index2.AbstractValue) {
if (nextSource.kind === "conditional") {
let [condValue, consequentVal, alternateVal] = nextSource.args;
(0, _invariant.default)(condValue instanceof _index2.AbstractValue);
let prefixSources = sources.slice(0, i);
let suffixSources = sources.slice(i + 1);
performConditionalObjectAssign(condValue, consequentVal, alternateVal, to, prefixSources, suffixSources);
return to;
} else if (nextSource.kind === "||") {
let [leftValue, rightValue] = nextSource.args;
(0, _invariant.default)(leftValue instanceof _index2.AbstractValue);
let prefixSources = sources.slice(0, i);
let suffixSources = sources.slice(i + 1);
performConditionalObjectAssign(leftValue, leftValue, rightValue, to, prefixSources, suffixSources);
return to;
} else if (nextSource.kind === "&&") {
let [leftValue, rightValue] = nextSource.args;
(0, _invariant.default)(leftValue instanceof _index2.AbstractValue);
let prefixSources = sources.slice(0, i);
let suffixSources = sources.slice(i + 1);
performConditionalObjectAssign(leftValue, rightValue, leftValue, to, prefixSources, suffixSources);
return to;
}
}
} // 3. Let sources be the List of argument values starting with the second argument.
sources;
let delayedSources = []; // 4. For each element nextSource of sources, in ascending index order,
for (let nextSource of sources) {
if (realm.isInPureScope() && !realm.instantRender.enabled) {
realm.evaluateWithPossibleThrowCompletion(() => {
to_must_be_partial = tryAndApplySourceOrRecover(realm, nextSource, to, delayedSources, to_must_be_partial);
return realm.intrinsics.undefined;
}, _index.TypesDomain.topVal, _index.ValuesDomain.topVal);
} else {
to_must_be_partial = applyObjectAssignSource(realm, nextSource, to, delayedSources, to_must_be_partial);
}
} // 5. Return to.
if (to_must_be_partial) {
// if to has properties, we copy and delay them (at this stage we do not need to remove them)
if (to.hasStringOrSymbolProperties()) {
let toSnapshot = to.getSnapshot();
delayedSources.push(toSnapshot);
}
to.makePartial(); // We already established above that to is simple,
// but now that it is partial we need to set the _isSimple flag.
to.makeSimple();
_index2.AbstractValue.createTemporalObjectAssign(realm, to, delayedSources);
}
return to;
} // ECMA262 19.1.2.1
if (!realm.isCompatibleWith(realm.MOBILE_JSC_VERSION)) {
func.defineNativeMethod("assign", 2, (context, [target, ...sources]) => performObjectAssign(target, sources));
} // ECMA262 19.1.2.2
func.defineNativeMethod("create", 2, (context, [O, Properties]) => {
// 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
if (!(0, _index3.HasSomeCompatibleType)(O, _index2.ObjectValue, _index2.NullValue)) {
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
} // 2. Let obj be ObjectCreate(O).
let obj = _singletons.Create.ObjectCreate(realm, O.throwIfNotConcrete()); // 3. If Properties is not undefined, then
if (!Properties.mightBeUndefined()) {
// a. Return ? ObjectDefineProperties(obj, Properties).
return _singletons.Properties.ObjectDefineProperties(realm, obj, Properties);
}
Properties.throwIfNotConcrete(); // 4. Return obj.
return obj;
}); // ECMA262 19.1.2.3
func.defineNativeMethod("defineProperties", 2, (context, [O, Properties]) => {
// 1. Return ? ObjectDefineProperties(O, Properties).
return _singletons.Properties.ObjectDefineProperties(realm, O, Properties);
}); // ECMA262 19.1.2.4
func.defineNativeMethod("defineProperty", 3, (context, [O, P, Attributes]) => {
// 1. If Type(O) is not Object, throw a TypeError exception.
if (!O.mightBeObject()) {
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
}
O = O.throwIfNotObject(); // 2. Let key be ? ToPropertyKey(P).
let key = _singletons.To.ToPropertyKey(realm, P.throwIfNotConcrete()); // 3. Let desc be ? ToPropertyDescriptor(Attributes).
let desc = _singletons.To.ToPropertyDescriptor(realm, Attributes); // 4. Perform ? DefinePropertyOrThrow(O, key, desc).
_singletons.Properties.DefinePropertyOrThrow(realm, O, key, desc); // 4. Return O.
return O;
}); // ECMA262 19.1.2.5
func.defineNativeMethod("freeze", 1, (context, [O]) => {
// 1. If Type(O) is not Object, return O.
if (!O.mightBeObject()) return O; // 2. Let status be ? SetIntegrityLevel(O, "frozen").
O = O.throwIfNotConcreteObject();
let status = (0, _index3.SetIntegrityLevel)(realm, O, "frozen"); // 3. If status is false, throw a TypeError exception.
if (status === false) {
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
} // 4. Return O.
return O;
}); // ECMA262 19.1.2.6
let getOwnPropertyDescriptor = func.defineNativeMethod("getOwnPropertyDescriptor", 2, (context, [O, P]) => {
// 1. Let obj be ? ToObject(O).
let obj = _singletons.To.ToObject(realm, O); // 2. Let key be ? ToPropertyKey(P).
let key = _singletons.To.ToPropertyKey(realm, P.throwIfNotConcrete()); // 3. Let desc be ? obj.[[GetOwnProperty]](key).
let desc = obj.$GetOwnProperty(key); // If we are returning a descriptor with a NativeFunctionValue
// and it has no intrinsic name, then we create a temporal as this
// can only be done at runtime
if (desc instanceof _descriptors.PropertyDescriptor) {
let getterFunc = desc.get;
if (getterFunc instanceof _index2.NativeFunctionValue && getterFunc.intrinsicName === undefined && realm.useAbstractInterpretation) {
(0, _invariant.default)(P instanceof _index2.Value); // this will create a property descriptor at runtime
let result = _index2.AbstractValue.createTemporalFromBuildFunction(realm, _index2.ObjectValue, [getOwnPropertyDescriptor, obj, P], (0, _generator.createOperationDescriptor)("OBJECT_PROTO_GET_OWN_PROPERTY_DESCRIPTOR"));
(0, _invariant.default)(result instanceof _index2.AbstractObjectValue);
result.makeSimple();
let get = (0, _index3.Get)(realm, result, "get");
let set = (0, _index3.Get)(realm, result, "set");
(0, _invariant.default)(get instanceof _index2.AbstractValue);
(0, _invariant.default)(set instanceof _index2.AbstractValue);
desc = new _descriptors.PropertyDescriptor({
get,
set,
enumerable: false,
configurable: true
});
}
} // 4. Return FromPropertyDescriptor(desc).
let propDesc = _singletons.Properties.FromPropertyDescriptor(realm, desc);
return propDesc;
}); // ECMA262 19.1.2.7
func.defineNativeMethod("getOwnPropertyNames", 1, (context, [O]) => {
// 1. Return ? GetOwnPropertyKeys(O, String).
return (0, _index3.GetOwnPropertyKeys)(realm, O, _index2.StringValue);
}); // ECMA262 19.1.2.8
func.defineNativeMethod("getOwnPropertyDescriptors", 1, (context, [O]) => {
// 1. Let obj be ? ToObject(O).
let obj = _singletons.To.ToObject(realm, O); // 2. Let ownKeys be ? obj.[[OwnPropertyKeys]]().
let ownKeys = obj.$OwnPropertyKeys(); // 3. Let descriptors be ! ObjectCreate(%ObjectPrototype%).
let descriptors = _singletons.Create.ObjectCreate(realm, realm.intrinsics.ObjectPrototype); // 4. Repeat, for each element key of ownKeys in List order,
for (let key of ownKeys) {
// a. Let desc be ? obj.[[GetOwnProperty]](key).
let desc = obj.$GetOwnProperty(key);
if (desc !== undefined) _singletons.Properties.ThrowIfMightHaveBeenDeleted(desc); // b. Let descriptor be ! FromPropertyDescriptor(desc).
let descriptor = _singletons.Properties.FromPropertyDescriptor(realm, desc); // c. If descriptor is not undefined, perform ! CreateDataProperty(descriptors, key, descriptor).
if (!(descriptor instanceof _index2.UndefinedValue)) _singletons.Create.CreateDataProperty(realm, descriptors, key, descriptor);
} // 5. Return descriptors.
return descriptors;
}); // ECMA262 19.1.2.9
if (!realm.isCompatibleWith(realm.MOBILE_JSC_VERSION) && !realm.isCompatibleWith("mobile")) {
let getOwnPropertySymbols = func.defineNativeMethod("getOwnPropertySymbols", 1, (context, [O]) => {
if (O instanceof _index2.AbstractValue && realm.isInPureScope()) {
let obj = O instanceof _index2.AbstractObjectValue ? O : _singletons.To.ToObject(realm, O);
realm.callReportObjectGetOwnProperties(obj);
return _index2.ArrayValue.createTemporalWithWidenedNumericProperty(realm, [getOwnPropertySymbols, obj], (0, _generator.createOperationDescriptor)("UNKNOWN_ARRAY_METHOD_CALL"));
} else if (_index2.ArrayValue.isIntrinsicAndHasWidenedNumericProperty(O)) {
realm.callReportObjectGetOwnProperties(O);
return _index2.ArrayValue.createTemporalWithWidenedNumericProperty(realm, [getOwnPropertySymbols, O], (0, _generator.createOperationDescriptor)("UNKNOWN_ARRAY_METHOD_CALL"));
} // Return ? GetOwnPropertyKeys(O, Symbol).
return (0, _index3.GetOwnPropertyKeys)(realm, O, _index2.SymbolValue);
});
} // ECMA262 19.1.2.10
func.defineNativeMethod("getPrototypeOf", 1, (context, [O]) => {
// 1. Let obj be ? ToObject(O).
let obj = _singletons.To.ToObject(realm, O); // 2. Return ? obj.[[GetPrototypeOf]]().
return obj.$GetPrototypeOf();
}); // ECMA262 19.1.2.11
func.defineNativeMethod("is", 2, (context, [value1, value2]) => {
// 1. Return SameValue(value1, value2).
return new _index2.BooleanValue(realm, (0, _index3.SameValuePartial)(realm, value1, value2));
}); // ECMA262 19.1.2.12
func.defineNativeMethod("isExtensible", 1, (context, [O]) => {
// 1. If Type(O) is not Object, return false.
if (!O.mightBeObject()) return realm.intrinsics.false;
O = O.throwIfNotObject(); // 2. Return ? IsExtensible(O).
return new _index2.BooleanValue(realm, (0, _index3.IsExtensible)(realm, O));
}); // ECMA262 19.1.2.13
func.defineNativeMethod("isFrozen", 1, (context, [O]) => {
// 1. If Type(O) is not Object, return true.
if (!O.mightBeObject()) return realm.intrinsics.true; // 2. Return ? TestIntegrityLevel(O, "frozen").
O = O.throwIfNotConcreteObject();
return new _index2.BooleanValue(realm, (0, _index3.TestIntegrityLevel)(realm, O, "frozen"));
}); // ECMA262 19.1.2.14
func.defineNativeMethod("isSealed", 1, (context, [O]) => {
// 1. If Type(O) is not Object, return true.
if (!O.mightBeObject()) return realm.intrinsics.true; // 2. Return ? TestIntegrityLevel(O, "sealed").
O = O.throwIfNotConcreteObject();
return new _index2.BooleanValue(realm, (0, _index3.TestIntegrityLevel)(realm, O, "sealed"));
}); // ECMA262 19.1.2.15
let objectKeys = func.defineNativeMethod("keys", 1, (context, [O]) => {
// 1. Let obj be ? ToObject(O).
let obj = _singletons.To.ToObject(realm, O); // If we're in pure scope and the items are completely abstract,
// then create an abstract temporal with an array kind
if (realm.isInPureScope() && obj instanceof _index2.AbstractObjectValue) {
let array = _index2.ArrayValue.createTemporalWithWidenedNumericProperty(realm, [objectKeys, obj], (0, _generator.createOperationDescriptor)("UNKNOWN_ARRAY_METHOD_CALL"));
return array;
} else if (_index2.ArrayValue.isIntrinsicAndHasWidenedNumericProperty(obj)) {
return _index2.ArrayValue.createTemporalWithWidenedNumericProperty(realm, [objectKeys, obj], (0, _generator.createOperationDescriptor)("UNKNOWN_ARRAY_METHOD_CALL"));
} // 2. Let nameList be ? EnumerableOwnProperties(obj, "key").
let nameList = (0, _index3.EnumerableOwnProperties)(realm, obj.throwIfNotConcreteObject(), "key"); // 3. Return CreateArrayFromList(nameList).
return _singletons.Create.CreateArrayFromList(realm, nameList);
}); // ECMA262 9.1.2.16
if (!realm.isCompatibleWith(realm.MOBILE_JSC_VERSION) && !realm.isCompatibleWith("mobile")) {
let objectValues = func.defineNativeMethod("values", 1, (context, [O]) => {
// 1. Let obj be ? ToObject(O).
let obj = _singletons.To.ToObject(realm, O);
if (realm.isInPureScope()) {
// If we're in pure scope and the items are completely abstract,
// then create an abstract temporal with an array kind
if (obj instanceof _index2.AbstractObjectValue) {
let array = _index2.ArrayValue.createTemporalWithWidenedNumericProperty(realm, [objectValues, obj], (0, _generator.createOperationDescriptor)("UNKNOWN_ARRAY_METHOD_CALL"));
return array;
} else if (_index2.ArrayValue.isIntrinsicAndHasWidenedNumericProperty(obj)) {
return _index2.ArrayValue.createTemporalWithWidenedNumericProperty(realm, [objectValues, obj], (0, _generator.createOperationDescriptor)("UNKNOWN_ARRAY_METHOD_CALL"));
}
} // 2. Let nameList be ? EnumerableOwnProperties(obj, "value").
let nameList = (0, _index3.EnumerableOwnProperties)(realm, obj.throwIfNotConcreteObject(), "value"); // 3. Return CreateArrayFromList(nameList).
return _singletons.Create.CreateArrayFromList(realm, nameList);
});
} // ECMA262 19.1.2.17
if (!realm.isCompatibleWith(realm.MOBILE_JSC_VERSION) && !realm.isCompatibleWith("mobile")) {
let objectEntries = func.defineNativeMethod("entries", 1, (context, [O]) => {
// 1. Let obj be ? ToObject(O).
let obj = _singletons.To.ToObject(realm, O); // If we're in pure scope and the items are completely abstract,
// then create an abstract temporal with an array kind
if (realm.isInPureScope() && obj instanceof _index2.AbstractObjectValue) {
let array = _index2.ArrayValue.createTemporalWithWidenedNumericProperty(realm, [objectEntries, obj], (0, _generator.createOperationDescriptor)("UNKNOWN_ARRAY_METHOD_CALL"));
return array;
} else if (_index2.ArrayValue.isIntrinsicAndHasWidenedNumericProperty(obj)) {
return _index2.ArrayValue.createTemporalWithWidenedNumericProperty(realm, [objectEntries, obj], (0, _generator.createOperationDescriptor)("UNKNOWN_ARRAY_METHOD_CALL"));
} // 2. Let nameList be ? EnumerableOwnProperties(obj, "key+value").
let nameList = (0, _index3.EnumerableOwnProperties)(realm, obj.throwIfNotConcreteObject(), "key+value"); // 3. Return CreateArrayFromList(nameList).
return _singletons.Create.CreateArrayFromList(realm, nameList);
});
} // ECMA262 19.1.2.18
func.defineNativeMethod("preventExtensions", 1, (context, [O]) => {
// 1. If Type(O) is not Object, return O.
if (!O.mightBeObject()) return O; // 2. Let status be ? O.[[PreventExtensions]]().
O = O.throwIfNotConcreteObject();
let status = O.$PreventExtensions(); // 3. If status is false, throw a TypeError exception.
if (status === false) {
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
} // 4. Return O.
return O;
}); // ECMA262 19.1.2.19
func.defineNativeMethod("seal", 1, (context, [O]) => {
// 1. If Type(O) is not Object, return O.
if (!O.mightBeObject()) return O; // 2. Let status be ? SetIntegrityLevel(O, "sealed").
O = O.throwIfNotConcreteObject();
let status = (0, _index3.SetIntegrityLevel)(realm, O, "sealed"); // 3. If status is false, throw a TypeError exception.
if (status === false) {
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
} // 4. Return O.
return O;
}); // ECMA262 19.1.2.20
if (!realm.isCompatibleWith(realm.MOBILE_JSC_VERSION) && !realm.isCompatibleWith("mobile")) func.defineNativeMethod("setPrototypeOf", 2, (context, [O, proto]) => {
// 1. Let O be ? RequireObjectCoercible(O).
O = (0, _index3.RequireObjectCoercible)(realm, O); // 2. If Type(proto) is neither Object nor Null, throw a TypeError exception.
if (!(0, _index3.HasSomeCompatibleType)(proto, _index2.ObjectValue, _index2.NullValue)) {
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
} // 3. If Type(O) is not Object, return O.
O = O.throwIfNotConcrete();
if (!(O instanceof _index2.ObjectValue)) return O; // 4. Let status be ? O.[[SetPrototypeOf]](proto).
let status = O.$SetPrototypeOf(proto); // 5. If status is false, throw a TypeError exception.
if (status === false) {
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
} // 6. Return O.
return O;
});
return func;
}
//# sourceMappingURL=Object.js.map