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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 11299009: Support type literals as compile-time constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index f47e5dac0a6b69579515f4db3b9ffccfc7e1b6a0..5cb4116d1479d589d1e338cd6027b52b7e3eb79a 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -3026,7 +3026,13 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
InterfaceType interfaceType = type;
bool hasTypeArguments = !interfaceType.arguments.isEmpty;
if (!isInQuotes) template.add("'");
- template.add(rti.getName(type.element));
+ if (type.element == compiler.dynamicClass) {
ngeoffray 2012/11/15 16:07:24 This looks fishy, why can't rti.getName return 'dy
karlklose 2012/11/19 15:08:58 Done.
+ // We represent the dynamic type by a class, which has a different
+ // name.
+ template.add('dynamic');
+ } else {
+ template.add(rti.getName(type.element));
+ }
if (hasTypeArguments) {
template.add("<");
for (DartType argument in interfaceType.arguments) {
@@ -3260,22 +3266,17 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
visitTypeReferenceSend(Send node) {
Element element = elements[node];
- HInstruction name;
- Element helper =
- compiler.findHelper(const SourceString('createRuntimeType'));
- if (element.isClass()) {
- String string = rti.generateRuntimeTypeString(element, 0);
- name = addConstantString(node.selector, string);
- } else if (element.isTypedef()) {
- // TODO(karlklose): implement support for type variables in typedefs.
- name = addConstantString(node.selector, rti.getName(element));
+ if (element.isClass() || element.isTypedef()) {
+ // TODO(karlklose): add type representation
+ ConstantHandler handler = compiler.constantHandler;
+ Constant constant = handler.compileNodeWithDefinitions(node, elements);
+ stack.add(graph.addConstant(constant));
} else if (element.isTypeVariable()) {
// TODO(6248): implement support for type variables.
compiler.unimplemented('first class type for type variable', node: node);
} else {
- internalError('unexpected element $element', node: node);
+ internalError('unexpected element kind $element', node: node);
}
- pushInvokeHelper1(helper, name);
if (node.isCall) {
// This send is of the form 'e(...)', where e is resolved to a type
// reference. We create a regular closure call on the result of the type

Powered by Google App Engine
This is Rietveld 408576698