|
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.2 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
|---|
| 3 | Author Florent Cailhol @ooflorent
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | "use strict";
|
|---|
| 7 |
|
|---|
| 8 | const ConstDependency = require("./ConstDependency");
|
|---|
| 9 | const HarmonyExports = require("./HarmonyExports");
|
|---|
| 10 |
|
|---|
| 11 | /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|---|
| 12 | /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|---|
| 13 | /** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|---|
| 14 |
|
|---|
| 15 | const PLUGIN_NAME = "HarmonyTopLevelThisParserPlugin";
|
|---|
| 16 |
|
|---|
| 17 | class HarmonyTopLevelThisParserPlugin {
|
|---|
| 18 | /**
|
|---|
| 19 | * Applies the plugin by registering its hooks on the compiler.
|
|---|
| 20 | * @param {JavascriptParser} parser the parser
|
|---|
| 21 | * @returns {void}
|
|---|
| 22 | */
|
|---|
| 23 | apply(parser) {
|
|---|
| 24 | parser.hooks.expression.for("this").tap(PLUGIN_NAME, (node) => {
|
|---|
| 25 | if (!parser.scope.topLevelScope) return;
|
|---|
| 26 | if (HarmonyExports.isEnabled(parser.state)) {
|
|---|
| 27 | const dep = new ConstDependency(
|
|---|
| 28 | "undefined",
|
|---|
| 29 | /** @type {Range} */ (node.range),
|
|---|
| 30 | null
|
|---|
| 31 | );
|
|---|
| 32 | dep.loc = /** @type {DependencyLocation} */ (node.loc);
|
|---|
| 33 | parser.state.module.addPresentationalDependency(dep);
|
|---|
| 34 | return true;
|
|---|
| 35 | }
|
|---|
| 36 | });
|
|---|
| 37 | }
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | module.exports = HarmonyTopLevelThisParserPlugin;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.