JS: collect label definitions, not some of their usages

This commit is contained in:
Anton Bannykh
2019-02-11 20:55:11 +03:00
parent b7bea3242e
commit 5c1664ebf8
2 changed files with 8 additions and 6 deletions
@@ -106,9 +106,9 @@ fun collectDefinedNames(scope: JsNode): Set<JsName> {
super.visitExpressionStatement(x)
}
override fun visitBreak(x: JsBreak) {
x.label?.name?.let { names += it }
super.visitBreak(x)
override fun visitLabel(x: JsLabel) {
x.name?.let { names += it }
super.visitLabel(x)
}
override fun visitCatch(x: JsCatch) {
@@ -141,9 +141,9 @@ fun collectDefinedNamesInAllScopes(scope: JsNode): Set<JsName> {
x.name?.let { names += it }
}
override fun visitBreak(x: JsBreak) {
x.label?.name?.let { names += it }
super.visitBreak(x)
override fun visitLabel(x: JsLabel) {
x.name?.let { names += it }
super.visitLabel(x)
}
override fun visitCatch(x: JsCatch) {
@@ -337,6 +337,7 @@ public final class Translation {
JsProgramFragment fragment = staticContext.getFragment();
for (String tag : staticContext.getInlineFunctionTags()) {
assert !inlineFunctionTagMap.containsKey(tag) : "Duplicate inline function tag found: '" + tag + "'";
inlineFunctionTagMap.put(tag, unit);
}
NormalizeImportTagsKt.normalizeImportTags(fragment);
@@ -349,6 +350,7 @@ public final class Translation {
byte[] headerData = ((TranslationUnit.BinaryAst) unit).getHeader();
JsAstProtoBuf.Header h = JsAstProtoBuf.Header.parseFrom(CodedInputStream.newInstance(headerData));
for (String tag : h.getInlineFunctionTagsList()) {
assert !inlineFunctionTagMap.containsKey(tag) : "Duplicate inline function tag found: '" + tag + "'";
inlineFunctionTagMap.put(tag, unit);
}
}