| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 part of js_ast; | 5 part of js_ast; |
| 6 | 6 |
| 7 abstract class NodeVisitor<T> implements TypeRefVisitor<T> { | 7 abstract class NodeVisitor<T> implements TypeRefVisitor<T> { |
| 8 T visitProgram(Program node); | 8 T visitProgram(Program node); |
| 9 | 9 |
| 10 T visitBlock(Block node); | 10 T visitBlock(Block node); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 T visitAnyTypeRef(AnyTypeRef node) => visitTypeRef(node); | 245 T visitAnyTypeRef(AnyTypeRef node) => visitTypeRef(node); |
| 246 T visitUnknownTypeRef(UnknownTypeRef node) => visitTypeRef(node); | 246 T visitUnknownTypeRef(UnknownTypeRef node) => visitTypeRef(node); |
| 247 T visitArrayTypeRef(ArrayTypeRef node) => visitTypeRef(node); | 247 T visitArrayTypeRef(ArrayTypeRef node) => visitTypeRef(node); |
| 248 } | 248 } |
| 249 | 249 |
| 250 abstract class Node { | 250 abstract class Node { |
| 251 /// Sets the source location of this node. For performance reasons, we allow | 251 /// Sets the source location of this node. For performance reasons, we allow |
| 252 /// setting this after construction. | 252 /// setting this after construction. |
| 253 Object sourceInformation; | 253 Object sourceInformation; |
| 254 | 254 |
| 255 ClosureAnnotation _closureAnnotation; | |
| 256 | |
| 257 /// Closure annotation of this node. | 255 /// Closure annotation of this node. |
| 258 ClosureAnnotation get closureAnnotation => _closureAnnotation; | 256 ClosureAnnotation closureAnnotation; |
| 259 | 257 |
| 260 accept(NodeVisitor visitor); | 258 accept(NodeVisitor visitor); |
| 261 void visitChildren(NodeVisitor visitor); | 259 void visitChildren(NodeVisitor visitor); |
| 262 | 260 |
| 263 // Shallow clone of node. Does not clone positions since the only use of this | 261 // Shallow clone of node. Does not clone positions since the only use of this |
| 264 // private method is create a copy with a new position. | 262 // private method is create a copy with a new position. |
| 265 Node _clone(); | 263 Node _clone(); |
| 266 | 264 |
| 267 withClosureAnnotation(ClosureAnnotation closureAnnotation) { | |
| 268 if (this.closureAnnotation == closureAnnotation) return this; | |
| 269 | |
| 270 return _clone() | |
| 271 ..sourceInformation = sourceInformation | |
| 272 .._closureAnnotation = closureAnnotation; | |
| 273 } | |
| 274 | |
| 275 // Returns a node equivalent to [this], but with new source position and end | 265 // Returns a node equivalent to [this], but with new source position and end |
| 276 // source position. | 266 // source position. |
| 277 Node withSourceInformation(sourceInformation) { | 267 Node withSourceInformation(sourceInformation) { |
| 278 if (sourceInformation == this.sourceInformation) { | 268 if (sourceInformation == this.sourceInformation) { |
| 279 return this; | 269 return this; |
| 280 } | 270 } |
| 281 Node clone = _clone(); | 271 Node clone = _clone(); |
| 282 // TODO(sra): Should existing data be 'sticky' if we try to overwrite with | 272 // TODO(sra): Should existing data be 'sticky' if we try to overwrite with |
| 283 // `null`? | 273 // `null`? |
| 284 clone.sourceInformation = sourceInformation; | 274 clone.sourceInformation = sourceInformation; |
| (...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 final List<ModuleItem> body; | 1903 final List<ModuleItem> body; |
| 1914 Module(this.body, {this.name}); | 1904 Module(this.body, {this.name}); |
| 1915 | 1905 |
| 1916 accept(NodeVisitor visitor) => visitor.visitModule(this); | 1906 accept(NodeVisitor visitor) => visitor.visitModule(this); |
| 1917 void visitChildren(NodeVisitor visitor) { | 1907 void visitChildren(NodeVisitor visitor) { |
| 1918 for (ModuleItem item in body) item.accept(visitor); | 1908 for (ModuleItem item in body) item.accept(visitor); |
| 1919 } | 1909 } |
| 1920 | 1910 |
| 1921 Module _clone() => new Module(body); | 1911 Module _clone() => new Module(body); |
| 1922 } | 1912 } |
| OLD | NEW |