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

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

Issue 24212005: Get rid of returnTypeOfElement (abstract) and typeOfElementWithSelector (concrete method assuming t… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | « no previous file | sdk/lib/_internal/compiler/implementation/types/type_graph_inferrer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart b/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
index acacbe25c19d9af2f880d5eab6e3f0b82f8d075c..27db3f3aa726735fdf3be6593b3f25440b07f8c4 100644
--- a/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
+++ b/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
@@ -357,11 +357,6 @@ abstract class InferrerEngine<T, V extends TypeSystem>
T typeOfElement(Element element);
/**
- * Returns the return type of [element].
- */
- T returnTypeOfElement(Element element);
-
- /**
* Records that [node] sets final field [element] to be of type [type].
*
* [nodeHolder] is the element holder of [node].
@@ -556,37 +551,6 @@ abstract class InferrerEngine<T, V extends TypeSystem>
return returnType;
}
- /**
- * Returns the type of [element] when being called with [selector].
- */
- T typeOfElementWithSelector(Element element, Selector selector) {
- if (element.name == Compiler.NO_SUCH_METHOD
- && selector.name != element.name) {
- // An invocation can resolve to a [noSuchMethod], in which case
- // we get the return type of [noSuchMethod].
- return returnTypeOfElement(element);
- } else if (selector.isGetter()) {
- if (element.isFunction()) {
- // [functionType] is null if the inferrer did not run.
- return types.functionType == null
- ? types.dynamicType
- : types.functionType;
- } else if (element.isField()) {
- return typeOfElement(element);
- } else if (Elements.isUnresolved(element)) {
- return types.dynamicType;
- } else {
- assert(element.isGetter());
- return returnTypeOfElement(element);
- }
- } else if (element.isGetter() || element.isField()) {
- assert(selector.isCall() || selector.isSetter());
- return types.dynamicType;
- } else {
- return returnTypeOfElement(element);
- }
- }
-
void updateSelectorInTree(Element owner, Node node, Selector selector) {
var elements = compiler.enqueuer.resolution.getCachedElements(owner);
if (node.asSendSet() != null) {
@@ -621,8 +585,54 @@ abstract class InferrerEngine<T, V extends TypeSystem>
}
}
+/**
+ * An [InferrerEngine] which provides a [typeOfElementWithSelector] method
+ * assuming the existence of a [returnTypeOfElement] method.
+ */
+abstract class SimpleInferrerEngine<T, V extends TypeSystem>
+ extends InferrerEngine<T, V> {
+
+ SimpleInferrerEngine(Compiler compiler, V types) : super(compiler, types);
+
+ /**
+ * Returns the return type of [element].
+ */
+ T returnTypeOfElement(Element element);
+
+ /**
+ * Returns the type of [element] when being called with [selector].
+ */
+ T typeOfElementWithSelector(Element element, Selector selector) {
+ if (element.name == Compiler.NO_SUCH_METHOD
+ && selector.name != element.name) {
+ // An invocation can resolve to a [noSuchMethod], in which case
+ // we get the return type of [noSuchMethod].
+ return returnTypeOfElement(element);
+ } else if (selector.isGetter()) {
+ if (element.isFunction()) {
+ // [functionType] is null if the inferrer did not run.
+ return types.functionType == null
+ ? types.dynamicType
+ : types.functionType;
+ } else if (element.isField()) {
+ return typeOfElement(element);
+ } else if (Elements.isUnresolved(element)) {
+ return types.dynamicType;
+ } else {
+ assert(element.isGetter());
+ return returnTypeOfElement(element);
+ }
+ } else if (element.isGetter() || element.isField()) {
+ assert(selector.isCall() || selector.isSetter());
+ return types.dynamicType;
+ } else {
+ return returnTypeOfElement(element);
+ }
+ }
+}
+
class InternalSimpleTypesInferrer
- extends InferrerEngine<TypeMask, TypeMaskSystem>
+ extends SimpleInferrerEngine<TypeMask, TypeMaskSystem>
implements TypesInferrer {
/**
* Maps a class to a [ClassTypeInformation] to help collect type
@@ -2183,13 +2193,17 @@ class SimpleTypeInferrerVisitor<T>
node.visitChildren(this);
Element element = elements[node];
Selector selector = elements.getSelector(node);
+ visit(node.receiver);
+ ArgumentsTypes arguments = analyzeArguments(node.arguments);
if (element != null && element.isFunction()) {
assert(Elements.isLocal(element));
// This only works for function statements. We need a
// more sophisticated type system with function types to support
// more.
inferrer.updateSideEffects(sideEffects, selector, element);
- return inferrer.returnTypeOfElement(element);
+ return inferrer.registerCalledElement(
+ node, selector, outermostElement, element, arguments, null,
+ sideEffects, inLoop);
}
sideEffects.setDependsOnSomething();
sideEffects.setAllSideEffects();
@@ -2291,15 +2305,14 @@ class SimpleTypeInferrerVisitor<T>
}
});
ArgumentsTypes arguments = new ArgumentsTypes<T>(unnamed, named);
- inferrer.registerCalledElement(node,
- null,
- outermostElement,
- element,
- arguments,
- null,
- sideEffects,
- inLoop);
- return inferrer.returnTypeOfElement(element);
+ return inferrer.registerCalledElement(node,
+ null,
+ outermostElement,
+ element,
+ arguments,
+ null,
+ sideEffects,
+ inLoop);
}
T visitReturn(Return node) {
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/types/type_graph_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698