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

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

Issue 10942028: Support class and typedef literals as expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add a comment. Created 8 years, 2 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
Index: lib/compiler/implementation/ssa/builder.dart
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
index d48f76ee959121bff3828e1f9aab731273648cab..df16e1dcbfea2880390622b7c5e45927b8370ecc 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -2874,7 +2874,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
HInstruction runtimeType = createForeign(runtimeTypeString, rtiInputs);
add(runtimeType);
runtimeCodeInputs.add(runtimeType);
- runtimeCode.add('runtimeType: #');
+ runtimeCode.add("runtimeType: '#'");
}
if (needsRti) {
if (runtimeTypeIsUsed) runtimeCode.add(', ');
@@ -2952,9 +2952,23 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
return;
}
if (compiler.world.needsRti(constructor.enclosingElement)) {
- type.arguments.forEach((DartType argument) {
- inputs.add(analyzeTypeArgument(argument, node));
- });
+ if (!type.arguments.isEmpty()) {
+ type.arguments.forEach((DartType argument) {
+ inputs.add(analyzeTypeArgument(argument, node));
+ });
+ } else if (compiler.enabledRuntimeType) {
+ Link<DartType> variables =
+ constructor.getEnclosingClass().typeVariables;
+ if (!variables.isEmpty()) {
+ // If the class has type variables but no type arguments have been
+ // provided, add [:dynamic:] as argument for all type variables.
+ DartString stringDynamic = new DartString.literal('dynamic');
+ HInstruction input = graph.addConstantString(stringDynamic,
+ node,
+ constantSystem);
+ variables.forEach((_) => inputs.add(input));
+ }
+ }
}
HType elementType = computeType(constructor);
@@ -3024,6 +3038,16 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
}
+ visitTypeReferenceSend(Send node) {
+ ClassElement element = elements[node];
+ String string = rti.generateRuntimeTypeString(element, 0);
+ DartString className = new DartString.literal(string);
+ Element helper =
+ compiler.findHelper(const SourceString('getOrCreateCachedRuntimeType'));
+ Constant typeName = constantSystem.createString(className, node.selector);
+ pushInvokeHelper1(helper, graph.addConstant(typeName));
+ }
+
visitGetterSend(Send node) {
generateGetter(node, elements[node]);
}
@@ -3183,7 +3207,11 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
// [receiver] is only used if the node is an instance send.
HInstruction receiver = null;
- if (Elements.isInstanceSend(node, elements)) {
+ Element selectorElement = elements[node.selector];
+ if (!Elements.isUnresolved(selectorElement)
+ && selectorElement.kind == ElementKind.CLASS) {
+ visitTypeReferenceSend(node);
+ } else if (Elements.isInstanceSend(node, elements)) {
receiver = generateInstanceSendReceiver(node);
generateInstanceGetterWithCompiledReceiver(node, receiver);
} else {

Powered by Google App Engine
This is Rietveld 408576698