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

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: Fix two long lines. 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 91d2d4567f85ebd1833377a4054c31adfc32ae60..f3485c6e7b6f311765c7a985df487c8ef6f90f59 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -1320,13 +1320,11 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
// Create the runtime type information, if needed.
InterfaceType type = classElement.computeType(compiler);
- List<HInstruction> inputs = <HInstruction>[];
- if (compiler.world.needsRti(classElement)) {
ngeoffray 2012/10/10 07:32:24 I don't think you should remove this check.
karlklose 2012/10/23 10:33:52 Done.
- classElement.typeVariables.forEach((TypeVariableType typeVariable) {
- inputs.add(localsHandler.directLocals[typeVariable.element]);
- });
- callSetRuntimeTypeInfo(classElement, inputs, newObject);
- }
+ List<HInstruction> inputs = <HInstruction>[];
+ classElement.typeVariables.forEach((TypeVariableType typeVariable) {
+ inputs.add(localsHandler.directLocals[typeVariable.element]);
+ });
+ callSetRuntimeTypeInfo(classElement, inputs, newObject);
// Generate calls to the constructor bodies.
for (int index = constructors.length - 1; index >= 0; index--) {
@@ -2708,7 +2706,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
HInstruction context = localsHandler.readThis();
add(target);
var inputs = <HInstruction>[target, context];
- if (node.isPropertyAccess) {
+ if (node.isPropertyAccessOrTypeReference) {
push(new HInvokeSuper(inputs));
} else if (element.isFunction() || element.isGenerativeConstructor()) {
// TODO(5347): Try to avoid the need for calling [implementation] before
@@ -2803,7 +2801,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(', ');
@@ -2876,9 +2874,21 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
InterfaceType type = elements.getType(annotation);
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()) {
ngeoffray 2012/10/10 07:32:24 Please add a comment that you need to put runtime
karlklose 2012/10/23 10:33:52 Here I add 'dynamic' as type argument for type var
+ DartString stringDynamic = new DartString.literal('dynamic');
+ HInstruction input = graph.addConstantString(stringDynamic,
+ node,
+ constantSystem);
+ variables.forEach((_) => inputs.add(input));
+ }
+ }
}
HType elementType = computeType(constructor);
@@ -2940,6 +2950,17 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
}
+ visitClassLiteralSend(Send node) {
+ ClassElement element = elements[node];
+ String string =
+ RuntimeTypeInformation.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]);
}
@@ -3090,7 +3111,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) {
+ visitClassLiteralSend(node);
ngeoffray 2012/10/10 07:32:24 What is this about? Object = 42?
karlklose 2012/10/23 10:33:52 also for ++ and --.
+ } else if (Elements.isInstanceSend(node, elements)) {
receiver = generateInstanceSendReceiver(node);
generateInstanceGetterWithCompiledReceiver(node, receiver);
} else {

Powered by Google App Engine
This is Rietveld 408576698