prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
58 lines (45 loc) • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _index = require("./index.js");
var _invariant = _interopRequireDefault(require("../invariant.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.
*/
/* Abstract base class for all function objects */
class FunctionValue extends _index.ObjectValue {
constructor(realm, intrinsicName) {
super(realm, realm.intrinsics.FunctionPrototype, intrinsicName);
}
getName() {
throw new Error("Abstract method");
}
getKind() {
return "Function";
}
getLength() {
let binding = this.properties.get("length");
(0, _invariant.default)(binding);
let desc = binding.descriptor;
(0, _invariant.default)(desc);
let value = desc.throwIfNotConcrete(this.$Realm).value;
if (!(value instanceof _index.NumberValue)) return undefined;
return value.value;
}
hasDefaultLength() {
(0, _invariant.default)(false, "abstract method; please override");
}
getDebugName() {
return super.getDebugName() || this.getName();
}
}
exports.default = FunctionValue;
//# sourceMappingURL=FunctionValue.js.map