"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _index = require("./index.js"); var _generator = require("../utils/generator.js"); var _invariant = require("../invariant.js"); var _invariant2 = _interopRequireDefault(_invariant); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * 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 */ var FunctionValue = function (_ObjectValue) { _inherits(FunctionValue, _ObjectValue); function FunctionValue(realm, intrinsicName) { _classCallCheck(this, FunctionValue); var _this = _possibleConstructorReturn(this, (FunctionValue.__proto__ || Object.getPrototypeOf(FunctionValue)).call(this, realm, realm.intrinsics.FunctionPrototype, intrinsicName)); _this.parent = realm.generator; return _this; } // 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 _createClass(FunctionValue, [{ key: "getName", value: function getName() { throw new Error("Abstract method"); } }, { key: "getKind", value: function getKind() { return "Function"; } }, { key: "getLength", value: function getLength() { var binding = this.properties.get("length"); (0, _invariant2.default)(binding); var desc = binding.descriptor; (0, _invariant2.default)(desc); var value = desc.value; if (!(value instanceof _index.NumberValue)) return undefined; return value.value; } }, { key: "getParent", value: function getParent() { return this.parent; } }, { key: "hasDefaultLength", value: function hasDefaultLength() { (0, _invariant2.default)(false, "abstract method; please override"); } }]); return FunctionValue; }(_index.ObjectValue); exports.default = FunctionValue; //# sourceMappingURL=FunctionValue.js.map