Index: sdk/lib/_internal/compiler/implementation/ir/ir_nodes.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/ir/ir_nodes.dart b/sdk/lib/_internal/compiler/implementation/ir/ir_nodes.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3e8176874b248963974fb51136544559cce8de9e |
--- /dev/null |
+++ b/sdk/lib/_internal/compiler/implementation/ir/ir_nodes.dart |
@@ -0,0 +1,63 @@ |
+// Copyright (c) 2013, 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. |
+ |
+// IrNodes are kept in a separate library to have precise control over their |
+// dependencies on other parts of the system |
+library ir_nodes; |
+ |
+import '../dart2jslib.dart' show Constant; |
+ |
+class PositionWithIdentifierName { |
+ int offset; |
+ String sourceName; |
ngeoffray
2013/11/20 14:55:27
Make those final?
lukas
2013/11/21 12:20:21
Done.
|
+ PositionWithIdentifierName(this.offset, this.sourceName); |
+} |
+ |
+abstract class IrNode { |
+ final /* int | PositionWithIdentifierName */ position; |
+ int get offset => |
+ (position is PositionWithIdentifierName) ? position.offset : position; |
+ String get sourceName => |
+ (position is PositionWithIdentifierName) ? position.sourceName : null; |
+ const IrNode(this.position); |
+ accept(IrNodesVisitor visitor); |
+} |
+ |
+class IrFunction extends IrNode { |
+ final List<IrNode> statements; |
+ |
+ int endOffset; |
+ int namePosition; |
ngeoffray
2013/11/20 14:55:27
Make those final?
lukas
2013/11/21 12:20:21
Done.
|
+ |
+ IrFunction(position, this.endOffset, this.namePosition, this.statements) |
+ : super(position); |
+ |
+ accept(IrNodesVisitor visitor) => visitor.visitIrFunction(this); |
+} |
+ |
+class IrReturn extends IrNode { |
+ final IrNode value; |
+ IrReturn(position, this.value) : super(position); |
+ accept(IrNodesVisitor visitor) => visitor.visitIrReturn(this); |
+} |
+ |
+class IrConstant extends IrNode { |
+ final Constant value; |
+ IrConstant(position, this.value) : super(position); |
+ accept(IrNodesVisitor visitor) => visitor.visitIrConstant(this); |
+} |
+ |
+ |
+abstract class IrNodesVisitor<T> { |
+ T visit(IrNode node) => node.accept(this); |
+ void visitAll(List<IrNode> nodes) { |
+ for (IrNode n in nodes) visit(n); |
+ } |
+ |
+ T visitNode(IrNode node); |
+ |
+ T visitIrFunction(IrFunction node) => visitNode(node); |
+ T visitIrReturn(IrReturn node) => visitNode(node); |
+ T visitIrConstant(IrConstant node) => visitNode(node); |
+} |