Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/@babel/traverse/lib/scope/index.js
rd565449 r0c6b92a 272 272 path.scope.registerBinding("param", param); 273 273 } 274 if (path.isFunctionExpression() && path. has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) {274 if (path.isFunctionExpression() && path.node.id && !path.node.id[NOT_LOCAL_BINDING]) { 275 275 path.scope.registerBinding("local", path.get("id"), path); 276 276 } 277 277 }, 278 278 ClassExpression(path) { 279 if (path. has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) {279 if (path.node.id && !path.node.id[NOT_LOCAL_BINDING]) { 280 280 path.scope.registerBinding("local", path.get("id"), path); 281 281 } … … 291 291 this.path = void 0; 292 292 this.block = void 0; 293 this.inited = void 0; 293 294 this.labels = void 0; 294 this.inited = void 0;295 295 this.bindings = void 0; 296 296 this.references = void 0; … … 326 326 return (_parent = parent) == null ? void 0 : _parent.scope; 327 327 } 328 get parentBlock() {329 return this.path.parent;330 }331 get hub() {332 return this.path.hub;333 }334 traverse(node, opts, state) {335 (0, _index.default)(node, opts, this, state, this.path);336 }337 328 generateDeclaredUidIdentifier(name) { 338 329 const id = this.generateUidIdentifier(name); … … 350 341 let i = 1; 351 342 do { 352 uid = this._generateUid(name, i); 343 uid = `_${name}`; 344 if (i > 1) uid += i; 353 345 i++; 354 346 } while (this.hasLabel(uid) || this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid)); … … 357 349 program.uids[uid] = true; 358 350 return uid; 359 }360 _generateUid(name, i) {361 let id = name;362 if (i > 1) id += i;363 return `_${id}`;364 351 } 365 352 generateUidBasedOnNode(node, defaultName) { … … 406 393 const duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && kind === "const"; 407 394 if (duplicate) { 408 throw this. hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);395 throw this.path.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError); 409 396 } 410 397 } … … 417 404 renamer.rename(arguments[2]); 418 405 } 419 }420 }421 _renameFromMap(map, oldName, newName, value) {422 if (map[oldName]) {423 map[newName] = value;424 map[oldName] = null;425 406 } 426 407 } … … 442 423 } while (scope = scope.parent); 443 424 console.log(sep); 444 }445 toArray(node, i, arrayLikeIsIterable) {446 if (isIdentifier(node)) {447 const binding = this.getBinding(node.name);448 if (binding != null && binding.constant && binding.path.isGenericType("Array")) {449 return node;450 }451 }452 if (isArrayExpression(node)) {453 return node;454 }455 if (isIdentifier(node, {456 name: "arguments"457 })) {458 return callExpression(memberExpression(memberExpression(memberExpression(identifier("Array"), identifier("prototype")), identifier("slice")), identifier("call")), [node]);459 }460 let helperName;461 const args = [node];462 if (i === true) {463 helperName = "toConsumableArray";464 } else if (typeof i === "number") {465 args.push(numericLiteral(i));466 helperName = "slicedToArray";467 } else {468 helperName = "toArray";469 }470 if (arrayLikeIsIterable) {471 args.unshift(this.hub.addHelper(helperName));472 helperName = "maybeArrayLike";473 }474 return callExpression(this.hub.addHelper(helperName), args);475 425 } 476 426 hasLabel(name) { … … 811 761 scope = scope.parent; 812 762 } while (scope); 813 return ids;814 }815 getAllBindingsOfKind(...kinds) {816 const ids = Object.create(null);817 for (const kind of kinds) {818 let scope = this;819 do {820 for (const name of Object.keys(scope.bindings)) {821 const binding = scope.bindings[name];822 if (binding.kind === kind) ids[name] = binding;823 }824 scope = scope.parent;825 } while (scope);826 }827 763 return ids; 828 764 } … … 959 895 Scope.globals = Object.keys(_globals.builtin); 960 896 Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"]; 897 { 898 Scope.prototype._renameFromMap = function _renameFromMap(map, oldName, newName, value) { 899 if (map[oldName]) { 900 map[newName] = value; 901 map[oldName] = null; 902 } 903 }; 904 Scope.prototype.traverse = function (node, opts, state) { 905 (0, _index.default)(node, opts, this, state, this.path); 906 }; 907 Scope.prototype._generateUid = function _generateUid(name, i) { 908 let id = name; 909 if (i > 1) id += i; 910 return `_${id}`; 911 }; 912 Scope.prototype.toArray = function toArray(node, i, arrayLikeIsIterable) { 913 if (isIdentifier(node)) { 914 const binding = this.getBinding(node.name); 915 if (binding != null && binding.constant && binding.path.isGenericType("Array")) { 916 return node; 917 } 918 } 919 if (isArrayExpression(node)) { 920 return node; 921 } 922 if (isIdentifier(node, { 923 name: "arguments" 924 })) { 925 return callExpression(memberExpression(memberExpression(memberExpression(identifier("Array"), identifier("prototype")), identifier("slice")), identifier("call")), [node]); 926 } 927 let helperName; 928 const args = [node]; 929 if (i === true) { 930 helperName = "toConsumableArray"; 931 } else if (typeof i === "number") { 932 args.push(numericLiteral(i)); 933 helperName = "slicedToArray"; 934 } else { 935 helperName = "toArray"; 936 } 937 if (arrayLikeIsIterable) { 938 args.unshift(this.path.hub.addHelper(helperName)); 939 helperName = "maybeArrayLike"; 940 } 941 return callExpression(this.path.hub.addHelper(helperName), args); 942 }; 943 Scope.prototype.getAllBindingsOfKind = function getAllBindingsOfKind(...kinds) { 944 const ids = Object.create(null); 945 for (const kind of kinds) { 946 let scope = this; 947 do { 948 for (const name of Object.keys(scope.bindings)) { 949 const binding = scope.bindings[name]; 950 if (binding.kind === kind) ids[name] = binding; 951 } 952 scope = scope.parent; 953 } while (scope); 954 } 955 return ids; 956 }; 957 Object.defineProperties(Scope.prototype, { 958 parentBlock: { 959 configurable: true, 960 enumerable: true, 961 get() { 962 return this.path.parent; 963 } 964 }, 965 hub: { 966 configurable: true, 967 enumerable: true, 968 get() { 969 return this.path.hub; 970 } 971 } 972 }); 973 } 961 974 962 975 //# sourceMappingURL=index.js.map
Note:
See TracChangeset
for help on using the changeset viewer.