You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

849 lines
22 KiB

4 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _includes = _interopRequireDefault(require("lodash/includes"));
  7. var _repeat = _interopRequireDefault(require("lodash/repeat"));
  8. var _renamer = _interopRequireDefault(require("./lib/renamer"));
  9. var _index = _interopRequireDefault(require("../index"));
  10. var _defaults = _interopRequireDefault(require("lodash/defaults"));
  11. var _binding = _interopRequireDefault(require("./binding"));
  12. var _globals = _interopRequireDefault(require("globals"));
  13. var t = _interopRequireWildcard(require("@babel/types"));
  14. var _cache = require("../cache");
  15. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  16. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  17. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18. function gatherNodeParts(node, parts) {
  19. if (t.isModuleDeclaration(node)) {
  20. if (node.source) {
  21. gatherNodeParts(node.source, parts);
  22. } else if (node.specifiers && node.specifiers.length) {
  23. for (const specifier of node.specifiers) {
  24. gatherNodeParts(specifier, parts);
  25. }
  26. } else if (node.declaration) {
  27. gatherNodeParts(node.declaration, parts);
  28. }
  29. } else if (t.isModuleSpecifier(node)) {
  30. gatherNodeParts(node.local, parts);
  31. } else if (t.isMemberExpression(node)) {
  32. gatherNodeParts(node.object, parts);
  33. gatherNodeParts(node.property, parts);
  34. } else if (t.isIdentifier(node)) {
  35. parts.push(node.name);
  36. } else if (t.isLiteral(node)) {
  37. parts.push(node.value);
  38. } else if (t.isCallExpression(node)) {
  39. gatherNodeParts(node.callee, parts);
  40. } else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
  41. for (const prop of node.properties) {
  42. gatherNodeParts(prop.key || prop.argument, parts);
  43. }
  44. } else if (t.isPrivateName(node)) {
  45. gatherNodeParts(node.id, parts);
  46. } else if (t.isThisExpression(node)) {
  47. parts.push("this");
  48. } else if (t.isSuper(node)) {
  49. parts.push("super");
  50. }
  51. }
  52. const collectorVisitor = {
  53. For(path) {
  54. for (const key of t.FOR_INIT_KEYS) {
  55. const declar = path.get(key);
  56. if (declar.isVar()) {
  57. const parentScope = path.scope.getFunctionParent() || path.scope.getProgramParent();
  58. parentScope.registerBinding("var", declar);
  59. }
  60. }
  61. },
  62. Declaration(path) {
  63. if (path.isBlockScoped()) return;
  64. if (path.isExportDeclaration() && path.get("declaration").isDeclaration()) {
  65. return;
  66. }
  67. const parent = path.scope.getFunctionParent() || path.scope.getProgramParent();
  68. parent.registerDeclaration(path);
  69. },
  70. ReferencedIdentifier(path, state) {
  71. state.references.push(path);
  72. },
  73. ForXStatement(path, state) {
  74. const left = path.get("left");
  75. if (left.isPattern() || left.isIdentifier()) {
  76. state.constantViolations.push(path);
  77. }
  78. },
  79. ExportDeclaration: {
  80. exit(path) {
  81. const {
  82. node,
  83. scope
  84. } = path;
  85. const declar = node.declaration;
  86. if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
  87. const id = declar.id;
  88. if (!id) return;
  89. const binding = scope.getBinding(id.name);
  90. if (binding) binding.reference(path);
  91. } else if (t.isVariableDeclaration(declar)) {
  92. for (const decl of declar.declarations) {
  93. for (const name of Object.keys(t.getBindingIdentifiers(decl))) {
  94. const binding = scope.getBinding(name);
  95. if (binding) binding.reference(path);
  96. }
  97. }
  98. }
  99. }
  100. },
  101. LabeledStatement(path) {
  102. path.scope.getProgramParent().addGlobal(path.node);
  103. path.scope.getBlockParent().registerDeclaration(path);
  104. },
  105. AssignmentExpression(path, state) {
  106. state.assignments.push(path);
  107. },
  108. UpdateExpression(path, state) {
  109. state.constantViolations.push(path);
  110. },
  111. UnaryExpression(path, state) {
  112. if (path.node.operator === "delete") {
  113. state.constantViolations.push(path);
  114. }
  115. },
  116. BlockScoped(path) {
  117. let scope = path.scope;
  118. if (scope.path === path) scope = scope.parent;
  119. scope.getBlockParent().registerDeclaration(path);
  120. },
  121. ClassDeclaration(path) {
  122. const id = path.node.id;
  123. if (!id) return;
  124. const name = id.name;
  125. path.scope.bindings[name] = path.scope.getBinding(name);
  126. },
  127. Block(path) {
  128. const paths = path.get("body");
  129. for (const bodyPath of paths) {
  130. if (bodyPath.isFunctionDeclaration()) {
  131. path.scope.getBlockParent().registerDeclaration(bodyPath);
  132. }
  133. }
  134. }
  135. };
  136. let uid = 0;
  137. class Scope {
  138. constructor(path) {
  139. const {
  140. node
  141. } = path;
  142. const cached = _cache.scope.get(node);
  143. if (cached && cached.path === path) {
  144. return cached;
  145. }
  146. _cache.scope.set(node, this);
  147. this.uid = uid++;
  148. this.block = node;
  149. this.path = path;
  150. this.labels = new Map();
  151. }
  152. get parent() {
  153. const parent = this.path.findParent(p => p.isScope());
  154. return parent && parent.scope;
  155. }
  156. get parentBlock() {
  157. return this.path.parent;
  158. }
  159. get hub() {
  160. return this.path.hub;
  161. }
  162. traverse(node, opts, state) {
  163. (0, _index.default)(node, opts, this, state, this.path);
  164. }
  165. generateDeclaredUidIdentifier(name) {
  166. const id = this.generateUidIdentifier(name);
  167. this.push({
  168. id
  169. });
  170. return t.cloneNode(id);
  171. }
  172. generateUidIdentifier(name) {
  173. return t.identifier(this.generateUid(name));
  174. }
  175. generateUid(name = "temp") {
  176. name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
  177. let uid;
  178. let i = 0;
  179. do {
  180. uid = this._generateUid(name, i);
  181. i++;
  182. } while (this.hasLabel(uid) || this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid));
  183. const program = this.getProgramParent();
  184. program.references[uid] = true;
  185. program.uids[uid] = true;
  186. return uid;
  187. }
  188. _generateUid(name, i) {
  189. let id = name;
  190. if (i > 1) id += i;
  191. return `_${id}`;
  192. }
  193. generateUidBasedOnNode(parent, defaultName) {
  194. let node = parent;
  195. if (t.isAssignmentExpression(parent)) {
  196. node = parent.left;
  197. } else if (t.isVariableDeclarator(parent)) {
  198. node = parent.id;
  199. } else if (t.isObjectProperty(node) || t.isObjectMethod(node)) {
  200. node = node.key;
  201. }
  202. const parts = [];
  203. gatherNodeParts(node, parts);
  204. let id = parts.join("$");
  205. id = id.replace(/^_/, "") || defaultName || "ref";
  206. return this.generateUid(id.slice(0, 20));
  207. }
  208. generateUidIdentifierBasedOnNode(parent, defaultName) {
  209. return t.identifier(this.generateUidBasedOnNode(parent, defaultName));
  210. }
  211. isStatic(node) {
  212. if (t.isThisExpression(node) || t.isSuper(node)) {
  213. return true;
  214. }
  215. if (t.isIdentifier(node)) {
  216. const binding = this.getBinding(node.name);
  217. if (binding) {
  218. return binding.constant;
  219. } else {
  220. return this.hasBinding(node.name);
  221. }
  222. }
  223. return false;
  224. }
  225. maybeGenerateMemoised(node, dontPush) {
  226. if (this.isStatic(node)) {
  227. return null;
  228. } else {
  229. const id = this.generateUidIdentifierBasedOnNode(node);
  230. if (!dontPush) {
  231. this.push({
  232. id
  233. });
  234. return t.cloneNode(id);
  235. }
  236. return id;
  237. }
  238. }
  239. checkBlockScopedCollisions(local, kind, name, id) {
  240. if (kind === "param") return;
  241. if (local.kind === "local") return;
  242. const duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && (kind === "let" || kind === "const");
  243. if (duplicate) {
  244. throw this.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
  245. }
  246. }
  247. rename(oldName, newName, block) {
  248. const binding = this.getBinding(oldName);
  249. if (binding) {
  250. newName = newName || this.generateUidIdentifier(oldName).name;
  251. return new _renamer.default(binding, oldName, newName).rename(block);
  252. }
  253. }
  254. _renameFromMap(map, oldName, newName, value) {
  255. if (map[oldName]) {
  256. map[newName] = value;
  257. map[oldName] = null;
  258. }
  259. }
  260. dump() {
  261. const sep = (0, _repeat.default)("-", 60);
  262. console.log(sep);
  263. let scope = this;
  264. do {
  265. console.log("#", scope.block.type);
  266. for (const name of Object.keys(scope.bindings)) {
  267. const binding = scope.bindings[name];
  268. console.log(" -", name, {
  269. constant: binding.constant,
  270. references: binding.references,
  271. violations: binding.constantViolations.length,
  272. kind: binding.kind
  273. });
  274. }
  275. } while (scope = scope.parent);
  276. console.log(sep);
  277. }
  278. toArray(node, i) {
  279. if (t.isIdentifier(node)) {
  280. const binding = this.getBinding(node.name);
  281. if (binding && binding.constant && binding.path.isGenericType("Array")) {
  282. return node;
  283. }
  284. }
  285. if (t.isArrayExpression(node)) {
  286. return node;
  287. }
  288. if (t.isIdentifier(node, {
  289. name: "arguments"
  290. })) {
  291. return t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.identifier("Array"), t.identifier("prototype")), t.identifier("slice")), t.identifier("call")), [node]);
  292. }
  293. let helperName;
  294. const args = [node];
  295. if (i === true) {
  296. helperName = "toConsumableArray";
  297. } else if (i) {
  298. args.push(t.numericLiteral(i));
  299. helperName = "slicedToArray";
  300. } else {
  301. helperName = "toArray";
  302. }
  303. return t.callExpression(this.hub.addHelper(helperName), args);
  304. }
  305. hasLabel(name) {
  306. return !!this.getLabel(name);
  307. }
  308. getLabel(name) {
  309. return this.labels.get(name);
  310. }
  311. registerLabel(path) {
  312. this.labels.set(path.node.label.name, path);
  313. }
  314. registerDeclaration(path) {
  315. if (path.isLabeledStatement()) {
  316. this.registerLabel(path);
  317. } else if (path.isFunctionDeclaration()) {
  318. this.registerBinding("hoisted", path.get("id"), path);
  319. } else if (path.isVariableDeclaration()) {
  320. const declarations = path.get("declarations");
  321. for (const declar of declarations) {
  322. this.registerBinding(path.node.kind, declar);
  323. }
  324. } else if (path.isClassDeclaration()) {
  325. this.registerBinding("let", path);
  326. } else if (path.isImportDeclaration()) {
  327. const specifiers = path.get("specifiers");
  328. for (const specifier of specifiers) {
  329. this.registerBinding("module", specifier);
  330. }
  331. } else if (path.isExportDeclaration()) {
  332. const declar = path.get("declaration");
  333. if (declar.isClassDeclaration() || declar.isFunctionDeclaration() || declar.isVariableDeclaration()) {
  334. this.registerDeclaration(declar);
  335. }
  336. } else {
  337. this.registerBinding("unknown", path);
  338. }
  339. }
  340. buildUndefinedNode() {
  341. return t.unaryExpression("void", t.numericLiteral(0), true);
  342. }
  343. registerConstantViolation(path) {
  344. const ids = path.getBindingIdentifiers();
  345. for (const name of Object.keys(ids)) {
  346. const binding = this.getBinding(name);
  347. if (binding) binding.reassign(path);
  348. }
  349. }
  350. registerBinding(kind, path, bindingPath = path) {
  351. if (!kind) throw new ReferenceError("no `kind`");
  352. if (path.isVariableDeclaration()) {
  353. const declarators = path.get("declarations");
  354. for (const declar of declarators) {
  355. this.registerBinding(kind, declar);
  356. }
  357. return;
  358. }
  359. const parent = this.getProgramParent();
  360. const ids = path.getOuterBindingIdentifiers(true);
  361. for (const name of Object.keys(ids)) {
  362. for (const id of ids[name]) {
  363. const local = this.getOwnBinding(name);
  364. if (local) {
  365. if (local.identifier === id) continue;
  366. this.checkBlockScopedCollisions(local, kind, name, id);
  367. }
  368. parent.references[name] = true;
  369. if (local) {
  370. this.registerConstantViolation(bindingPath);
  371. } else {
  372. this.bindings[name] = new _binding.default({
  373. identifier: id,
  374. scope: this,
  375. path: bindingPath,
  376. kind: kind
  377. });
  378. }
  379. }
  380. }
  381. }
  382. addGlobal(node) {
  383. this.globals[node.name] = node;
  384. }
  385. hasUid(name) {
  386. let scope = this;
  387. do {
  388. if (scope.uids[name]) return true;
  389. } while (scope = scope.parent);
  390. return false;
  391. }
  392. hasGlobal(name) {
  393. let scope = this;
  394. do {
  395. if (scope.globals[name]) return true;
  396. } while (scope = scope.parent);
  397. return false;
  398. }
  399. hasReference(name) {
  400. let scope = this;
  401. do {
  402. if (scope.references[name]) return true;
  403. } while (scope = scope.parent);
  404. return false;
  405. }
  406. isPure(node, constantsOnly) {
  407. if (t.isIdentifier(node)) {
  408. const binding = this.getBinding(node.name);
  409. if (!binding) return false;
  410. if (constantsOnly) return binding.constant;
  411. return true;
  412. } else if (t.isClass(node)) {
  413. if (node.superClass && !this.isPure(node.superClass, constantsOnly)) {
  414. return false;
  415. }
  416. return this.isPure(node.body, constantsOnly);
  417. } else if (t.isClassBody(node)) {
  418. for (const method of node.body) {
  419. if (!this.isPure(method, constantsOnly)) return false;
  420. }
  421. return true;
  422. } else if (t.isBinary(node)) {
  423. return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly);
  424. } else if (t.isArrayExpression(node)) {
  425. for (const elem of node.elements) {
  426. if (!this.isPure(elem, constantsOnly)) return false;
  427. }
  428. return true;
  429. } else if (t.isObjectExpression(node)) {
  430. for (const prop of node.properties) {
  431. if (!this.isPure(prop, constantsOnly)) return false;
  432. }
  433. return true;
  434. } else if (t.isClassMethod(node)) {
  435. if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
  436. if (node.kind === "get" || node.kind === "set") return false;
  437. return true;
  438. } else if (t.isProperty(node)) {
  439. if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
  440. return this.isPure(node.value, constantsOnly);
  441. } else if (t.isUnaryExpression(node)) {
  442. return this.isPure(node.argument, constantsOnly);
  443. } else if (t.isTaggedTemplateExpression(node)) {
  444. return t.matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly);
  445. } else if (t.isTemplateLiteral(node)) {
  446. for (const expression of node.expressions) {
  447. if (!this.isPure(expression, constantsOnly)) return false;
  448. }
  449. return true;
  450. } else {
  451. return t.isPureish(node);
  452. }
  453. }
  454. setData(key, val) {
  455. return this.data[key] = val;
  456. }
  457. getData(key) {
  458. let scope = this;
  459. do {
  460. const data = scope.data[key];
  461. if (data != null) return data;
  462. } while (scope = scope.parent);
  463. }
  464. removeData(key) {
  465. let scope = this;
  466. do {
  467. const data = scope.data[key];
  468. if (data != null) scope.data[key] = null;
  469. } while (scope = scope.parent);
  470. }
  471. init() {
  472. if (!this.references) this.crawl();
  473. }
  474. crawl() {
  475. const path = this.path;
  476. this.references = Object.create(null);
  477. this.bindings = Object.create(null);
  478. this.globals = Object.create(null);
  479. this.uids = Object.create(null);
  480. this.data = Object.create(null);
  481. if (path.isLoop()) {
  482. for (const key of t.FOR_INIT_KEYS) {
  483. const node = path.get(key);
  484. if (node.isBlockScoped()) this.registerBinding(node.node.kind, node);
  485. }
  486. }
  487. if (path.isFunctionExpression() && path.has("id")) {
  488. if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
  489. this.registerBinding("local", path.get("id"), path);
  490. }
  491. }
  492. if (path.isClassExpression() && path.has("id")) {
  493. if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
  494. this.registerBinding("local", path);
  495. }
  496. }
  497. if (path.isFunction()) {
  498. const params = path.get("params");
  499. for (const param of params) {
  500. this.registerBinding("param", param);
  501. }
  502. }
  503. if (path.isCatchClause()) {
  504. this.registerBinding("let", path);
  505. }
  506. const parent = this.getProgramParent();
  507. if (parent.crawling) return;
  508. const state = {
  509. references: [],
  510. constantViolations: [],
  511. assignments: []
  512. };
  513. this.crawling = true;
  514. path.traverse(collectorVisitor, state);
  515. this.crawling = false;
  516. for (const path of state.assignments) {
  517. const ids = path.getBindingIdentifiers();
  518. let programParent;
  519. for (const name of Object.keys(ids)) {
  520. if (path.scope.getBinding(name)) continue;
  521. programParent = programParent || path.scope.getProgramParent();
  522. programParent.addGlobal(ids[name]);
  523. }
  524. path.scope.registerConstantViolation(path);
  525. }
  526. for (const ref of state.references) {
  527. const binding = ref.scope.getBinding(ref.node.name);
  528. if (binding) {
  529. binding.reference(ref);
  530. } else {
  531. ref.scope.getProgramParent().addGlobal(ref.node);
  532. }
  533. }
  534. for (const path of state.constantViolations) {
  535. path.scope.registerConstantViolation(path);
  536. }
  537. }
  538. push(opts) {
  539. let path = this.path;
  540. if (!path.isBlockStatement() && !path.isProgram()) {
  541. path = this.getBlockParent().path;
  542. }
  543. if (path.isSwitchStatement()) {
  544. path = (this.getFunctionParent() || this.getProgramParent()).path;
  545. }
  546. if (path.isLoop() || path.isCatchClause() || path.isFunction()) {
  547. path.ensureBlock();
  548. path = path.get("body");
  549. }
  550. const unique = opts.unique;
  551. const kind = opts.kind || "var";
  552. const blockHoist = opts._blockHoist == null ? 2 : opts._blockHoist;
  553. const dataKey = `declaration:${kind}:${blockHoist}`;
  554. let declarPath = !unique && path.getData(dataKey);
  555. if (!declarPath) {
  556. const declar = t.variableDeclaration(kind, []);
  557. declar._blockHoist = blockHoist;
  558. [declarPath] = path.unshiftContainer("body", [declar]);
  559. if (!unique) path.setData(dataKey, declarPath);
  560. }
  561. const declarator = t.variableDeclarator(opts.id, opts.init);
  562. declarPath.node.declarations.push(declarator);
  563. this.registerBinding(kind, declarPath.get("declarations").pop());
  564. }
  565. getProgramParent() {
  566. let scope = this;
  567. do {
  568. if (scope.path.isProgram()) {
  569. return scope;
  570. }
  571. } while (scope = scope.parent);
  572. throw new Error("Couldn't find a Program");
  573. }
  574. getFunctionParent() {
  575. let scope = this;
  576. do {
  577. if (scope.path.isFunctionParent()) {
  578. return scope;
  579. }
  580. } while (scope = scope.parent);
  581. return null;
  582. }
  583. getBlockParent() {
  584. let scope = this;
  585. do {
  586. if (scope.path.isBlockParent()) {
  587. return scope;
  588. }
  589. } while (scope = scope.parent);
  590. throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...");
  591. }
  592. getAllBindings() {
  593. const ids = Object.create(null);
  594. let scope = this;
  595. do {
  596. (0, _defaults.default)(ids, scope.bindings);
  597. scope = scope.parent;
  598. } while (scope);
  599. return ids;
  600. }
  601. getAllBindingsOfKind() {
  602. const ids = Object.create(null);
  603. for (const kind of arguments) {
  604. let scope = this;
  605. do {
  606. for (const name of Object.keys(scope.bindings)) {
  607. const binding = scope.bindings[name];
  608. if (binding.kind === kind) ids[name] = binding;
  609. }
  610. scope = scope.parent;
  611. } while (scope);
  612. }
  613. return ids;
  614. }
  615. bindingIdentifierEquals(name, node) {
  616. return this.getBindingIdentifier(name) === node;
  617. }
  618. getBinding(name) {
  619. let scope = this;
  620. do {
  621. const binding = scope.getOwnBinding(name);
  622. if (binding) return binding;
  623. } while (scope = scope.parent);
  624. }
  625. getOwnBinding(name) {
  626. return this.bindings[name];
  627. }
  628. getBindingIdentifier(name) {
  629. const info = this.getBinding(name);
  630. return info && info.identifier;
  631. }
  632. getOwnBindingIdentifier(name) {
  633. const binding = this.bindings[name];
  634. return binding && binding.identifier;
  635. }
  636. hasOwnBinding(name) {
  637. return !!this.getOwnBinding(name);
  638. }
  639. hasBinding(name, noGlobals) {
  640. if (!name) return false;
  641. if (this.hasOwnBinding(name)) return true;
  642. if (this.parentHasBinding(name, noGlobals)) return true;
  643. if (this.hasUid(name)) return true;
  644. if (!noGlobals && (0, _includes.default)(Scope.globals, name)) return true;
  645. if (!noGlobals && (0, _includes.default)(Scope.contextVariables, name)) return true;
  646. return false;
  647. }
  648. parentHasBinding(name, noGlobals) {
  649. return this.parent && this.parent.hasBinding(name, noGlobals);
  650. }
  651. moveBindingTo(name, scope) {
  652. const info = this.getBinding(name);
  653. if (info) {
  654. info.scope.removeOwnBinding(name);
  655. info.scope = scope;
  656. scope.bindings[name] = info;
  657. }
  658. }
  659. removeOwnBinding(name) {
  660. delete this.bindings[name];
  661. }
  662. removeBinding(name) {
  663. const info = this.getBinding(name);
  664. if (info) {
  665. info.scope.removeOwnBinding(name);
  666. }
  667. let scope = this;
  668. do {
  669. if (scope.uids[name]) {
  670. scope.uids[name] = false;
  671. }
  672. } while (scope = scope.parent);
  673. }
  674. }
  675. exports.default = Scope;
  676. Scope.globals = Object.keys(_globals.default.builtin);
  677. Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"];