Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
|
Brian Wilkerson
2012/06/14 15:20:52
nit: copyright year
| |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package com.google.dart.compiler.ast; | 5 package com.google.dart.compiler.ast; |
| 6 | 6 |
| 7 import com.google.dart.compiler.parser.Token; | 7 import com.google.dart.compiler.parser.Token; |
| 8 import com.google.dart.compiler.resolver.Element; | 8 import com.google.dart.compiler.resolver.Element; |
| 9 import com.google.dart.compiler.resolver.MethodNodeElement; | 9 import com.google.dart.compiler.resolver.MethodNodeElement; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Represents a Dart binary expression. | 12 * Represents a Dart binary expression. |
| 13 */ | 13 */ |
| 14 public class DartBinaryExpression extends DartExpression { | 14 public class DartBinaryExpression extends DartExpression { |
| 15 | 15 |
| 16 private final Token op; | 16 private final Token op; |
| 17 private final int opOffset; | |
| 17 private DartExpression arg1; | 18 private DartExpression arg1; |
| 18 private DartExpression arg2; | 19 private DartExpression arg2; |
| 19 private MethodNodeElement element; | 20 private MethodNodeElement element; |
| 20 | 21 |
| 21 public DartBinaryExpression(Token op, DartExpression arg1, DartExpression arg2 ) { | 22 public DartBinaryExpression(Token op, int opOffset, DartExpression arg1, DartE xpression arg2) { |
| 23 this.opOffset = opOffset; | |
| 22 assert op.isBinaryOperator() : op; | 24 assert op.isBinaryOperator() : op; |
| 23 | 25 |
| 24 this.op = op; | 26 this.op = op; |
| 25 this.arg1 = becomeParentOf(arg1 != null ? arg1 : new DartSyntheticErrorExpre ssion()); | 27 this.arg1 = becomeParentOf(arg1 != null ? arg1 : new DartSyntheticErrorExpre ssion()); |
| 26 this.arg2 = becomeParentOf(arg2 != null ? arg2 : new DartSyntheticErrorExpre ssion()); | 28 this.arg2 = becomeParentOf(arg2 != null ? arg2 : new DartSyntheticErrorExpre ssion()); |
| 27 } | 29 } |
| 28 | 30 |
| 29 public DartExpression getArg1() { | 31 public DartExpression getArg1() { |
| 30 return arg1; | 32 return arg1; |
| 31 } | 33 } |
| 32 | 34 |
| 33 public DartExpression getArg2() { | 35 public DartExpression getArg2() { |
| 34 return arg2; | 36 return arg2; |
| 35 } | 37 } |
| 36 | 38 |
| 37 public Token getOperator() { | 39 public Token getOperator() { |
| 38 return op; | 40 return op; |
| 39 } | 41 } |
| 42 | |
| 43 /** | |
| 44 * @return the character offset of the {@link #getOperator()} token. | |
| 45 */ | |
| 46 public int getOperatorOffset() { | |
| 47 return opOffset; | |
| 48 } | |
| 40 | 49 |
| 41 @Override | 50 @Override |
| 42 public void visitChildren(ASTVisitor<?> visitor) { | 51 public void visitChildren(ASTVisitor<?> visitor) { |
| 43 arg1.accept(visitor); | 52 arg1.accept(visitor); |
| 44 arg2.accept(visitor); | 53 arg2.accept(visitor); |
| 45 } | 54 } |
| 46 | 55 |
| 47 @Override | 56 @Override |
| 48 public <R> R accept(ASTVisitor<R> visitor) { | 57 public <R> R accept(ASTVisitor<R> visitor) { |
| 49 return visitor.visitBinaryExpression(this); | 58 return visitor.visitBinaryExpression(this); |
| 50 } | 59 } |
| 51 | 60 |
| 52 @Override | 61 @Override |
| 53 public MethodNodeElement getElement() { | 62 public MethodNodeElement getElement() { |
| 54 return element; | 63 return element; |
| 55 } | 64 } |
| 56 | 65 |
| 57 @Override | 66 @Override |
| 58 public void setElement(Element element) { | 67 public void setElement(Element element) { |
| 59 this.element = (MethodNodeElement) element; | 68 this.element = (MethodNodeElement) element; |
| 60 } | 69 } |
| 61 } | 70 } |
| OLD | NEW |