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

Unified Diff: sdk/lib/_internal/compiler/implementation/types/types.dart

Issue 12095011: Properly register types on the JS foreign instruction. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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: sdk/lib/_internal/compiler/implementation/types/types.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/types/types.dart (revision 17700)
+++ sdk/lib/_internal/compiler/implementation/types/types.dart (working copy)
@@ -21,12 +21,21 @@
class TypesTask extends CompilerTask {
final String name = 'Type inference';
final Set<Element> untypedElements;
+ /**
+ * A map from a method to the types its parameters will get.
+ */
final Map<Element, Link<Element>> typedSends;
+
+ /**
+ * Contains the types a specific node can have.
+ */
+ final Map<Node, Link<Element>> typedNodes;
final ConcreteTypesInferrer concreteTypesInferrer;
TypesTask(Compiler compiler)
: untypedElements = new Set<Element>(),
typedSends = new Map<Element, Link<Element>>(),
+ typedNodes = new Map<Node, Link<Element>>(),
concreteTypesInferrer = compiler.enableConcreteTypeInference
? new ConcreteTypesInferrer(compiler) : null,
super(compiler);
@@ -64,14 +73,13 @@
if (guaranteedType != null) return guaranteedType;
}
Element holder = element.enclosingElement;
+ if (!holder.isFunction()) return null;
Link<Element> types = typedSends[holder];
- if (types == null) return null;
- if (!holder.isFunction()) return null;
+ if (types == null || types.isEmpty) return null;
if (untypedElements.contains(holder)) return null;
FunctionElement function = holder;
FunctionSignature signature = function.computeSignature(compiler);
for (Element parameter in signature.requiredParameters) {
- if (types.isEmpty) return null;
if (element == parameter) {
return new ConcreteType.singleton(compiler.maxConcreteTypeSize,
new ClassBaseType(types.head));
@@ -91,7 +99,10 @@
if (concreteTypesInferrer != null) {
return concreteTypesInferrer.getConcreteTypeOfNode(node);
}
- return null;
+ Link<Element> types = typedNodes[node];
+ if (types == null || types.isEmpty) return null;
+ return new UnionType(new Set.from(
+ types.mappedBy((element) => new ClassBaseType(element))));
});
}
}

Powered by Google App Engine
This is Rietveld 408576698