"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 _completions = require("../completions.js"); var _singletons = require("../singletons.js"); 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. */ /* Built-in Function Objects */ var NativeFunctionValue = function (_ECMAScriptFunctionVa) { _inherits(NativeFunctionValue, _ECMAScriptFunctionVa); function NativeFunctionValue(realm, intrinsicName, name, length, callback) { var constructor = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; _classCallCheck(this, NativeFunctionValue); var _this = _possibleConstructorReturn(this, (NativeFunctionValue.__proto__ || Object.getPrototypeOf(NativeFunctionValue)).call(this, realm, intrinsicName)); _this.$ThisMode = "strict"; _this.$HomeObject = undefined; _this.$FunctionKind = "normal"; _this.$Call = function (thisArgument, argsList) { return _singletons.Functions.$Call(_this.$Realm, _this, thisArgument, argsList); }; if (constructor) { _this.$ConstructorKind = "base"; _this.$Construct = function (argumentsList, newTarget) { return _singletons.Functions.$Construct(_this.$Realm, _this, argumentsList, newTarget); }; } _this.$Environment = realm.$GlobalEnv; _this.callback = callback; _this.length = length; _this.$DefineOwnProperty("length", { value: new _index.NumberValue(realm, length), writable: false, configurable: true, enumerable: false }); if (name) { if (name instanceof _index.SymbolValue) { _this.name = name.$Description ? "[" + name.$Description.throwIfNotConcreteString().value + "]" : "[native]"; } else { _this.name = name; } _this.$DefineOwnProperty("name", { value: new _index.StringValue(realm, _this.name), writable: false, configurable: true, enumerable: false }); } else { _this.name = "native"; } return _this; } _createClass(NativeFunctionValue, [{ key: "getTrackedPropertyNames", value: function getTrackedPropertyNames() { return NativeFunctionValue.trackedPropertyNames; } }, { key: "hasDefaultLength", value: function hasDefaultLength() { return this.getLength() === this.length; } }, { key: "getName", // Override. value: function getName() { return this.name; } }, { key: "callCallback", value: function callCallback(context, argsList, newTarget) { var originalLength = argsList.length; for (var i = 0; i < this.length; i++) { argsList[i] = argsList[i] || this.$Realm.intrinsics.undefined; } return new _completions.ReturnCompletion(this.callback(context, argsList, originalLength, newTarget), this.$Realm.currentLocation); } // for Proxy }]); return NativeFunctionValue; }(_index.ECMAScriptFunctionValue); NativeFunctionValue.trackedPropertyNames = _index.ObjectValue.trackedPropertyNames.concat("$RevocableProxy"); exports.default = NativeFunctionValue; //# sourceMappingURL=NativeFunctionValue.js.map