"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); /** * 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. */ exports.default = function (ast, strictCode, env, realm) { strictCode = (0, _strict2.default)(ast); (0, _Program.GlobalDeclarationInstantiation)(realm, ast, env, strictCode); var partialBody = []; var val = void 0; var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = ast.body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var node = _step.value; if (node.type !== "FunctionDeclaration") { var _env$partiallyEvaluat = env.partiallyEvaluateCompletionDeref(node, strictCode), _env$partiallyEvaluat2 = _slicedToArray(_env$partiallyEvaluat, 3), potentialVal = _env$partiallyEvaluat2[0], partialAst = _env$partiallyEvaluat2[1], nio = _env$partiallyEvaluat2[2]; var _iteratorNormalCompletion2 = true; var _didIteratorError2 = false; var _iteratorError2 = undefined; try { for (var _iterator2 = nio[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { var ioAst = _step2.value; partialBody.push(ioAst); } } catch (err) { _didIteratorError2 = true; _iteratorError2 = err; } finally { try { if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } } finally { if (_didIteratorError2) { throw _iteratorError2; } } } partialBody.push(partialAst); if (!(potentialVal instanceof _index.EmptyValue)) val = potentialVal; } else { // TODO: this goes away once residual functions are partially evaluated. partialBody.push(node); } } // todo: compute a global fixed point by invoking each escaped (i.e. call back) // function with dummy arguments and joining their effects with the // global state until there is no invocation that causes further changes to // the global state. } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } var result = val || realm.intrinsics.empty; return [result, t.program(partialBody, ast.directives), []]; }; var _completions = require("../completions.js"); var _index = require("../values/index.js"); var _Program = require("../evaluators/Program.js"); var _strict = require("../utils/strict.js"); var _strict2 = _interopRequireDefault(_strict); var _babelTypes = require("babel-types"); var t = _interopRequireWildcard(_babelTypes); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } //# sourceMappingURL=Program.js.map