This commit is contained in:
develar
2012-10-26 13:39:20 +04:00
parent 633e2a142a
commit 623fb94649
15 changed files with 71 additions and 49 deletions
@@ -48,7 +48,7 @@ public class JsConstructExpressionVisitor extends RecursiveJsVisitor {
}
@Override
public void visitInvocation(JsInvocation x) {
public void visitInvocation(JsInvocation invocation) {
containsInvocation = true;
}
@@ -73,8 +73,8 @@ public class JsFirstExpressionVisitor extends RecursiveJsVisitor {
}
@Override
public void visitInvocation(JsInvocation x) {
accept(x.getQualifier());
public void visitInvocation(JsInvocation invocation) {
accept(invocation.getQualifier());
}
@Override
@@ -75,7 +75,7 @@ class JsPrecedenceVisitor extends JsVisitor {
}
@Override
public void visitInvocation(JsInvocation x) {
public void visitInvocation(JsInvocation invocation) {
answer = 16;
}
@@ -583,11 +583,11 @@ public class JsToStringGenerationVisitor extends JsVisitor {
}
@Override
public void visitInvocation(JsInvocation x) {
printPair(x, x.getQualifier());
public void visitInvocation(JsInvocation invocation) {
printPair(invocation, invocation.getQualifier());
leftParen();
printExpressions(x.getArguments());
printExpressions(invocation.getArguments());
rightParen();
}
@@ -621,9 +621,15 @@ public class JsToStringGenerationVisitor extends JsVisitor {
}
p.print('.');
}
p.maybeIndent();
beforeNodePrinted(nameRef);
p.print(nameRef.getIdent());
}
protected void beforeNodePrinted(JsNode node) {
}
@Override
public void visitNew(JsNew x) {
p.print(CHARS_NEW);
@@ -35,12 +35,17 @@ public class ChameleonJsExpression implements JsExpression {
}
@Override
public Object getSourceInfo() {
return expression.getSourceInfo();
public Object getSource() {
return expression.getSource();
}
@Override
public void setSourceInfo(Object info) {
expression.setSourceInfo(info);
public void setSource(Object info) {
expression.setSource(info);
}
@Override
public JsExpression source(Object info) {
return expression.source(info);
}
}
@@ -1,9 +1,10 @@
package com.google.dart.compiler.backend.js.ast;
import com.google.dart.compiler.common.HasSourceInfo;
public interface JsExpression extends JsNode, HasSourceInfo {
public interface JsExpression extends JsNode {
boolean isLeaf();
JsStatement makeStmt();
@Override
JsExpression source(Object info);
}
@@ -36,4 +36,10 @@ abstract class JsExpressionImpl extends SourceInfoAwareJsNode implements JsExpre
return arguments;
}
}
@Override
public JsExpression source(Object info) {
setSource(info);
return this;
}
}
@@ -26,12 +26,17 @@ public final class JsExpressionStatement extends AbstractNode implements JsState
}
@Override
public Object getSourceInfo() {
public Object getSource() {
return null;
}
@Override
public void setSourceInfo(Object info) {
public void setSource(Object info) {
throw new IllegalStateException("You must not set source info for JsExpressionStatement, set for expression");
}
@Override
public JsNode source(Object info) {
throw new IllegalStateException("You must not set source info for JsExpressionStatement, set for expression");
}
}
@@ -10,9 +10,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Represents a JavaScript invocation.
*/
public final class JsInvocation extends JsExpressionImpl.JsExpressionHasArguments {
private JsExpression qualifier;
@@ -4,16 +4,27 @@
package com.google.dart.compiler.backend.js.ast;
import com.google.dart.compiler.common.HasSourceInfo;
public interface JsNode extends HasSourceInfo {
public interface JsNode {
/**
* Causes this object to have the visitor visit itself and its children.
*
* @param visitor the visitor that should traverse this node
*
*/
void accept(JsVisitor visitor);
void acceptChildren(JsVisitor visitor);
/**
* Return the source info associated with this object.
*/
Object getSource();
/**
* Set the source info associated with this object.
*
* @param info
*/
void setSource(Object info);
JsNode source(Object info);
}
@@ -105,8 +105,8 @@ public abstract class JsVisitor {
visitElement(x);
}
public void visitInvocation(JsInvocation x) {
visitElement(x);
public void visitInvocation(JsInvocation invocation) {
visitElement(invocation);
}
public void visitLabel(JsLabel x) {
@@ -1,19 +1,25 @@
package com.google.dart.compiler.backend.js.ast;
abstract class SourceInfoAwareJsNode extends AbstractNode {
private Object sourceInfo;
private Object source;
@Override
public Object getSourceInfo() {
return sourceInfo;
public Object getSource() {
return source;
}
@Override
public void setSourceInfo(Object info) {
sourceInfo = info;
public void setSource(Object info) {
source = info;
}
@Override
public void acceptChildren(JsVisitor visitor) {
}
@Override
public JsNode source(Object info) {
source = info;
return this;
}
}
@@ -1,18 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package com.google.dart.compiler.common;
public interface HasSourceInfo {
/**
* Return the source info associated with this object.
*/
Object getSourceInfo();
/**
* Set the source info associated with this object.
* @param info
*/
void setSourceInfo(Object info);
}
@@ -42,6 +42,8 @@ public interface TextOutput {
void setOutListener(OutListener outListener);
void maybeIndent();
public interface OutListener {
void newLined();
@@ -146,7 +146,8 @@ public class TextOutputImpl implements TextOutput {
}
}
private void maybeIndent() {
@Override
public void maybeIndent() {
if (justNewlined && !compact) {
printAndCount(indents[identLevel]);
justNewlined = false;