OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013, 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 // IrNodes are kept in a separate library to have precise control over their | |
6 // dependencies on other parts of the system | |
7 library ir_nodes; | |
8 | |
9 import '../dart2jslib.dart' show Constant; | |
10 | |
11 abstract class IrNode { | |
12 final int offset; | |
13 const IrNode(this.offset); | |
14 accept(IrNodesVisitor visitor); | |
15 } | |
16 | |
17 /** | |
18 * The singleton instance of this class never ends up in the final IR, it is | |
19 * just used as a return value in the [IrNodeBuilderVisitor] for non-expressions | |
20 * such as [:visitBlock:]. | |
21 * | |
22 * TODO(lry): use [:null:] instead? | |
23 */ | |
24 class IrNoValue extends IrNode { | |
25 const IrNoValue() : super(0); | |
26 accept(IrNodesVisitor visitor) => throw "NoValue.accept()"; | |
27 } | |
28 | |
29 class IrFunction extends IrNode { | |
30 // Non-final for now because the node is created early, allowing [IrReturn] | |
31 // nodes in the body to refer to it. | |
32 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.
| |
33 IrFunction(int offset, this.statements) : super(offset); | |
34 accept(IrNodesVisitor visitor) => visitor.visitIrFunction(this); | |
35 | |
36 bool hasBody() => statements.isNotEmpty; | |
37 } | |
38 | |
39 class IrReturn extends IrNode { | |
40 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
| |
41 final IrNode value; | |
42 IrReturn(int offset, this.function, this.value) : super(offset); | |
43 accept(IrNodesVisitor visitor) => visitor.visitIrReturn(this); | |
44 } | |
45 | |
46 class IrConstant extends IrNode { | |
47 final Constant value; | |
48 IrConstant(int offset, this.value) : super(offset); | |
49 accept(IrNodesVisitor visitor) => visitor.visitIrConstant(this); | |
50 } | |
51 | |
52 | |
53 abstract class IrNodesVisitor<T> { | |
54 T visitIrFunction(IrFunction node); | |
55 T visitIrReturn(IrReturn node); | |
56 T visitIrConstant(IrConstant node); | |
57 } | |
OLD | NEW |