simplify AST (idea like)
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.backend.js.JsToStringGenerationVisitor;
|
import com.google.dart.compiler.backend.js.JsToStringGenerationVisitor;
|
||||||
import com.google.dart.compiler.common.HasSourceInfo;
|
|
||||||
import com.google.dart.compiler.util.TextOutputImpl;
|
import com.google.dart.compiler.util.TextOutputImpl;
|
||||||
|
|
||||||
abstract class AbstractNode implements JsNode, HasSourceInfo {
|
abstract class AbstractNode implements JsNode {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
TextOutputImpl out = new TextOutputImpl();
|
TextOutputImpl out = new TextOutputImpl();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Represents a JavaScript block statement.
|
* Represents a JavaScript block statement.
|
||||||
*/
|
*/
|
||||||
public class JsBlock extends JsNodeImpl implements JsStatement {
|
public class JsBlock extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
private final List<JsStatement> statements;
|
private final List<JsStatement> statements;
|
||||||
|
|
||||||
public JsBlock() {
|
public JsBlock() {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
/**
|
/**
|
||||||
* Represents a JavaScript catch clause.
|
* Represents a JavaScript catch clause.
|
||||||
*/
|
*/
|
||||||
public class JsCatch extends JsNodeImpl implements HasCondition {
|
public class JsCatch extends SourceInfoAwareJsNode implements HasCondition {
|
||||||
|
|
||||||
protected final JsCatchScope scope;
|
protected final JsCatchScope scope;
|
||||||
private JsBlock body;
|
private JsBlock body;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class JsContinue extends JsNodeImpl implements JsStatement {
|
public class JsContinue extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
protected final String label;
|
protected final String label;
|
||||||
|
|
||||||
public JsContinue() {
|
public JsContinue() {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
/**
|
/**
|
||||||
* Represents a JavaScript debugger statement.
|
* Represents a JavaScript debugger statement.
|
||||||
*/
|
*/
|
||||||
public class JsDebugger extends JsNodeImpl implements JsStatement {
|
public class JsDebugger extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
public JsDebugger() {
|
public JsDebugger() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
public class JsEmpty extends JsNodeImpl implements JsStatement {
|
public class JsEmpty extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
JsEmpty() {
|
JsEmpty() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
abstract class JsExpressionImpl extends JsNodeImpl implements JsExpression {
|
abstract class JsExpressionImpl extends SourceInfoAwareJsNode implements JsExpression {
|
||||||
protected JsExpressionImpl() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether or not this expression is a leaf, such as a
|
* Determines whether or not this expression is a leaf, such as a
|
||||||
* {@link JsNameRef}, {@link JsLiteral.JsBooleanLiteral}, and so on. Leaf expressions
|
* {@link JsNameRef}, {@link JsLiteral.JsBooleanLiteral}, and so on. Leaf expressions
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
* Note that any of the parts of the <code>for</code> loop header can be
|
* 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.
|
* <code>null</code>, although the body will never be null.
|
||||||
*/
|
*/
|
||||||
public class JsFor extends JsNodeImpl implements JsStatement {
|
public class JsFor extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
private JsStatement body;
|
private JsStatement body;
|
||||||
private JsExpression condition;
|
private JsExpression condition;
|
||||||
private JsExpression incrementExpression;
|
private JsExpression incrementExpression;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
public class JsForIn extends JsNodeImpl implements JsStatement {
|
public class JsForIn extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
private JsStatement body;
|
private JsStatement body;
|
||||||
private JsExpression iterExpression;
|
private JsExpression iterExpression;
|
||||||
private JsExpression objectExpression;
|
private JsExpression objectExpression;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
/**
|
/**
|
||||||
* Represents a JavaScript if statement.
|
* Represents a JavaScript if statement.
|
||||||
*/
|
*/
|
||||||
public final class JsIf extends JsNodeImpl implements JsStatement {
|
public final class JsIf extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
private JsExpression ifExpression;
|
private JsExpression ifExpression;
|
||||||
private JsStatement thenStatement;
|
private JsStatement thenStatement;
|
||||||
private JsStatement elseStatement;
|
private JsStatement elseStatement;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.google.dart.compiler.common.Symbol;
|
|||||||
/**
|
/**
|
||||||
* Represents a JavaScript label statement.
|
* Represents a JavaScript label statement.
|
||||||
*/
|
*/
|
||||||
public class JsLabel extends JsNodeImpl implements JsStatement, HasName {
|
public class JsLabel extends SourceInfoAwareJsNode implements JsStatement, HasName {
|
||||||
private final JsName label;
|
private final JsName label;
|
||||||
|
|
||||||
private JsStatement statement;
|
private JsStatement statement;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.google.dart.compiler.common.Symbol;
|
|||||||
/**
|
/**
|
||||||
* A JavaScript parameter.
|
* A JavaScript parameter.
|
||||||
*/
|
*/
|
||||||
public final class JsParameter extends JsNodeImpl implements HasName {
|
public final class JsParameter extends SourceInfoAwareJsNode implements HasName {
|
||||||
private final JsName name;
|
private final JsName name;
|
||||||
|
|
||||||
public JsParameter(JsName name) {
|
public JsParameter(JsName name) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import static com.google.dart.compiler.backend.js.ast.JsNumberLiteral.JsIntLiter
|
|||||||
/**
|
/**
|
||||||
* A JavaScript program.
|
* A JavaScript program.
|
||||||
*/
|
*/
|
||||||
public final class JsProgram extends JsNodeImpl {
|
public final class JsProgram extends SourceInfoAwareJsNode {
|
||||||
private final JsEmpty emptyStatement;
|
private final JsEmpty emptyStatement;
|
||||||
|
|
||||||
private JsProgramFragment[] fragments;
|
private JsProgramFragment[] fragments;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
/**
|
/**
|
||||||
* One independently loadable fragment of a {@link JsProgram}.
|
* One independently loadable fragment of a {@link JsProgram}.
|
||||||
*/
|
*/
|
||||||
public class JsProgramFragment extends JsNodeImpl {
|
public class JsProgramFragment extends SourceInfoAwareJsNode {
|
||||||
private final JsGlobalBlock globalBlock;
|
private final JsGlobalBlock globalBlock;
|
||||||
|
|
||||||
public JsProgramFragment() {
|
public JsProgramFragment() {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* Used in object literals to specify property values by name.
|
* Used in object literals to specify property values by name.
|
||||||
*/
|
*/
|
||||||
public class JsPropertyInitializer extends JsNodeImpl {
|
public class JsPropertyInitializer extends SourceInfoAwareJsNode {
|
||||||
private JsExpression labelExpr;
|
private JsExpression labelExpr;
|
||||||
private JsExpression valueExpr;
|
private JsExpression valueExpr;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
/**
|
/**
|
||||||
* A JavaScript return statement.
|
* A JavaScript return statement.
|
||||||
*/
|
*/
|
||||||
public final class JsReturn extends JsNodeImpl implements JsStatement {
|
public final class JsReturn extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
private JsExpression expression;
|
private JsExpression expression;
|
||||||
|
|
||||||
public JsReturn() {
|
public JsReturn() {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* A JavaScript switch statement.
|
* A JavaScript switch statement.
|
||||||
*/
|
*/
|
||||||
public class JsSwitch extends JsNodeImpl implements JsStatement {
|
public class JsSwitch extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
|
|
||||||
private final List<JsSwitchMember> cases = new ArrayList<JsSwitchMember>();
|
private final List<JsSwitchMember> cases = new ArrayList<JsSwitchMember>();
|
||||||
private JsExpression expression;
|
private JsExpression expression;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* A member/case in a JavaScript switch object.
|
* A member/case in a JavaScript switch object.
|
||||||
*/
|
*/
|
||||||
public abstract class JsSwitchMember extends JsNodeImpl {
|
public abstract class JsSwitchMember extends SourceInfoAwareJsNode {
|
||||||
protected final List<JsStatement> statements = new SmartList<JsStatement>();
|
protected final List<JsStatement> statements = new SmartList<JsStatement>();
|
||||||
|
|
||||||
protected JsSwitchMember() {
|
protected JsSwitchMember() {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
public class JsThrow extends JsNodeImpl implements JsStatement {
|
public class JsThrow extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
private JsExpression expression;
|
private JsExpression expression;
|
||||||
|
|
||||||
public JsThrow() {
|
public JsThrow() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* A JavaScript <code>try</code> statement.
|
* A JavaScript <code>try</code> statement.
|
||||||
*/
|
*/
|
||||||
public class JsTry extends JsNodeImpl implements JsStatement {
|
public class JsTry extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
private final List<JsCatch> catches;
|
private final List<JsCatch> catches;
|
||||||
private JsBlock finallyBlock;
|
private JsBlock finallyBlock;
|
||||||
private JsBlock tryBlock;
|
private JsBlock tryBlock;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* A JavaScript <code>var</code> statement.
|
* A JavaScript <code>var</code> statement.
|
||||||
*/
|
*/
|
||||||
public class JsVars extends JsNodeImpl implements JsStatement, Iterable<JsVars.JsVar> {
|
public class JsVars extends SourceInfoAwareJsNode implements JsStatement, Iterable<JsVars.JsVar> {
|
||||||
private final List<JsVar> vars;
|
private final List<JsVar> vars;
|
||||||
|
|
||||||
private final boolean multiline;
|
private final boolean multiline;
|
||||||
@@ -49,7 +49,7 @@ public class JsVars extends JsNodeImpl implements JsStatement, Iterable<JsVars.J
|
|||||||
/**
|
/**
|
||||||
* A var declared using the JavaScript <code>var</code> statement.
|
* A var declared using the JavaScript <code>var</code> statement.
|
||||||
*/
|
*/
|
||||||
public static class JsVar extends JsNodeImpl implements HasName {
|
public static class JsVar extends SourceInfoAwareJsNode implements HasName {
|
||||||
private final JsName name;
|
private final JsName name;
|
||||||
private JsExpression initExpression;
|
private JsExpression initExpression;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.google.dart.compiler.backend.js.ast;
|
|||||||
/**
|
/**
|
||||||
* A JavaScript <code>while</code> statement.
|
* A JavaScript <code>while</code> statement.
|
||||||
*/
|
*/
|
||||||
public class JsWhile extends JsNodeImpl implements JsStatement {
|
public class JsWhile extends SourceInfoAwareJsNode implements JsStatement {
|
||||||
protected JsStatement body;
|
protected JsStatement body;
|
||||||
protected JsExpression condition;
|
protected JsExpression condition;
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -1,11 +1,8 @@
|
|||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
abstract class JsNodeImpl extends AbstractNode {
|
abstract class SourceInfoAwareJsNode extends AbstractNode {
|
||||||
private Object sourceInfo;
|
private Object sourceInfo;
|
||||||
|
|
||||||
protected JsNodeImpl() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSourceInfo() {
|
public Object getSourceInfo() {
|
||||||
return sourceInfo;
|
return sourceInfo;
|
||||||
Reference in New Issue
Block a user