2018-01-08 22:31:54 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Florent Cailhol @ooflorent
|
|
|
|
*/
|
2018-07-30 23:08:51 +08:00
|
|
|
|
2018-01-08 22:31:54 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const ConstDependency = require("./ConstDependency");
|
|
|
|
|
|
|
|
class HarmonyTopLevelThisParserPlugin {
|
|
|
|
apply(parser) {
|
2018-02-25 09:00:20 +08:00
|
|
|
parser.hooks.expression
|
|
|
|
.for("this")
|
|
|
|
.tap("HarmonyTopLevelThisParserPlugin", node => {
|
|
|
|
if (!parser.scope.topLevelScope) return;
|
2019-12-02 05:46:17 +08:00
|
|
|
const isHarmony = parser.state.harmonyModule;
|
2018-02-25 09:00:20 +08:00
|
|
|
if (isHarmony) {
|
2018-12-06 02:21:18 +08:00
|
|
|
const dep = new ConstDependency("undefined", node.range, null);
|
2018-02-25 09:00:20 +08:00
|
|
|
dep.loc = node.loc;
|
2019-10-30 13:40:40 +08:00
|
|
|
parser.state.module.addPresentationalDependency(dep);
|
2018-02-25 09:00:20 +08:00
|
|
|
}
|
|
|
|
});
|
2018-01-08 22:31:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = HarmonyTopLevelThisParserPlugin;
|