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