Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(795)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ir/ir_nodes.dart

Issue 57873002: Build new IR for functions returning a constant (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: no nested functions in ir Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 class PositionWithIdentifierName {
ngeoffray 2013/11/21 15:02:05 Comment.
lukas 2013/11/21 17:14:27 Done.
12 final int offset;
13 final String sourceName;
14 PositionWithIdentifierName(this.offset, this.sourceName);
15 }
16
17 abstract class IrNode {
18 final /* int | PositionWithIdentifierName */ position;
19 int get offset =>
20 (position is PositionWithIdentifierName) ? position.offset : position;
21 String get sourceName =>
22 (position is PositionWithIdentifierName) ? position.sourceName : null;
ngeoffray 2013/11/21 15:02:05 Spaces between functions/getters please.
lukas 2013/11/21 17:14:27 Done.
23 const IrNode(this.position);
24 accept(IrNodesVisitor visitor);
25 }
26
27 class IrFunction extends IrNode {
28 final List<IrNode> statements;
29
30 final int endOffset;
31 final int namePosition;
32
33 IrFunction(position, this.endOffset, this.namePosition, this.statements)
34 : super(position);
35
36 accept(IrNodesVisitor visitor) => visitor.visitIrFunction(this);
37 }
38
39 class IrReturn extends IrNode {
40 final IrNode value;
41 IrReturn(position, this.value) : super(position);
42 accept(IrNodesVisitor visitor) => visitor.visitIrReturn(this);
43 }
44
45 class IrConstant extends IrNode {
46 final Constant value;
47 IrConstant(position, this.value) : super(position);
48 accept(IrNodesVisitor visitor) => visitor.visitIrConstant(this);
49 }
50
51
52 abstract class IrNodesVisitor<T> {
53 T visit(IrNode node) => node.accept(this);
54 void visitAll(List<IrNode> nodes) {
55 for (IrNode n in nodes) visit(n);
56 }
57
58 T visitNode(IrNode node);
59
60 T visitIrFunction(IrFunction node) => visitNode(node);
61 T visitIrReturn(IrReturn node) => visitNode(node);
62 T visitIrConstant(IrConstant node) => visitNode(node);
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698