Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/@babel/traverse/lib/scope/index.js

    rd565449 r0c6b92a  
    272272      path.scope.registerBinding("param", param);
    273273    }
    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]) {
    275275      path.scope.registerBinding("local", path.get("id"), path);
    276276    }
    277277  },
    278278  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]) {
    280280      path.scope.registerBinding("local", path.get("id"), path);
    281281    }
     
    291291    this.path = void 0;
    292292    this.block = void 0;
     293    this.inited = void 0;
    293294    this.labels = void 0;
    294     this.inited = void 0;
    295295    this.bindings = void 0;
    296296    this.references = void 0;
     
    326326    return (_parent = parent) == null ? void 0 : _parent.scope;
    327327  }
    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   }
    337328  generateDeclaredUidIdentifier(name) {
    338329    const id = this.generateUidIdentifier(name);
     
    350341    let i = 1;
    351342    do {
    352       uid = this._generateUid(name, i);
     343      uid = `_${name}`;
     344      if (i > 1) uid += i;
    353345      i++;
    354346    } while (this.hasLabel(uid) || this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid));
     
    357349    program.uids[uid] = true;
    358350    return uid;
    359   }
    360   _generateUid(name, i) {
    361     let id = name;
    362     if (i > 1) id += i;
    363     return `_${id}`;
    364351  }
    365352  generateUidBasedOnNode(node, defaultName) {
     
    406393    const duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && kind === "const";
    407394    if (duplicate) {
    408       throw this.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
     395      throw this.path.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
    409396    }
    410397  }
     
    417404        renamer.rename(arguments[2]);
    418405      }
    419     }
    420   }
    421   _renameFromMap(map, oldName, newName, value) {
    422     if (map[oldName]) {
    423       map[newName] = value;
    424       map[oldName] = null;
    425406    }
    426407  }
     
    442423    } while (scope = scope.parent);
    443424    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);
    475425  }
    476426  hasLabel(name) {
     
    811761      scope = scope.parent;
    812762    } 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     }
    827763    return ids;
    828764  }
     
    959895Scope.globals = Object.keys(_globals.builtin);
    960896Scope.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}
    961974
    962975//# sourceMappingURL=index.js.map
Note: See TracChangeset for help on using the changeset viewer.