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

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

Issue 348053002: dart2dart: Support for all constants in new backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: SVN rebase + merge Created 6 years, 6 months 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart ('k') | tests/language/const_global_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 719f95647a3b18d3bafb950c6b18b928d5d25ffb..d7e61f51cc3299f5dd0fcd714ae85b8042746126 100644
--- a/sdk/lib/_internal/compiler/implementation/ir/ir_nodes.dart
+++ b/sdk/lib/_internal/compiler/implementation/ir/ir_nodes.dart
@@ -6,7 +6,7 @@
// dependencies on other parts of the system.
library dart2js.ir_nodes;
-import '../dart2jslib.dart' as dart2js show Constant;
+import '../dart2jslib.dart' as dart2js show Constant, ConstructedConstant;
import '../elements/elements.dart'
show FunctionElement, LibraryElement, ParameterElement, ClassElement,
Element, VariableElement;
@@ -61,6 +61,9 @@ abstract class Primitive extends Definition {
/// Assigned by [RegisterAllocator], is null before that phase.
int registerIndex;
+ /// If non-null, this primitive is a reference to the given constant.
+ dart2js.Constant get constant;
+
/// Use the given element as a hint for naming this primitive.
///
/// Has no effect if this primitive already has a non-null [element].
@@ -214,6 +217,8 @@ class InvokeConstConstructor extends Primitive {
final List<Reference> arguments;
final Selector selector;
+ final dart2js.ConstructedConstant constant;
+
/// The class being instantiated. This is the same as `target.enclosingClass`
/// and `type.element`.
ClassElement get targetClass => constructor.enclosingElement;
@@ -224,10 +229,12 @@ class InvokeConstConstructor extends Primitive {
InvokeConstConstructor(this.type,
this.constructor,
this.selector,
- List<Definition> args)
+ List<Definition> args,
+ this.constant)
: arguments = _referenceList(args) {
assert(constructor.isConstructor);
assert(type.element == constructor.enclosingElement);
+ assert(constant.type == type);
}
accept(Visitor visitor) => visitor.visitInvokeConstConstructor(this);
@@ -295,23 +302,35 @@ class Constant extends Primitive {
Constant(this.value);
+ dart2js.Constant get constant => value;
+
accept(Visitor visitor) => visitor.visitConstant(this);
}
class LiteralList extends Primitive {
- List<Reference> values;
+ /// The List type being created; this is not the type argument.
+ final GenericType type;
+ final List<Reference> values;
- LiteralList(List<Primitive> values)
+ /// Set to null if this is not a const literal list.
+ final dart2js.Constant constant;
+
+ LiteralList(this.type, List<Primitive> values, [this.constant])
: this.values = _referenceList(values);
accept(Visitor visitor) => visitor.visitLiteralList(this);
}
class LiteralMap extends Primitive {
- List<Reference> keys;
- List<Reference> values;
+ final GenericType type;
+ final List<Reference> keys;
+ final List<Reference> values;
- LiteralMap(List<Primitive> keys, List<Primitive> values)
+ /// Set to null if this is not a const literal map.
+ final dart2js.Constant constant;
+
+ LiteralMap(this.type, List<Primitive> keys, List<Primitive> values,
+ [this.constant])
: this.keys = _referenceList(keys),
this.values = _referenceList(values);
@@ -323,6 +342,8 @@ class Parameter extends Primitive {
super.element = element;
}
+ dart2js.Constant get constant => null;
+
accept(Visitor visitor) => visitor.visitParameter(this);
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart ('k') | tests/language/const_global_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698