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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/universe/function_set.dart

Issue 14416014: After a dynamic call, refine the receiver type by looking at the potential targets of that call. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of universe; 5 part of universe;
6 6
7 // TODO(kasperl): This actually holds getters and setters just fine 7 // TODO(kasperl): This actually holds getters and setters just fine
8 // too and stricly they aren't functions. Maybe this needs a better 8 // too and stricly they aren't functions. Maybe this needs a better
9 // name -- something like ElementSet seems a bit too generic. 9 // name -- something like ElementSet seems a bit too generic.
10 class FunctionSet { 10 class FunctionSet {
(...skipping 26 matching lines...) Expand all
37 bool contains(Element element) { 37 bool contains(Element element) {
38 assert(element.isInstanceMember()); 38 assert(element.isInstanceMember());
39 assert(!element.isAbstract(compiler)); 39 assert(!element.isAbstract(compiler));
40 SourceString name = element.name; 40 SourceString name = element.name;
41 FunctionSetNode node = nodes[name]; 41 FunctionSetNode node = nodes[name];
42 return (node != null) 42 return (node != null)
43 ? node.contains(element) 43 ? node.contains(element)
44 : false; 44 : false;
45 } 45 }
46 46
47 Iterable<ClassElement> findTargets(Selector selector) {
48 SourceString name = selector.name;
49 FunctionSetNode node = nodes[name];
50 if (node == null) return const <ClassElement>[];
51 return node.query(selector, compiler, null).classes;
52 }
53
47 /** 54 /**
48 * Returns an object that allows iterating over all the functions 55 * Returns an object that allows iterating over all the functions
49 * that may be invoked with the given [selector]. 56 * that may be invoked with the given [selector].
50 */ 57 */
51 Iterable<Element> filter(Selector selector) { 58 Iterable<Element> filter(Selector selector) {
52 SourceString name = selector.name; 59 SourceString name = selector.name;
53 FunctionSetNode node = nodes[name]; 60 FunctionSetNode node = nodes[name];
54 FunctionSetNode noSuchMethods = nodes[Compiler.NO_SUCH_METHOD]; 61 FunctionSetNode noSuchMethods = nodes[Compiler.NO_SUCH_METHOD];
55 if (node != null) { 62 if (node != null) {
56 return node.query(selector, compiler, noSuchMethods).functions; 63 return node.query(selector, compiler, noSuchMethods).functions;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (!noSuchMethodQuery.functions.isEmpty) { 179 if (!noSuchMethodQuery.functions.isEmpty) {
173 if (functions == null) { 180 if (functions == null) {
174 functions = new List<Element>.from(noSuchMethodQuery.functions); 181 functions = new List<Element>.from(noSuchMethodQuery.functions);
175 } else { 182 } else {
176 functions.addAll(noSuchMethodQuery.functions); 183 functions.addAll(noSuchMethodQuery.functions);
177 } 184 }
178 } 185 }
179 } 186 }
180 cache[selector] = result = (functions != null) 187 cache[selector] = result = (functions != null)
181 ? newQuery(functions, selector, compiler) 188 ? newQuery(functions, selector, compiler)
182 : const FunctionSetQuery(const <Element>[]); 189 : const FunctionSetQuery(const <Element>[],
190 const <ClassElement>[]);
183 return result; 191 return result;
184 } 192 }
185 193
186 FunctionSetQuery newQuery(List<Element> functions, 194 FunctionSetQuery newQuery(List<Element> functions,
187 Selector selector, 195 Selector selector,
188 Compiler compiler) { 196 Compiler compiler) {
189 return new FunctionSetQuery(functions); 197 return new FunctionSetQuery(
198 functions, <ClassElement>[compiler.objectClass]);
190 } 199 }
191 } 200 }
192 201
193 class FunctionSetQuery { 202 class FunctionSetQuery {
194 final List<Element> functions; 203 final List<Element> functions;
195 const FunctionSetQuery(this.functions); 204 final List<ClassElement> classes;
205 const FunctionSetQuery(this.functions, this.classes);
196 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698