{"version":3,"sources":["https://lively-kernel.org/lively4/swt21-debugging/src/external/babel-plugin-var-recorder.js"],"names":["moduleNameToVarRecorderName","Map","getScopeIdForModule","moduleName","has","scopeId","replace","lively4url","set","get","GENERATED","Symbol","isMarked","node","mark","VarRecorder","enter","program","state","file","var_recorder_info","filename","log","initTemplates","splitUpVariableDeclarations","rewriteBindings","removeTrashNodes","exit","path","lazyInitializeModuleScopeTemplate","template","VAR_RECORDER_NAME","MODULE_IDENTIFIER","lazyInitializeModuleScope","unshiftContainer","MODULE_NAME","_MODULE_NAME","DOIT_MATCHER","MODULE_MATCHER","window","__topLevelVarRecorder_ModuleNames__","test","codeIdAndPath","codeId","Error","ensureVarRecorder","ensureVarRecorderModule","rec","varToRecordTemplate","recordToVarTemplate","referenceTemplate","replaceReference","ref","replaceWith","reference","expression","skip","topLevelVariableDeclarations","Set","topLevelVariableExportDeclarations","binding","getAllBindings","declarationPath","parentPath","parent","type","declarations","length","add","simpleExportDeclaration","name","t","ExportNamedDeclaration","rewriteExportVariableDeclarations","Array","from","exportDeclaration","forEach","declarator","isIdentifier","insertBefore","id","traverse","Identifier","isObjectProperty","parentKey","reverse","init","insertAfter","kind","trashNode","rewriteGloablVariableDeclarations","references","push","refString","map","ea","join","pattern","partOfForStatement","shouldSortOut","isVariableDeclarator","isVariableDeclaration","isForAwaitStatement","isForInStatement","isForOfStatement","isForStatement","bubbleThroughPattern","isArrayPattern","isRestElement","isObjectPattern","isRestProperty","rewriteBinding","__ignoreRecorder__","referencePaths","filter","isExportNamedDeclaration","isExportDefaultDeclaration","isExportSpecifier","find","isProgram","identifier","newPath","findParent","p","isPattern","isDeclaration","varToRecord","referenceString","stringLiteral","arguments","properties","body","loc","markedAsMeta","getStatementParent","isVariable","isLabeledStatement","isBreakStatement","isFunctionExpression","isImportDefaultSpecifier","isCatchClause","isClassDeclaration","isClassMethod","isImportSpecifier","isMemberExpression","computed","isObjectMethod","isFunctionDeclaration","isArrowFunctionExpression","rewriteIdentifiers","isAssignmentExpression","par","scope","hasOwnBinding","getOwnBinding","hasGlobal","moduleBoundGlobals","includes","rewriteAllIdentifiers","_moduleBoundGlobals","Object","keys","values","toBeRemoved","remove","types","_types","_template","visitor","Program","var_recorder"],"mappings":";;;;;;AAAA,YAAMA,8BAA8B,IAAIC,GAAJ,EAApC;;AAEO,eAASC,mBAAT,CAA6BC,UAA7B,EAAyC;AAC9C;AACA,YAAI,CAACH,4BAA4BI,GAA5B,CAAgCD,UAAhC,CAAL,EAAkD;AAChD,cAAIE,UAAU,CAACF,cAAc,WAAf,EAA4BG,OAA5B,CAAoCC,UAApC,EAAgD,EAAhD,EAAoDD,OAApD,CAA4D,eAA5D,EAA6E,GAA7E,CAAd;AACAN,sCAA4BQ,GAA5B,CAAgCL,UAAhC,EAA4CE,OAA5C;AACD;AACD,eAAOL,4BAA4BS,GAA5B,CAAgCN,UAAhC,CAAP;AACD;;AAGD;;;;AACA,YAAMO,YAAYC,OAAO,WAAP,CAAlB;AACA;AACA,eAASC,QAAT,CAAkBC,IAAlB,EAAwB;AACtB,eAAOA,KAAKH,SAAL,CAAP;AACD;AACD,eAASI,IAAT,CAAcD,IAAd,EAAoB;AAClBA,aAAKH,SAAL,IAAkB,IAAlB;AACA,eAAOG,IAAP;AACD;;AAID,YAAME,WAAN,CAAkB;;AAEhB;AACAC,cAAMC,OAAN,EAAeC,KAAf,EAAsB;AACpB,eAAKD,OAAL,GAAeA,OAAf;AACA,gBAAME,OAAOD,MAAMC,IAAnB;AACAD,gBAAME,iBAAN,GAA0B,EAA1B;;AAEA,eAAKC,QAAL,GAAgBF,KAAKG,GAAL,CAASD,QAAzB;;AAEA,eAAKE,aAAL;AACA,eAAKC;;AAEL;AACA;;AAHA,aAKA,KAAKC,eAAL;;AAEA,eAAKC,gBAAL;AACD;;AAED;AACAC,aAAKC,IAAL,EAAWV,KAAX,EAAkB;AAChB,gBAAMW,oCAAoCC,SACvC,GAAE,KAAKC,iBAAkB,IAAG,KAAKC,iBAAkB,MAA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gB,OAAtB,CAA8BjB,WAAW,KAAKoD,cAAL,CAAoBpD,OAApB,CAAzC;AACA,eAAK3C,OAAL,CAAaiE,QAAb,CAAsB;AACpBC,wBAAavD,IAAD,IAAU,KAAK0H,kBAAL,CAAwB1H,IAAxB;AADF,WAAtB;AAGD;;AAED8D,kBAAU7E,IAAV,EAAgB;AACd,cAAI,CAAC,KAAKuJ,WAAV,EAAuB,KAAKA,WAAL,GAAmB,IAAI1G,GAAJ,EAAnB;AACvB,eAAK0G,WAAL,CAAiBhG,GAAjB,CAAqBvD,IAArB;AACD;;AAEDa,2BAAmB;AACjB,cAAI,CAAC,KAAK0I,WAAV,EAAuB;AACvB,eAAKA,WAAL,CAAiBvF,OAAjB,CAAyBmB,MAAM;AAC7BA,eAAGqE,MAAH;AACD,WAFD;AAGA,eAAKD,WAAL,GAAmB,IAAI1G,GAAJ,EAAnB,CALiB,CAKY;AAC9B;AA5Ze;;AAgalB,UAAIa,CAAJ,EAAOzC,QAAP;;AAEA;;yBAEe,UAAS,EAAEwI,OAAOC,MAAT,EAAiBzI,UAAU0I,SAA3B,EAAT,EAAiD;AAC9DjG,YAAIgG,MAAJ;AACAzI,mBAAW0I,SAAX;;AAEA,eAAO;AACLlG,gBAAM,wBADD;AAELmG,mBAAS;AACPC,qBAAS;AACP1J,oBAAMC,OAAN,EAAeC,KAAf,EAAsB;AACpBA,sBAAMyJ,YAAN,GAAqB,IAAI5J,WAAJ,EAArB;AACAG,sBAAMyJ,YAAN,CAAmB3J,KAAnB,CAAyBC,OAAzB,EAAkCC,KAAlC;AACD,eAJM;AAKPS,mBAAKC,IAAL,EAAWV,KAAX,EAAkB;AAChBA,sBAAMyJ,YAAN,CAAmBhJ,IAAnB,CAAwBC,IAAxB,EAA8BV,KAA9B;AACD;AAPM;AADF;AAFJ,SAAP;AAeD,O","file":"babel-plugin-var-recorder.js","sourcesContent":["const moduleNameToVarRecorderName = new Map();\n\nexport function getScopeIdForModule(moduleName) {\n  // console.log(\"[babel-plugin-var-recorder] getScopeIdForModule\", moduleName);\n  if (!moduleNameToVarRecorderName.has(moduleName)) {\n    var scopeId = (moduleName || \"undefined\").replace(lively4url, \"\").replace(/[^a-zA-Z0-9]/g, \"_\")\n    moduleNameToVarRecorderName.set(moduleName, scopeId);\n  }\n  return moduleNameToVarRecorderName.get(moduleName);\n}\n\n\n/*MD ## Marking Nodes MD*/\nconst GENERATED = Symbol('generated');\n// we could use WeakMaps instead?\nfunction isMarked(node) {\n  return node[GENERATED];\n}\nfunction mark(node) {\n  node[GENERATED] = true;\n  return node;\n}\n\n\n\nclass VarRecorder {\n    \n  /*MD ## Visitor API MD*/\n  enter(program, state) {\n    this.program = program\n    const file = state.file;\n    state.var_recorder_info = {};\n\n    this.filename = file.log.filename\n\n    this.initTemplates()\n    this.splitUpVariableDeclarations()\n    \n    // this.rewriteExportVariableDeclarations()\n    // this.rewriteGloablVariableDeclarations()\n    \n    this.rewriteBindings()\n\n    this.removeTrashNodes()\n  }\n\n  // #Important qw\n  exit(path, state) {\n    const lazyInitializeModuleScopeTemplate = template(\n      `${this.VAR_RECORDER_NAME}.${this.MODULE_IDENTIFIER} = ${this.VAR_RECORDER_NAME}.${this.MODULE_IDENTIFIER} || {}`);\n    const lazyInitializeModuleScope = lazyInitializeModuleScopeTemplate();\n    path.unshiftContainer('body', lazyInitializeModuleScope);\n    path.unshiftContainer('body', template(\"const __SystemJSRewritingHack = {};\")());\n  }\n\n  /*MD ## Implementation MD*/\n\n  get MODULE_NAME() {\n    if (!this._MODULE_NAME) {\n      const DOIT_MATCHER = /^workspace(async)?(js)?:/;\n      const MODULE_MATCHER = /.js$/;\n\n      if (window.__topLevelVarRecorder_ModuleNames__ && DOIT_MATCHER.test(this.filename) && !MODULE_MATCHER.test(this.filename)) {\n        // workspace: becomes workspacejs... e.g. and we are only interested in the id ...\n        var codeIdAndPath = this.filename.replace(DOIT_MATCHER, \"\") \n        // strip path... that we encoded.... \n        var codeId = codeIdAndPath.replace(/\\/.*/, \"\") \n\n        codeId = codeId + \"/\" // see bound-eval.js \n\n        // (A) - filename\n        // (B) - code id (per doit?) and a path....\n\n        // TODO the path should be the module in the first place.....\n        // why not: MODULE_NAME = codeIdAndPath.replace(/^[\\/]*/,\"\")\n        this._MODULE_NAME = window.__topLevelVarRecorder_ModuleNames__[codeId];\n        // console.log(\"boundEval MODULE_NAME: \" + MODULE_NAME + \" codeId: \" + codeId)\n      } else if (!DOIT_MATCHER.test(this.filename) && MODULE_MATCHER.test(this.filename)) {\n        // eval a .js file\n        this._MODULE_NAME = this.filename;\n      } else {\n        throw new Error(`Transpiling neither a .js module nor workspace code(${this._MODULE_NAME})`);\n      }        \n    }\n    return this._MODULE_NAME\n  }\n\n  get VAR_RECORDER_NAME() {\n    return '_recorder_'; \n  }\n\n  get MODULE_IDENTIFIER() {\n    return getScopeIdForModule(this.MODULE_NAME); \n  }\n\n  ensureVarRecorder() {\n    return window[this.VAR_RECORDER_NAME] = window[this.VAR_RECORDER_NAME] || {};\n  }\n\n  ensureVarRecorderModule() {\n    var rec = this.ensureVarRecorder() \n    return rec[this.MODULE_IDENTIFIER] = rec[this.MODULE_IDENTIFIER] || {};\n  }\n  \n  initTemplates() {\n    this.varToRecordTemplate = template(`\n        Object.defineProperty(${this.VAR_RECORDER_NAME}.${this.MODULE_IDENTIFIER}, referenceString , { \n        get() { return reference; }, \n        set(thisIsVererySecretVariableName) {reference = thisIsVererySecretVariableName; return true }, \n        enumerable: true, \n        configurable: true})\n      `)\n    this.recordToVarTemplate = template(`reference = ${this.VAR_RECORDER_NAME}.${this.MODULE_IDENTIFIER}.reference`),\n    this.referenceTemplate = template(`${this.VAR_RECORDER_NAME}.${this.MODULE_IDENTIFIER}.reference`);\n  }\n\n  replaceReference(ref) {\n    ref.replaceWith(this.referenceTemplate({ reference: ref.node }).expression);\n    ref.skip();\n  }\n\n  splitUpVariableDeclarations() {\n    this.topLevelVariableDeclarations = new Set()\n    this.topLevelVariableExportDeclarations = new Set()\n    for (let binding of this.getAllBindings()) {\n      var declarationPath = binding.path.parentPath\n      if (declarationPath.parent.type == \"ExportNamedDeclaration\") {\n        if (declarationPath.node.declarations && declarationPath.node.declarations.length > 0) {\n          this.topLevelVariableExportDeclarations.add(declarationPath) // we need to split them up\n        }\n      } else if (declarationPath.node.declarations && declarationPath.node.declarations.length > 0) {\n        this.topLevelVariableDeclarations.add(declarationPath) // we need to split them up\n      }\n    }\n  }\n\n  simpleExportDeclaration(name) {\n    return  t.ExportNamedDeclaration(template(`var name`)({ name: name }), [], null)\n  } \n  \n  rewriteExportVariableDeclarations() {\n    for (let declarationPath of Array.from(this.topLevelVariableExportDeclarations)) {\n      var exportDeclaration = declarationPath.parentPath\n      var declarations = declarationPath.get(\"declarations\")\n      declarations.forEach(declarator => {\n        if (declarator.get(\"id\").isIdentifier()) {\n          exportDeclaration.insertBefore(this.simpleExportDeclaration( declarator.node.id))\n        } else {\n          declarator.get(\"id\").traverse({\n            Identifier: (path) => {                    \n              if (path.parentPath.isObjectProperty() && path.parentKey == \"key\") return;\n              exportDeclaration.insertBefore(this.simpleExportDeclaration( path.node))\n            }\n          })\n        }\n      })\n      // insertAfter... will flip the order... so, we do it reverse and then the order will be fine ... fingers crossed! ;-)\n      declarations.reverse().forEach(declarator => {\n        if (declarator.node.init) {\n          exportDeclaration.insertAfter(template(`name = init`)({name: declarator.node.id, init: declarator.node.init}))\n        }\n      })\n      declarationPath.node.kind = \"var\" // asignments in const are a problem... \n      this.trashNode(exportDeclaration)\n    }\n  }\n\n  rewriteGloablVariableDeclarations() {\n    for (let declarationPath of Array.from(this.topLevelVariableDeclarations)) {\n      declarationPath.get(\"declarations\").forEach(declarator => {\n        if (declarator.get(\"id\").isIdentifier()) {                \n          declarationPath.insertBefore(template(`var name`)({\n            name: declarator.node.id\n          }))\n        } else {\n          declarator.get(\"id\").traverse({\n            Identifier(path) {                    \n              if (path.parentPath.isObjectProperty() && path.parentKey == \"key\") return;\n              declarationPath.insertBefore(template(`var name`)({\n                name: path.node\n              }))  \n            }\n          })\n        }\n      })\n\n      // insertAfter... will flip the order... so, we do it reverse and then the order will be fine ... fingers crossed! ;-)\n      declarationPath.get(\"declarations\").reverse().forEach(declarator => {\n        if (declarator.get(\"id\").isIdentifier()) {\n          if (declarator.node.init) {\n            declarationPath.insertAfter(template(`name = init`)({ name: declarator.node.id, init: declarator.node.init }))\n          }\n        } else {\n          if (declarator.node.init) {\n            var references = []\n            declarator.get(\"id\").traverse({\n              Identifier(path) {                    \n                if (path.parentPath.isObjectProperty() && path.parentKey == \"key\") return;\n                references.push(path.node.name)\n              }\n            })\n            // since templates don't support loops, we generate a string here...\n            var refString = references.map(ea => `${this.VAR_RECORDER_NAME}.${this.MODULE_IDENTIFIER}.${ea} = ${ea}`).join(\"; \")\n            declarationPath.insertAfter(template(`{let pattern = init; ${refString}}`)({ \n              pattern: declarator.get(\"id\").node, \n              init: declarator.node.init \n            }))\n          }\n        }\n      })\n      this.trashNode(declarationPath)\n    }\n  }\n\n  partOfForStatement(binding) {\n    const parentPath = binding.path.parentPath;\n    const shouldSortOut = binding.path.isVariableDeclarator() &&\n      parentPath.isVariableDeclaration() &&\n      parentPath.node.kind === \"var\" && ((\n        (\n          parentPath.parentPath.isForAwaitStatement() ||\n          parentPath.parentPath.isForInStatement() ||\n          parentPath.parentPath.isForOfStatement()\n        ) && parentPath.parentKey === \"left\"\n      ) || (\n        parentPath.parentPath.isForStatement() &&\n        parentPath.parentKey === \"init\"\n      ));\n    return shouldSortOut;\n  }\n\n  bubbleThroughPattern(path) {\n    if (path.parentPath.isArrayPattern() && path.parentKey === 'elements') \n      return this.bubbleThroughPattern(path.parentPath);\n    if (path.parentPath.isRestElement() && path.parentKey === 'argument') \n      return this.bubbleThroughPattern(path.parentPath);\n    if (path.parentPath.isObjectPattern() && path.parentKey === 'properties') \n      return this.bubbleThroughPattern(path.parentPath);\n    if (path.parentPath.isObjectProperty() && path.parentKey === 'value') \n      return this.bubbleThroughPattern(path.parentPath);\n    if (path.parentPath.isRestProperty() && path.parentKey === 'argument') \n      return this.bubbleThroughPattern(path.parentPath);\n    return path;\n  }\n\n  rewriteBinding(binding) {\n    if (this.partOfForStatement(binding)) {\n      binding.__ignoreRecorder__ = true;\n      return;\n    } \n\n    binding.referencePaths\n      .filter(ref => {\n        // ExportNamedDeclarations should not be rewritten as reference\n        // they are already rewritten as binding\n\n        if (ref.isExportNamedDeclaration()) {\n          return false;\n        }\n        // Same for declaring the default export\n        if (ref.isExportDefaultDeclaration()) {\n          return false;\n        }\n\n        // handle named exports special\n        if (ref.parentPath.isExportSpecifier() && ref.parentKey === 'local') {\n          ref\n            .find(path => path.parentPath.isProgram())\n            .insertBefore(this.recordToVarTemplate({ reference: mark(t.identifier(binding.identifier.name)) }))\n            .forEach(newPath => newPath.skip());\n          ref.skip();\n          return false;\n        }\n\n        // ObjectPatterns and ArrayPatterns in VariableDeclarations do not accept MemberExpressions.\n        // Thus, we have to filter out these cases explicitly.\n        if (ref.findParent(p => p.isPattern()) && ref.findParent(p => p.isDeclaration())) {\n          let pattern = this.bubbleThroughPattern(ref);\n          if (pattern.parentPath.isVariableDeclarator() && pattern.parentKey === 'id') return false;\n        }\n        return true;\n      })\n      // .forEach(ea => this.replaceReference(ea)); \n\n    // dealing with the declaration of the binding\n    let varToRecord = this.varToRecordTemplate({ reference: t.identifier(binding.identifier.name),\n      referenceString: t.stringLiteral(binding.identifier.name), });\n    // Add location position for AE Debugging\n    varToRecord.expression.arguments[2].properties[1].body.body[0].expression.loc = binding.identifier.loc;\n\n    varToRecord.markedAsMeta = true\n\n\n    if (binding.kind === 'hoisted' /* || binding.kind === 'module'*/ ) {\n      binding.path\n        .find(path => path.isProgram())\n        .unshiftContainer('body', varToRecord);\n    } else {\n      // #DesignQuestion\n      // a) should we add a guard here and check if the variable was recorded and we are reloaded\n      // b) change the semantics of variable declarations to be assigned with \"undefined\" if first time loaded [as implemented below]\n      if (!binding.path.node.init)\n        binding.path.node.init = this.referenceTemplate({\n          reference: t.identifier(binding.identifier.name)\n        }).expression;\n      binding.path\n        .getStatementParent()\n        .insertAfter(varToRecord)\n        .forEach(newPath => newPath.skip());\n    }\n  }\n  \n  // TODO: is there a general way to exclude non-variables?\n  isVariable(path) {\n    // - filter out with negative conditions\n    if (t.isLabeledStatement(path.parent) && path.parentKey === 'label') return false;\n    if (t.isBreakStatement(path.parent) && path.parentKey === 'label') return false;\n    if (t.isForInStatement(path.parent) && path.parentKey === 'left') return false;\n    if (t.isFunctionExpression(path.parent) && path.parentKey === 'id') return false;\n    if (t.isImportDefaultSpecifier(path.parent) && path.parentKey === 'local') return false;\n    if (t.isCatchClause(path.parent) && path.parentKey === 'param') return false;\n    if (t.isObjectProperty(path.parent) && path.parentKey === 'key') return false;\n    if (t.isClassDeclaration(path.parent)) return false;\n    if (t.isClassMethod(path.parent)) return false;\n    if (t.isImportSpecifier(path.parent)) return false; // correct?\n    if (t.isMemberExpression(path.parent) && path.parentKey === 'property' && !path.parent.computed) return false; // TODO: correct?\n    if (t.isObjectMethod(path.parent)) return false;\n    if (t.isFunctionDeclaration(path.parent)) return false;\n    if ((t.isArrowFunctionExpression(path.parent) && path.parentKey === 'params')) return false;\n    if ((t.isFunctionExpression(path.parent) && path.parentKey === 'params')) return false;\n    if (t.isRestElement(path.parent)) return false;\n\n    // TODO: 2nd stage:\n    // - return true on known conditions\n    return true;\n\n    // - throw error at others\n  }\n\n   rewriteIdentifiers(path) {\n    if (isMarked(path.node)) return;\n    if (!this.isVariable(path)) return;\n\n    // special case of assigning to a reference\n    let pattern = this.bubbleThroughPattern(path);\n    if (pattern.parentPath.isAssignmentExpression() && pattern.parentKey === 'left') {\n      let par = path.find(parent => parent.scope.hasOwnBinding(path.node.name));\n      // is our binding scope the module-wide scope?\n      if (par && par.scope === this.program.scope) {\n\n        // is it part of a for in declaration\n        const binding = par.scope.getOwnBinding(path.node.name)\n        if (binding && binding.__ignoreRecorder__) { return; }\n\n        if (!path.find(p => p.node.markedAsMeta)) {\n          this.replaceReference(path);\n        }\n\n        return path.skip();\n      }\n    }\n\n    // Distinguish between module-bound variables and real globals\n    if (\n      path.scope.hasGlobal(path.node.name) &&\n      this.moduleBoundGlobals.includes(path.node.name)\n    ) {\n      this.replaceReference(path);\n      return path.skip();\n    }\n  }\n\n  \n  \n  \n  rewriteAllIdentifiers(path) {\n    if (isMarked(path.node)) return;\n    if (!this.isVariable(path)) return;\n\n    // special case of assigning to a reference\n    let pattern = this.bubbleThroughPattern(path);\n    if (pattern.parentPath.isAssignmentExpression() && pattern.parentKey === 'left') {\n      let par = path.find(parent => parent.scope.hasOwnBinding(path.node.name));\n      // is our binding scope the module-wide scope?\n      if (par && par.scope === this.program.scope) {\n\n        // is it part of a for in declaration\n        const binding = par.scope.getOwnBinding(path.node.name)\n        if (binding && binding.__ignoreRecorder__) { return; }\n\n        if (!path.find(p => p.node.markedAsMeta)) {\n          this.replaceReference(path);\n        }\n\n        return path.skip();\n      }\n    }\n\n    // Distinguish between module-bound variables and real globals\n    if (\n      path.scope.hasGlobal(path.node.name) &&\n      this.moduleBoundGlobals.includes(path.node.name)\n    ) {\n      this.replaceReference(path);\n      return path.skip();\n    }\n  }\n\n  get moduleBoundGlobals() {\n    if(!this._moduleBoundGlobals) {\n      this._moduleBoundGlobals = Object.keys(this.ensureVarRecorderModule());\n    }\n    return this._moduleBoundGlobals\n  } \n\n  getAllBindings() {\n    return Object.values(this.program.scope.getAllBindings())\n  }\n\n  rewriteBindings() {\n    this.getAllBindings().forEach(binding => this.rewriteBinding(binding));   \n    this.program.traverse({\n      Identifier: (path) => this.rewriteIdentifiers(path)\n    })\n  }\n\n  trashNode(node) {\n    if (!this.toBeRemoved) this.toBeRemoved = new Set() \n    this.toBeRemoved.add(node)\n  }\n\n  removeTrashNodes() {\n    if (!this.toBeRemoved) return;\n    this.toBeRemoved.forEach(ea => {\n      ea.remove()\n    })\n    this.toBeRemoved = new Set() // just in case...\n  }\n}\n\n\nlet t, template;\n\n/*MD # Plugin Function MD*/\n\nexport default function({ types: _types, template: _template }) {\n  t = _types;\n  template = _template;\n\n  return {\n    name: \"top-level-var-recorder\",\n    visitor: {\n      Program: {\n        enter(program, state) {\n          state.var_recorder = new VarRecorder()\n          state.var_recorder.enter(program, state)\n        },\n        exit(path, state) {\n          state.var_recorder.exit(path, state)\n        },\n      },\n    }\n  };\n\n}\n"]}