prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
59 lines (45 loc) • 1.92 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _index = require("./index.js");
var _invariant = require("../invariant.js");
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* Abstract base class for all function objects */
class FunctionValue extends _index.ObjectValue {
constructor(realm, intrinsicName) {
super(realm, realm.intrinsics.FunctionPrototype, intrinsicName);
}
// Indicates whether this function has been referenced by a __residual call.
// If true, the serializer will check that the function does not access any
// identifiers defined outside of the local scope.
// Allows for residual function with inference of parameters
getName() {
throw new Error("Abstract method");
}
getKind() {
return "Function";
}
getLength() {
let binding = this.properties.get("length");
(0, _invariant2.default)(binding);
let desc = binding.descriptor;
(0, _invariant2.default)(desc);
let value = desc.value;
if (!(value instanceof _index.NumberValue)) return undefined;
return value.value;
}
hasDefaultLength() {
(0, _invariant2.default)(false, "abstract method; please override");
}
}
exports.default = FunctionValue; /**
* 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.
*/
//# sourceMappingURL=FunctionValue.js.map