Chromium Code Reviews| 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..7023a00d1905e2d672b9815f4cd45e780c704fa1 |
| --- /dev/null |
| +++ b/sdk/lib/_internal/compiler/implementation/ir/ir_nodes.dart |
| @@ -0,0 +1,57 @@ |
| +// 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; |
| + |
| +abstract class IrNode { |
| + final int offset; |
| + const IrNode(this.offset); |
| + accept(IrNodesVisitor visitor); |
| +} |
| + |
| +/** |
| + * The singleton instance of this class never ends up in the final IR, it is |
| + * just used as a return value in the [IrNodeBuilderVisitor] for non-expressions |
| + * such as [:visitBlock:]. |
| + * |
| + * TODO(lry): use [:null:] instead? |
| + */ |
| +class IrNoValue extends IrNode { |
| + const IrNoValue() : super(0); |
| + accept(IrNodesVisitor visitor) => throw "NoValue.accept()"; |
| +} |
| + |
| +class IrFunction extends IrNode { |
| + // Non-final for now because the node is created early, allowing [IrReturn] |
| + // nodes in the body to refer to it. |
| + List<IrNode> statements; |
|
karlklose
2013/11/06 09:11:28
The field 'statements' can be final, you only need
lukas
2013/11/06 11:36:08
Done.
|
| + IrFunction(int offset, this.statements) : super(offset); |
| + accept(IrNodesVisitor visitor) => visitor.visitIrFunction(this); |
| + |
| + bool hasBody() => statements.isNotEmpty; |
| +} |
| + |
| +class IrReturn extends IrNode { |
| + final IrFunction function; |
|
karlklose
2013/11/06 09:11:28
If the primary way of dealing with the IR is to us
lukas
2013/11/06 11:36:08
OK, removed for now, we'll see how to encode retur
|
| + final IrNode value; |
| + IrReturn(int offset, this.function, this.value) : super(offset); |
| + accept(IrNodesVisitor visitor) => visitor.visitIrReturn(this); |
| +} |
| + |
| +class IrConstant extends IrNode { |
| + final Constant value; |
| + IrConstant(int offset, this.value) : super(offset); |
| + accept(IrNodesVisitor visitor) => visitor.visitIrConstant(this); |
| +} |
| + |
| + |
| +abstract class IrNodesVisitor<T> { |
| + T visitIrFunction(IrFunction node); |
| + T visitIrReturn(IrReturn node); |
| + T visitIrConstant(IrConstant node); |
| +} |