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

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

Issue 85813002: Revert "Revert "Build new IR for functions returning a constant."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: feedback by kasper 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 dart2js.ir_nodes;
8
9 import '../dart2jslib.dart' show Constant;
10
11 /**
12 * A pair of source offset and an identifier name. Identifier names are used in
13 * the Javascript backend to generate source maps.
14 */
15 class PositionWithIdentifierName {
16 final int offset;
17 final String sourceName;
18 PositionWithIdentifierName(this.offset, this.sourceName);
19 }
20
21 abstract class IrNode {
22 final /* int | PositionWithIdentifierName */ position;
23
24 const IrNode(this.position);
25
26 int get offset => (position is int) ? position : position.offset;
27
28 String get sourceName => (position is int) ? null : position.sourceName;
29
30 accept(IrNodesVisitor visitor);
31 }
32
33 class IrFunction extends IrNode {
34 final List<IrNode> statements;
35
36 final int endOffset;
37 final int namePosition;
38
39 IrFunction(position, this.endOffset, this.namePosition, this.statements)
40 : super(position);
41
42 accept(IrNodesVisitor visitor) => visitor.visitIrFunction(this);
43 }
44
45 class IrReturn extends IrNode {
46 final IrNode value;
47
48 IrReturn(position, this.value) : super(position);
49
50 accept(IrNodesVisitor visitor) => visitor.visitIrReturn(this);
51 }
52
53 class IrConstant extends IrNode {
54 final Constant value;
55
56 IrConstant(position, this.value) : super(position);
57
58 accept(IrNodesVisitor visitor) => visitor.visitIrConstant(this);
59 }
60
61
62 abstract class IrNodesVisitor<T> {
63 T visit(IrNode node) => node.accept(this);
64
65 void visitAll(List<IrNode> nodes) {
66 for (IrNode n in nodes) visit(n);
67 }
68
69 T visitNode(IrNode node);
70
71 T visitIrFunction(IrFunction node) => visitNode(node);
72 T visitIrReturn(IrReturn node) => visitNode(node);
73 T visitIrConstant(IrConstant node) => visitNode(node);
74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698