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

Unified 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: yet another rebase Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..fce4829ba5a157ea9236f930450c8efeed91f473
--- /dev/null
+++ b/sdk/lib/_internal/compiler/implementation/ir/ir_nodes.dart
@@ -0,0 +1,76 @@
+// 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
kasperl 2013/11/25 11:32:54 Terminate comment with .
lukas 2013/11/25 14:50:52 Done.
+library ir_nodes;
+
+import '../dart2jslib.dart' show Constant;
kasperl 2013/11/25 11:32:54 It's a little bit scary to drag in the entire Cons
lukas 2013/11/25 14:50:52 Yes - I'll address this in the next CL which will
+
+/**
+ * A pair of source offset and an identifier name. Identifier names are used in
+ * the Javascript backend to generate source maps.
+ */
+class PositionWithIdentifierName {
+ final int offset;
+ final String sourceName;
+ PositionWithIdentifierName(this.offset, this.sourceName);
+}
+
+abstract class IrNode {
+ final /* int | PositionWithIdentifierName */ position;
+
+ const IrNode(this.position);
+
+ int get offset =>
+ (position is PositionWithIdentifierName) ? position.offset : position;
kasperl 2013/11/25 11:32:54 'is int' is simpler?
lukas 2013/11/25 14:50:52 Done.
+
+ String get sourceName =>
+ (position is PositionWithIdentifierName) ? position.sourceName : null;
+
+ accept(IrNodesVisitor visitor);
+}
+
+class IrFunction extends IrNode {
+ final List<IrNode> statements;
+
+ final int endOffset;
+ final int namePosition;
+
+ 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);
+}

Powered by Google App Engine
This is Rietveld 408576698