@babel/traverse 7.22.7 → 8.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cache.js +7 -32
- package/lib/cache.js.map +1 -1
- package/lib/context.js +7 -14
- package/lib/context.js.map +1 -1
- package/lib/hub.js +1 -8
- package/lib/hub.js.map +1 -1
- package/lib/index.js +4847 -36
- package/lib/index.js.map +1 -1
- package/lib/path/ancestry.js +11 -26
- package/lib/path/ancestry.js.map +1 -1
- package/lib/path/comments.js +4 -12
- package/lib/path/comments.js.map +1 -1
- package/lib/path/context.js +35 -63
- package/lib/path/context.js.map +1 -1
- package/lib/path/conversion.js +18 -38
- package/lib/path/conversion.js.map +1 -1
- package/lib/path/evaluation.js +4 -11
- package/lib/path/evaluation.js.map +1 -1
- package/lib/path/family.js +19 -33
- package/lib/path/family.js.map +1 -1
- package/lib/path/index.js +45 -53
- package/lib/path/index.js.map +1 -1
- package/lib/path/inference/index.js +9 -21
- package/lib/path/inference/index.js.map +1 -1
- package/lib/path/inference/inferer-reference.js +5 -11
- package/lib/path/inference/inferer-reference.js.map +1 -1
- package/lib/path/inference/inferers.js +30 -65
- package/lib/path/inference/inferers.js.map +1 -1
- package/lib/path/inference/util.js +6 -16
- package/lib/path/inference/util.js.map +1 -1
- package/lib/path/introspection.js +20 -45
- package/lib/path/introspection.js.map +1 -1
- package/lib/path/lib/hoister.js +10 -17
- package/lib/path/lib/hoister.js.map +1 -1
- package/lib/path/lib/removal-hooks.js +1 -8
- package/lib/path/lib/removal-hooks.js.map +1 -1
- package/lib/path/lib/virtual-types-validator.js +19 -42
- package/lib/path/lib/virtual-types-validator.js.map +1 -1
- package/lib/path/lib/virtual-types.js +18 -42
- package/lib/path/lib/virtual-types.js.map +1 -1
- package/lib/path/modification.js +20 -35
- package/lib/path/modification.js.map +1 -1
- package/lib/path/removal.js +13 -27
- package/lib/path/removal.js.map +1 -1
- package/lib/path/replacement.js +25 -38
- package/lib/path/replacement.js.map +1 -1
- package/lib/scope/binding.js +10 -17
- package/lib/scope/binding.js.map +1 -1
- package/lib/scope/index.js +49 -66
- package/lib/scope/index.js.map +1 -1
- package/lib/scope/lib/renamer.js +12 -20
- package/lib/scope/lib/renamer.js.map +1 -1
- package/lib/traverse-node.js +5 -15
- package/lib/traverse-node.js.map +1 -1
- package/lib/visitors.js +16 -24
- package/lib/visitors.js.map +1 -1
- package/package.json +17 -14
package/lib/scope/binding.js
CHANGED
@@ -1,25 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
exports.default = void 0;
|
7
|
-
class Binding {
|
1
|
+
export default class Binding {
|
2
|
+
identifier;
|
3
|
+
scope;
|
4
|
+
path;
|
5
|
+
kind;
|
8
6
|
constructor({
|
9
7
|
identifier,
|
10
8
|
scope,
|
11
9
|
path,
|
12
10
|
kind
|
13
11
|
}) {
|
14
|
-
this.identifier = void 0;
|
15
|
-
this.scope = void 0;
|
16
|
-
this.path = void 0;
|
17
|
-
this.kind = void 0;
|
18
|
-
this.constantViolations = [];
|
19
|
-
this.constant = true;
|
20
|
-
this.referencePaths = [];
|
21
|
-
this.referenced = false;
|
22
|
-
this.references = 0;
|
23
12
|
this.identifier = identifier;
|
24
13
|
this.scope = scope;
|
25
14
|
this.path = path;
|
@@ -31,6 +20,11 @@ class Binding {
|
|
31
20
|
}
|
32
21
|
this.clearValue();
|
33
22
|
}
|
23
|
+
constantViolations = [];
|
24
|
+
constant = true;
|
25
|
+
referencePaths = [];
|
26
|
+
referenced = false;
|
27
|
+
references = 0;
|
34
28
|
deoptValue() {
|
35
29
|
this.clearValue();
|
36
30
|
this.hasDeoptedValue = true;
|
@@ -65,7 +59,6 @@ class Binding {
|
|
65
59
|
this.referenced = !!this.references;
|
66
60
|
}
|
67
61
|
}
|
68
|
-
exports.default = Binding;
|
69
62
|
function isDeclaredInLoop(path) {
|
70
63
|
for (let {
|
71
64
|
parentPath,
|
package/lib/scope/binding.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Binding","
|
1
|
+
{"version":3,"names":["Binding","identifier","scope","path","kind","constructor","isDeclaredInLoop","Error","reassign","clearValue","constantViolations","constant","referencePaths","referenced","references","deoptValue","hasDeoptedValue","setValue","value","hasValue","indexOf","push","reference","dereference","parentPath","key","isFunctionParent","isWhile","isForXStatement","isForStatement"],"sources":["../../src/scope/binding.ts"],"sourcesContent":["import type NodePath from \"../path\";\nimport type * as t from \"@babel/types\";\nimport type Scope from \"./index\";\n\nexport type BindingKind =\n | \"var\" /* var declarator */\n | \"let\" /* let declarator, class declaration id, catch clause parameters */\n | \"const\" /* const/using declarator */\n | \"module\" /* import specifiers */\n | \"hoisted\" /* function declaration id */\n | \"param\" /* function declaration parameters */\n | \"local\" /* function expression id, class expression id */\n | \"unknown\"; /* export specifiers */\n/**\n * This class is responsible for a binding inside of a scope.\n *\n * It tracks the following:\n *\n * * Node path.\n * * Amount of times referenced by other nodes.\n * * Paths to nodes that reassign or modify this binding.\n * * The kind of binding. (Is it a parameter, declaration etc)\n */\n\nexport default class Binding {\n identifier: t.Identifier;\n scope: Scope;\n path: NodePath;\n kind: BindingKind;\n\n constructor({\n identifier,\n scope,\n path,\n kind,\n }: {\n identifier: t.Identifier;\n scope: Scope;\n path: NodePath;\n kind: BindingKind;\n }) {\n this.identifier = identifier;\n this.scope = scope;\n this.path = path;\n this.kind = kind;\n\n if (\n (kind === \"var\" || kind === \"hoisted\") &&\n // https://github.com/rollup/rollup/issues/4654\n // Rollup removes the path argument from this call. Add an\n // unreachable IIFE (that rollup doesn't know is unreachable)\n // with side effects, to prevent it from messing up with arguments.\n // You can reproduce this with\n // BABEL_8_BREAKING=true make prepublish-build\n isDeclaredInLoop(\n path ||\n (() => {\n throw new Error(\"Internal Babel error: unreachable \");\n })(),\n )\n ) {\n this.reassign(path);\n }\n\n this.clearValue();\n }\n\n constantViolations: Array<NodePath> = [];\n constant: boolean = true;\n\n referencePaths: Array<NodePath> = [];\n referenced: boolean = false;\n references: number = 0;\n\n declare hasDeoptedValue: boolean;\n declare hasValue: boolean;\n declare value: any;\n\n deoptValue() {\n this.clearValue();\n this.hasDeoptedValue = true;\n }\n\n setValue(value: any) {\n if (this.hasDeoptedValue) return;\n this.hasValue = true;\n this.value = value;\n }\n\n clearValue() {\n this.hasDeoptedValue = false;\n this.hasValue = false;\n this.value = null;\n }\n\n /**\n * Register a constant violation with the provided `path`.\n */\n\n reassign(path: NodePath) {\n this.constant = false;\n if (this.constantViolations.indexOf(path) !== -1) {\n return;\n }\n this.constantViolations.push(path);\n }\n\n /**\n * Increment the amount of references to this binding.\n */\n\n reference(path: NodePath) {\n if (this.referencePaths.indexOf(path) !== -1) {\n return;\n }\n this.referenced = true;\n this.references++;\n this.referencePaths.push(path);\n }\n\n /**\n * Decrement the amount of references to this binding.\n */\n\n dereference() {\n this.references--;\n this.referenced = !!this.references;\n }\n}\n\nfunction isDeclaredInLoop(path: NodePath) {\n for (\n let { parentPath, key } = path;\n parentPath;\n { parentPath, key } = parentPath\n ) {\n if (parentPath.isFunctionParent()) return false;\n if (\n parentPath.isWhile() ||\n parentPath.isForXStatement() ||\n (parentPath.isForStatement() && key === \"body\")\n ) {\n return true;\n }\n }\n return false;\n}\n"],"mappings":"AAwBA,eAAe,MAAMA,OAAO,CAAC;EAC3BC,UAAU;EACVC,KAAK;EACLC,IAAI;EACJC,IAAI;EAEJC,WAAWA,CAAC;IACVJ,UAAU;IACVC,KAAK;IACLC,IAAI;IACJC;EAMF,CAAC,EAAE;IACD,IAAI,CAACH,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,IAAI,GAAGA,IAAI;IAEhB,IACE,CAACA,IAAI,KAAK,KAAK,IAAIA,IAAI,KAAK,SAAS,KAOrCE,gBAAgB,CACdH,IAAI,IACF,CAAC,MAAM;MACL,MAAM,IAAII,KAAK,CAAC,oCAAoC,CAAC;IACvD,CAAC,EAAE,CACP,CAAC,EACD;MACA,IAAI,CAACC,QAAQ,CAACL,IAAI,CAAC;IACrB;IAEA,IAAI,CAACM,UAAU,CAAC,CAAC;EACnB;EAEAC,kBAAkB,GAAoB,EAAE;EACxCC,QAAQ,GAAY,IAAI;EAExBC,cAAc,GAAoB,EAAE;EACpCC,UAAU,GAAY,KAAK;EAC3BC,UAAU,GAAW,CAAC;EAMtBC,UAAUA,CAAA,EAAG;IACX,IAAI,CAACN,UAAU,CAAC,CAAC;IACjB,IAAI,CAACO,eAAe,GAAG,IAAI;EAC7B;EAEAC,QAAQA,CAACC,KAAU,EAAE;IACnB,IAAI,IAAI,CAACF,eAAe,EAAE;IAC1B,IAAI,CAACG,QAAQ,GAAG,IAAI;IACpB,IAAI,CAACD,KAAK,GAAGA,KAAK;EACpB;EAEAT,UAAUA,CAAA,EAAG;IACX,IAAI,CAACO,eAAe,GAAG,KAAK;IAC5B,IAAI,CAACG,QAAQ,GAAG,KAAK;IACrB,IAAI,CAACD,KAAK,GAAG,IAAI;EACnB;EAMAV,QAAQA,CAACL,IAAc,EAAE;IACvB,IAAI,CAACQ,QAAQ,GAAG,KAAK;IACrB,IAAI,IAAI,CAACD,kBAAkB,CAACU,OAAO,CAACjB,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;MAChD;IACF;IACA,IAAI,CAACO,kBAAkB,CAACW,IAAI,CAAClB,IAAI,CAAC;EACpC;EAMAmB,SAASA,CAACnB,IAAc,EAAE;IACxB,IAAI,IAAI,CAACS,cAAc,CAACQ,OAAO,CAACjB,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;MAC5C;IACF;IACA,IAAI,CAACU,UAAU,GAAG,IAAI;IACtB,IAAI,CAACC,UAAU,EAAE;IACjB,IAAI,CAACF,cAAc,CAACS,IAAI,CAAClB,IAAI,CAAC;EAChC;EAMAoB,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACT,UAAU,EAAE;IACjB,IAAI,CAACD,UAAU,GAAG,CAAC,CAAC,IAAI,CAACC,UAAU;EACrC;AACF;AAEA,SAASR,gBAAgBA,CAACH,IAAc,EAAE;EACxC,KACE,IAAI;IAAEqB,UAAU;IAAEC;EAAI,CAAC,GAAGtB,IAAI,EAC9BqB,UAAU,GACV;IAAEA,UAAU;IAAEC;EAAI,CAAC,GAAGD,UAAU,GAChC;IACA,IAAIA,UAAU,CAACE,gBAAgB,CAAC,CAAC,EAAE,OAAO,KAAK;IAC/C,IACEF,UAAU,CAACG,OAAO,CAAC,CAAC,IACpBH,UAAU,CAACI,eAAe,CAAC,CAAC,IAC3BJ,UAAU,CAACK,cAAc,CAAC,CAAC,IAAIJ,GAAG,KAAK,MAAO,EAC/C;MACA,OAAO,IAAI;IACb;EACF;EACA,OAAO,KAAK;AACd"}
|
package/lib/scope/index.js
CHANGED
@@ -1,17 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
exports.default = void 0;
|
7
|
-
var _renamer = require("./lib/renamer");
|
8
|
-
var _index = require("../index");
|
9
|
-
var _binding = require("./binding");
|
10
|
-
var _globals = require("globals");
|
11
|
-
var _t = require("@babel/types");
|
12
|
-
var t = _t;
|
13
|
-
var _cache = require("../cache");
|
14
|
-
var _visitors = require("../visitors");
|
1
|
+
import Renamer from "./lib/renamer.js";
|
2
|
+
import traverse from "../index.js";
|
3
|
+
import Binding from "./binding.js";
|
4
|
+
import globals from "globals";
|
5
|
+
import * as _t from "@babel/types";
|
15
6
|
const {
|
16
7
|
NOT_LOCAL_BINDING,
|
17
8
|
callExpression,
|
@@ -58,13 +49,16 @@ const {
|
|
58
49
|
isPrivateName,
|
59
50
|
isExportDeclaration
|
60
51
|
} = _t;
|
52
|
+
import * as t from "@babel/types";
|
53
|
+
import { scope as scopeCache } from "../cache.js";
|
54
|
+
import { isExplodedVisitor } from "../visitors.js";
|
61
55
|
function gatherNodeParts(node, parts) {
|
62
|
-
switch (node
|
56
|
+
switch (node?.type) {
|
63
57
|
default:
|
64
58
|
if (isImportDeclaration(node) || isExportDeclaration(node)) {
|
65
59
|
if ((isExportAllDeclaration(node) || isExportNamedDeclaration(node) || isImportDeclaration(node)) && node.source) {
|
66
60
|
gatherNodeParts(node.source, parts);
|
67
|
-
} else if ((isExportNamedDeclaration(node) || isImportDeclaration(node)) && node.specifiers
|
61
|
+
} else if ((isExportNamedDeclaration(node) || isImportDeclaration(node)) && node.specifiers?.length) {
|
68
62
|
for (const e of node.specifiers) gatherNodeParts(e, parts);
|
69
63
|
} else if ((isExportDefaultDeclaration(node) || isExportNamedDeclaration(node)) && node.declaration) {
|
70
64
|
gatherNodeParts(node.declaration, parts);
|
@@ -221,12 +215,12 @@ const collectorVisitor = {
|
|
221
215
|
const id = declar.id;
|
222
216
|
if (!id) return;
|
223
217
|
const binding = scope.getBinding(id.name);
|
224
|
-
binding
|
218
|
+
binding?.reference(path);
|
225
219
|
} else if (isVariableDeclaration(declar)) {
|
226
220
|
for (const decl of declar.declarations) {
|
227
221
|
for (const name of Object.keys(getBindingIdentifiers(decl))) {
|
228
222
|
const binding = scope.getBinding(name);
|
229
|
-
binding
|
223
|
+
binding?.reference(path);
|
230
224
|
}
|
231
225
|
}
|
232
226
|
}
|
@@ -276,35 +270,36 @@ const collectorVisitor = {
|
|
276
270
|
}
|
277
271
|
};
|
278
272
|
let uid = 0;
|
279
|
-
class Scope {
|
273
|
+
export default class Scope {
|
274
|
+
uid;
|
275
|
+
path;
|
276
|
+
block;
|
277
|
+
labels;
|
278
|
+
inited;
|
279
|
+
bindings;
|
280
|
+
references;
|
281
|
+
globals;
|
282
|
+
uids;
|
283
|
+
data;
|
284
|
+
crawling;
|
280
285
|
constructor(path) {
|
281
|
-
this.uid = void 0;
|
282
|
-
this.path = void 0;
|
283
|
-
this.block = void 0;
|
284
|
-
this.labels = void 0;
|
285
|
-
this.inited = void 0;
|
286
|
-
this.bindings = void 0;
|
287
|
-
this.references = void 0;
|
288
|
-
this.globals = void 0;
|
289
|
-
this.uids = void 0;
|
290
|
-
this.data = void 0;
|
291
|
-
this.crawling = void 0;
|
292
286
|
const {
|
293
287
|
node
|
294
288
|
} = path;
|
295
|
-
const cached =
|
296
|
-
if (
|
289
|
+
const cached = scopeCache.get(node);
|
290
|
+
if (cached?.path === path) {
|
297
291
|
return cached;
|
298
292
|
}
|
299
|
-
|
293
|
+
scopeCache.set(node, this);
|
300
294
|
this.uid = uid++;
|
301
295
|
this.block = node;
|
302
296
|
this.path = path;
|
303
297
|
this.labels = new Map();
|
304
298
|
this.inited = false;
|
305
299
|
}
|
300
|
+
static globals = Object.keys(globals.builtin);
|
301
|
+
static contextVariables = ["arguments", "undefined", "Infinity", "NaN"];
|
306
302
|
get parent() {
|
307
|
-
var _parent;
|
308
303
|
let parent,
|
309
304
|
path = this.path;
|
310
305
|
do {
|
@@ -313,7 +308,7 @@ class Scope {
|
|
313
308
|
if (shouldSkip && path.isMethod()) path = path.parentPath;
|
314
309
|
if (path && path.isScope()) parent = path;
|
315
310
|
} while (path && !parent);
|
316
|
-
return
|
311
|
+
return parent?.scope;
|
317
312
|
}
|
318
313
|
get parentBlock() {
|
319
314
|
return this.path.parent;
|
@@ -322,7 +317,7 @@ class Scope {
|
|
322
317
|
return this.path.hub;
|
323
318
|
}
|
324
319
|
traverse(node, opts, state) {
|
325
|
-
(
|
320
|
+
traverse(node, opts, this, state, this.path);
|
326
321
|
}
|
327
322
|
generateDeclaredUidIdentifier(name) {
|
328
323
|
const id = this.generateUidIdentifier(name);
|
@@ -401,10 +396,10 @@ class Scope {
|
|
401
396
|
rename(oldName, newName) {
|
402
397
|
const binding = this.getBinding(oldName);
|
403
398
|
if (binding) {
|
404
|
-
newName
|
405
|
-
const renamer = new
|
399
|
+
newName ||= this.generateUidIdentifier(oldName).name;
|
400
|
+
const renamer = new Renamer(binding, oldName, newName);
|
406
401
|
{
|
407
|
-
renamer.rename(
|
402
|
+
renamer.rename();
|
408
403
|
}
|
409
404
|
}
|
410
405
|
}
|
@@ -435,7 +430,7 @@ class Scope {
|
|
435
430
|
toArray(node, i, arrayLikeIsIterable) {
|
436
431
|
if (isIdentifier(node)) {
|
437
432
|
const binding = this.getBinding(node.name);
|
438
|
-
if (binding
|
433
|
+
if (binding?.constant && binding.path.isGenericType("Array")) {
|
439
434
|
return node;
|
440
435
|
}
|
441
436
|
}
|
@@ -510,8 +505,7 @@ class Scope {
|
|
510
505
|
registerConstantViolation(path) {
|
511
506
|
const ids = path.getBindingIdentifiers();
|
512
507
|
for (const name of Object.keys(ids)) {
|
513
|
-
|
514
|
-
(_this$getBinding = this.getBinding(name)) == null ? void 0 : _this$getBinding.reassign(path);
|
508
|
+
this.getBinding(name)?.reassign(path);
|
515
509
|
}
|
516
510
|
}
|
517
511
|
registerBinding(kind, path, bindingPath = path) {
|
@@ -536,7 +530,7 @@ class Scope {
|
|
536
530
|
if (local) {
|
537
531
|
this.registerConstantViolation(bindingPath);
|
538
532
|
} else {
|
539
|
-
this.bindings[name] = new
|
533
|
+
this.bindings[name] = new Binding({
|
540
534
|
identifier: id,
|
541
535
|
scope: this,
|
542
536
|
path: bindingPath,
|
@@ -575,11 +569,10 @@ class Scope {
|
|
575
569
|
} else if (isThisExpression(node) || isMetaProperty(node) || isTopicReference(node) || isPrivateName(node)) {
|
576
570
|
return true;
|
577
571
|
} else if (isClass(node)) {
|
578
|
-
var _node$decorators;
|
579
572
|
if (node.superClass && !this.isPure(node.superClass, constantsOnly)) {
|
580
573
|
return false;
|
581
574
|
}
|
582
|
-
if (
|
575
|
+
if (node.decorators?.length > 0) {
|
583
576
|
return false;
|
584
577
|
}
|
585
578
|
return this.isPure(node.body, constantsOnly);
|
@@ -601,16 +594,14 @@ class Scope {
|
|
601
594
|
}
|
602
595
|
return true;
|
603
596
|
} else if (isMethod(node)) {
|
604
|
-
var _node$decorators2;
|
605
597
|
if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
|
606
|
-
if (
|
598
|
+
if (node.decorators?.length > 0) {
|
607
599
|
return false;
|
608
600
|
}
|
609
601
|
return true;
|
610
602
|
} else if (isProperty(node)) {
|
611
|
-
var _node$decorators3;
|
612
603
|
if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
|
613
|
-
if (
|
604
|
+
if (node.decorators?.length > 0) {
|
614
605
|
return false;
|
615
606
|
}
|
616
607
|
if (isObjectProperty(node) || node.static) {
|
@@ -670,7 +661,7 @@ class Scope {
|
|
670
661
|
assignments: []
|
671
662
|
};
|
672
663
|
this.crawling = true;
|
673
|
-
if (path.type !== "Program" &&
|
664
|
+
if (path.type !== "Program" && isExplodedVisitor(collectorVisitor)) {
|
674
665
|
for (const visit of collectorVisitor.enter) {
|
675
666
|
visit.call(state, path, state);
|
676
667
|
}
|
@@ -815,8 +806,7 @@ class Scope {
|
|
815
806
|
do {
|
816
807
|
const binding = scope.getOwnBinding(name);
|
817
808
|
if (binding) {
|
818
|
-
|
819
|
-
if ((_previousPath = previousPath) != null && _previousPath.isPattern() && binding.kind !== "param" && binding.kind !== "local") {} else {
|
809
|
+
if (previousPath?.isPattern() && binding.kind !== "param" && binding.kind !== "local") {} else {
|
820
810
|
return binding;
|
821
811
|
}
|
822
812
|
} else if (!binding && name === "arguments" && scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) {
|
@@ -829,18 +819,16 @@ class Scope {
|
|
829
819
|
return this.bindings[name];
|
830
820
|
}
|
831
821
|
getBindingIdentifier(name) {
|
832
|
-
|
833
|
-
return (_this$getBinding2 = this.getBinding(name)) == null ? void 0 : _this$getBinding2.identifier;
|
822
|
+
return this.getBinding(name)?.identifier;
|
834
823
|
}
|
835
824
|
getOwnBindingIdentifier(name) {
|
836
825
|
const binding = this.bindings[name];
|
837
|
-
return binding
|
826
|
+
return binding?.identifier;
|
838
827
|
}
|
839
828
|
hasOwnBinding(name) {
|
840
829
|
return !!this.getOwnBinding(name);
|
841
830
|
}
|
842
831
|
hasBinding(name, opts) {
|
843
|
-
var _opts, _opts2, _opts3;
|
844
832
|
if (!name) return false;
|
845
833
|
if (this.hasOwnBinding(name)) return true;
|
846
834
|
{
|
@@ -849,14 +837,13 @@ class Scope {
|
|
849
837
|
};
|
850
838
|
}
|
851
839
|
if (this.parentHasBinding(name, opts)) return true;
|
852
|
-
if (!
|
853
|
-
if (!
|
854
|
-
if (!
|
840
|
+
if (!opts?.noUids && this.hasUid(name)) return true;
|
841
|
+
if (!opts?.noGlobals && Scope.globals.includes(name)) return true;
|
842
|
+
if (!opts?.noGlobals && Scope.contextVariables.includes(name)) return true;
|
855
843
|
return false;
|
856
844
|
}
|
857
845
|
parentHasBinding(name, opts) {
|
858
|
-
|
859
|
-
return (_this$parent = this.parent) == null ? void 0 : _this$parent.hasBinding(name, opts);
|
846
|
+
return this.parent?.hasBinding(name, opts);
|
860
847
|
}
|
861
848
|
moveBindingTo(name, scope) {
|
862
849
|
const info = this.getBinding(name);
|
@@ -870,8 +857,7 @@ class Scope {
|
|
870
857
|
delete this.bindings[name];
|
871
858
|
}
|
872
859
|
removeBinding(name) {
|
873
|
-
|
874
|
-
(_this$getBinding3 = this.getBinding(name)) == null ? void 0 : _this$getBinding3.scope.removeOwnBinding(name);
|
860
|
+
this.getBinding(name)?.scope.removeOwnBinding(name);
|
875
861
|
let scope = this;
|
876
862
|
do {
|
877
863
|
if (scope.uids[name]) {
|
@@ -880,8 +866,5 @@ class Scope {
|
|
880
866
|
} while (scope = scope.parent);
|
881
867
|
}
|
882
868
|
}
|
883
|
-
exports.default = Scope;
|
884
|
-
Scope.globals = Object.keys(_globals.builtin);
|
885
|
-
Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"];
|
886
869
|
|
887
870
|
//# sourceMappingURL=index.js.map
|