KJS: Add JsLoop AST interface and corresponding visitors
This commit is contained in:
@@ -18,7 +18,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Note that any of the parts of the <code>for</code> loop header can be
|
||||
* <code>null</code>, although the body will never be null.
|
||||
*/
|
||||
public class JsFor extends SourceInfoAwareJsNode implements JsStatement {
|
||||
public class JsFor extends SourceInfoAwareJsNode implements JsLoop {
|
||||
private JsStatement body;
|
||||
private JsExpression condition;
|
||||
private JsExpression incrementExpression;
|
||||
|
||||
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.js.backend.ast;
|
||||
import org.jetbrains.kotlin.js.util.AstUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JsForIn extends SourceInfoAwareJsNode implements JsStatement {
|
||||
public class JsForIn extends SourceInfoAwareJsNode implements JsLoop {
|
||||
private JsStatement body;
|
||||
private JsExpression iterExpression;
|
||||
private JsExpression objectExpression;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.backend.ast;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface JsLoop extends JsStatement {
|
||||
@NotNull
|
||||
@Override
|
||||
JsStatement deepCopy();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ abstract class JsVisitor {
|
||||
visitElement(x)
|
||||
|
||||
open fun visitDoWhile(x: JsDoWhile): Unit =
|
||||
visitElement(x)
|
||||
visitLoop(x)
|
||||
|
||||
open fun visitEmpty(x: JsEmpty): Unit =
|
||||
visitElement(x)
|
||||
@@ -73,10 +73,10 @@ abstract class JsVisitor {
|
||||
visitElement(x)
|
||||
|
||||
open fun visitFor(x: JsFor): Unit =
|
||||
visitElement(x)
|
||||
visitLoop(x)
|
||||
|
||||
open fun visitForIn(x: JsForIn): Unit =
|
||||
visitElement(x)
|
||||
visitLoop(x)
|
||||
|
||||
open fun visitFunction(x: JsFunction): Unit =
|
||||
visitElement(x)
|
||||
@@ -90,6 +90,9 @@ abstract class JsVisitor {
|
||||
open fun visitLabel(x: JsLabel): Unit =
|
||||
visitElement(x)
|
||||
|
||||
open fun visitLoop(x: JsLoop): Unit =
|
||||
visitElement(x)
|
||||
|
||||
open fun visitNameRef(nameRef: JsNameRef): Unit =
|
||||
visitElement(nameRef)
|
||||
|
||||
@@ -151,7 +154,7 @@ abstract class JsVisitor {
|
||||
visitElement(x)
|
||||
|
||||
open fun visitWhile(x: JsWhile): Unit =
|
||||
visitElement(x)
|
||||
visitLoop(x)
|
||||
|
||||
open fun visitDocComment(comment: JsDocComment): Unit =
|
||||
visitElement(comment)
|
||||
|
||||
@@ -104,6 +104,7 @@ public abstract class JsVisitorWithContext {
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsDoWhile x, @NotNull JsContext ctx) {
|
||||
endVisit((JsLoop) x, ctx);
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsEmpty x, @NotNull JsContext ctx) {
|
||||
@@ -113,9 +114,11 @@ public abstract class JsVisitorWithContext {
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsFor x, @NotNull JsContext ctx) {
|
||||
endVisit((JsLoop) x, ctx);
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsForIn x, @NotNull JsContext ctx) {
|
||||
endVisit((JsLoop) x, ctx);
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsFunction x, @NotNull JsContext ctx) {
|
||||
@@ -132,6 +135,9 @@ public abstract class JsVisitorWithContext {
|
||||
public void endVisit(@NotNull JsLabel x, @NotNull JsContext ctx) {
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsLoop x, @NotNull JsContext ctx) {
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsName x, @NotNull JsContext ctx) {
|
||||
}
|
||||
|
||||
@@ -202,6 +208,7 @@ public abstract class JsVisitorWithContext {
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsWhile x, @NotNull JsContext ctx) {
|
||||
endVisit((JsLoop) x, ctx);
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsArrayAccess x, @NotNull JsContext ctx) {
|
||||
@@ -253,7 +260,7 @@ public abstract class JsVisitorWithContext {
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsDoWhile x, @NotNull JsContext ctx) {
|
||||
return true;
|
||||
return visit((JsLoop) x, ctx);
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsEmpty x, @NotNull JsContext ctx) {
|
||||
@@ -265,11 +272,11 @@ public abstract class JsVisitorWithContext {
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsFor x, @NotNull JsContext ctx) {
|
||||
return true;
|
||||
return visit((JsLoop) x, ctx);
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsForIn x, @NotNull JsContext ctx) {
|
||||
return true;
|
||||
return visit((JsLoop) x, ctx);
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsFunction x, @NotNull JsContext ctx) {
|
||||
@@ -288,6 +295,10 @@ public abstract class JsVisitorWithContext {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsLoop x, @NotNull JsContext ctx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsName x, @NotNull JsContext ctx) {
|
||||
return true;
|
||||
}
|
||||
@@ -369,7 +380,7 @@ public abstract class JsVisitorWithContext {
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsWhile x, @NotNull JsContext ctx) {
|
||||
return true;
|
||||
return visit((JsLoop) x, ctx);
|
||||
}
|
||||
|
||||
protected abstract <T extends JsNode> T doAccept(T node);
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* A JavaScript <code>while</code> statement.
|
||||
*/
|
||||
public class JsWhile extends SourceInfoAwareJsNode implements JsStatement {
|
||||
public class JsWhile extends SourceInfoAwareJsNode implements JsLoop {
|
||||
protected JsStatement body;
|
||||
protected JsExpression condition;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user