UNPKG

1.48 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _index = require("./index.js");
9
10var _invariant = _interopRequireDefault(require("../invariant.js"));
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14/**
15 * Copyright (c) 2017-present, Facebook, Inc.
16 * All rights reserved.
17 *
18 * This source code is licensed under the BSD-style license found in the
19 * LICENSE file in the root directory of this source tree. An additional grant
20 * of patent rights can be found in the PATENTS file in the same directory.
21 */
22
23/* Abstract base class for all function objects */
24class FunctionValue extends _index.ObjectValue {
25 constructor(realm, intrinsicName) {
26 super(realm, realm.intrinsics.FunctionPrototype, intrinsicName);
27 }
28
29 getName() {
30 throw new Error("Abstract method");
31 }
32
33 getKind() {
34 return "Function";
35 }
36
37 getLength() {
38 let binding = this.properties.get("length");
39 (0, _invariant.default)(binding);
40 let desc = binding.descriptor;
41 (0, _invariant.default)(desc);
42 let value = desc.value;
43 if (!(value instanceof _index.NumberValue)) return undefined;
44 return value.value;
45 }
46
47 hasDefaultLength() {
48 (0, _invariant.default)(false, "abstract method; please override");
49 }
50
51 getDebugName() {
52 return super.getDebugName() || this.getName();
53 }
54
55}
56
57exports.default = FunctionValue;
58//# sourceMappingURL=FunctionValue.js.map
\No newline at end of file