source: imaps-frontend/node_modules/@babel/plugin-transform-parameters/lib/shadow-utils.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.1 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.buildScopeIIFE = buildScopeIIFE;
7exports.collectShadowedParamsNames = collectShadowedParamsNames;
8exports.iifeVisitor = void 0;
9var _core = require("@babel/core");
10const iifeVisitor = exports.iifeVisitor = {
11 "ReferencedIdentifier|BindingIdentifier"(path, state) {
12 const {
13 scope,
14 node
15 } = path;
16 const {
17 name
18 } = node;
19 if (name === "eval" || scope.getBinding(name) === state.scope.parent.getBinding(name) && state.scope.hasOwnBinding(name)) {
20 state.needsOuterBinding = true;
21 path.stop();
22 }
23 },
24 "TypeAnnotation|TSTypeAnnotation|TypeParameterDeclaration|TSTypeParameterDeclaration": path => path.skip()
25};
26function collectShadowedParamsNames(param, functionScope, shadowedParams) {
27 for (const name of Object.keys(param.getBindingIdentifiers())) {
28 var _functionScope$bindin;
29 const constantViolations = (_functionScope$bindin = functionScope.bindings[name]) == null ? void 0 : _functionScope$bindin.constantViolations;
30 if (constantViolations) {
31 for (const redeclarator of constantViolations) {
32 const node = redeclarator.node;
33 switch (node.type) {
34 case "VariableDeclarator":
35 {
36 if (node.init === null) {
37 const declaration = redeclarator.parentPath;
38 if (!declaration.parentPath.isFor() || declaration.parentPath.get("body") === declaration) {
39 redeclarator.remove();
40 break;
41 }
42 }
43 shadowedParams.add(name);
44 break;
45 }
46 case "FunctionDeclaration":
47 shadowedParams.add(name);
48 break;
49 }
50 }
51 }
52 }
53}
54function buildScopeIIFE(shadowedParams, body) {
55 const args = [];
56 const params = [];
57 for (const name of shadowedParams) {
58 args.push(_core.types.identifier(name));
59 params.push(_core.types.identifier(name));
60 }
61 return _core.types.returnStatement(_core.types.callExpression(_core.types.arrowFunctionExpression(params, body), args));
62}
63
64//# sourceMappingURL=shadow-utils.js.map
Note: See TracBrowser for help on using the repository browser.