source: frontend/node_modules/@babel/traverse/lib/scope/binding.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7class Binding {
8 constructor({
9 identifier,
10 scope,
11 path,
12 kind
13 }) {
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 this.identifier = identifier;
24 this.scope = scope;
25 this.path = path;
26 this.kind = kind;
27 if ((kind === "var" || kind === "hoisted") && isInitInLoop(path)) {
28 this.reassign(path);
29 }
30 this.clearValue();
31 }
32 deoptValue() {
33 this.clearValue();
34 this.hasDeoptedValue = true;
35 }
36 setValue(value) {
37 if (this.hasDeoptedValue) return;
38 this.hasValue = true;
39 this.value = value;
40 }
41 clearValue() {
42 this.hasDeoptedValue = false;
43 this.hasValue = false;
44 this.value = null;
45 }
46 reassign(path) {
47 this.constant = false;
48 if (this.constantViolations.includes(path)) {
49 return;
50 }
51 this.constantViolations.push(path);
52 }
53 reference(path) {
54 if (this.referencePaths.includes(path)) {
55 return;
56 }
57 this.referenced = true;
58 this.references++;
59 this.referencePaths.push(path);
60 }
61 dereference() {
62 this.references--;
63 this.referenced = !!this.references;
64 }
65}
66exports.default = Binding;
67function isInitInLoop(path) {
68 const isFunctionDeclarationOrHasInit = !path.isVariableDeclarator() || path.node.init;
69 for (let {
70 parentPath,
71 key
72 } = path; parentPath; {
73 parentPath,
74 key
75 } = parentPath) {
76 if (parentPath.isFunctionParent()) return false;
77 if (key === "left" && parentPath.isForXStatement() || isFunctionDeclarationOrHasInit && key === "body" && parentPath.isLoop()) {
78 return true;
79 }
80 }
81 return false;
82}
83
84//# sourceMappingURL=binding.js.map
Note: See TracBrowser for help on using the repository browser.