| 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 |
| 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 /** | 7 /** |
| 8 * Represents a Dart 'for (.. in ..)' statement. | 8 * Represents a Dart 'for (.. in ..)' statement. |
| 9 */ | 9 */ |
| 10 public class DartForInStatement extends DartStatement { | 10 public class DartForInStatement extends DartStatement { |
| 11 | 11 |
| 12 private DartStatement setup; | 12 private DartStatement setup; |
| 13 private DartExpression iterable; | 13 private DartExpression iterable; |
| 14 private DartStatement body; | 14 private DartStatement body; |
| 15 | 15 |
| 16 private DartStatement normalizedNode = this; | |
| 17 | |
| 18 public DartForInStatement(DartStatement setup, | 16 public DartForInStatement(DartStatement setup, |
| 19 DartExpression iterable, | 17 DartExpression iterable, |
| 20 DartStatement body) { | 18 DartStatement body) { |
| 21 this.setup = becomeParentOf(setup); | 19 this.setup = becomeParentOf(setup); |
| 22 this.iterable = becomeParentOf(iterable); | 20 this.iterable = becomeParentOf(iterable); |
| 23 this.body = becomeParentOf(body); | 21 this.body = becomeParentOf(body); |
| 24 } | 22 } |
| 25 | 23 |
| 26 public DartStatement getBody() { | 24 public DartStatement getBody() { |
| 27 return body; | 25 return body; |
| 28 } | 26 } |
| 29 | 27 |
| 30 public DartExpression getIterable() { | 28 public DartExpression getIterable() { |
| 31 return iterable; | 29 return iterable; |
| 32 } | 30 } |
| 33 | 31 |
| 34 public void setNormalizedNode(DartStatement statement) { | |
| 35 normalizedNode = statement; | |
| 36 } | |
| 37 | |
| 38 @Override | |
| 39 public DartStatement getNormalizedNode() { | |
| 40 return normalizedNode; | |
| 41 } | |
| 42 | |
| 43 public boolean introducesVariable() { | 32 public boolean introducesVariable() { |
| 44 return setup instanceof DartVariableStatement; | 33 return setup instanceof DartVariableStatement; |
| 45 } | 34 } |
| 46 | 35 |
| 47 public DartIdentifier getIdentifier() { | 36 public DartIdentifier getIdentifier() { |
| 48 assert !introducesVariable(); | 37 assert !introducesVariable(); |
| 49 return (DartIdentifier) ((DartExprStmt) setup).getExpression(); | 38 return (DartIdentifier) ((DartExprStmt) setup).getExpression(); |
| 50 } | 39 } |
| 51 | 40 |
| 52 public DartVariableStatement getVariableStatement() { | 41 public DartVariableStatement getVariableStatement() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 69 setup.accept(visitor); | 58 setup.accept(visitor); |
| 70 iterable.accept(visitor); | 59 iterable.accept(visitor); |
| 71 body.accept(visitor); | 60 body.accept(visitor); |
| 72 } | 61 } |
| 73 | 62 |
| 74 @Override | 63 @Override |
| 75 public <R> R accept(DartPlainVisitor<R> visitor) { | 64 public <R> R accept(DartPlainVisitor<R> visitor) { |
| 76 return visitor.visitForInStatement(this); | 65 return visitor.visitForInStatement(this); |
| 77 } | 66 } |
| 78 } | 67 } |
| OLD | NEW |