OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library type_graph_inferrer; | 5 library type_graph_inferrer; |
6 | 6 |
7 import 'dart:collection' show | 7 import 'dart:collection' show |
8 IterableBase, | 8 IterableBase, |
9 Queue; | 9 Queue; |
10 | 10 |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 workQueue.addAll(info.typeInfoMap.values); | 664 workQueue.addAll(info.typeInfoMap.values); |
665 workQueue.add(info); | 665 workQueue.add(info); |
666 } | 666 } |
667 | 667 |
668 void runOverAllElements() { | 668 void runOverAllElements() { |
669 if (compiler.disableTypeInference) return; | 669 if (compiler.disableTypeInference) return; |
670 if (compiler.verbose) { | 670 if (compiler.verbose) { |
671 compiler.progress.reset(); | 671 compiler.progress.reset(); |
672 } | 672 } |
673 sortResolvedElements().forEach((Element element) { | 673 sortResolvedElements().forEach((Element element) { |
| 674 assert(compiler.enqueuer.resolution.hasBeenProcessed(element)); |
674 if (compiler.shouldPrintProgress) { | 675 if (compiler.shouldPrintProgress) { |
675 reporter.log('Added $addedInGraph elements in inferencing graph.'); | 676 reporter.log('Added $addedInGraph elements in inferencing graph.'); |
676 compiler.progress.reset(); | 677 compiler.progress.reset(); |
677 } | 678 } |
678 // This also forces the creation of the [ElementTypeInformation] to ensure | 679 // This also forces the creation of the [ElementTypeInformation] to ensure |
679 // it is in the graph. | 680 // it is in the graph. |
680 types.withMember(element, () => analyze(element, null)); | 681 types.withMember(element, () => analyze(element, null)); |
681 }); | 682 }); |
682 reporter.log('Added $addedInGraph elements in inferencing graph.'); | 683 reporter.log('Added $addedInGraph elements in inferencing graph.'); |
683 | 684 |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 allocatedCalls.add(info); | 1214 allocatedCalls.add(info); |
1214 return info; | 1215 return info; |
1215 } | 1216 } |
1216 | 1217 |
1217 // Sorts the resolved elements by size. We do this for this inferrer | 1218 // Sorts the resolved elements by size. We do this for this inferrer |
1218 // to get the same results for [ListTracer] compared to the | 1219 // to get the same results for [ListTracer] compared to the |
1219 // [SimpleTypesInferrer]. | 1220 // [SimpleTypesInferrer]. |
1220 Iterable<Element> sortResolvedElements() { | 1221 Iterable<Element> sortResolvedElements() { |
1221 int max = 0; | 1222 int max = 0; |
1222 Map<int, Setlet<Element>> methodSizes = new Map<int, Setlet<Element>>(); | 1223 Map<int, Setlet<Element>> methodSizes = new Map<int, Setlet<Element>>(); |
1223 compiler.enqueuer.resolution.resolvedElements.forEach((AstElement element) { | 1224 compiler.enqueuer.resolution.processedElements.forEach((AstElement element)
{ |
1224 // TODO(ngeoffray): Not sure why the resolver would put a null | 1225 // TODO(ngeoffray): Not sure why the resolver would put a null |
1225 // mapping. | 1226 // mapping. |
1226 if (!compiler.enqueuer.resolution.hasBeenResolved(element)) return; | 1227 if (!compiler.enqueuer.resolution.hasBeenProcessed(element)) return; |
1227 TreeElementMapping mapping = element.resolvedAst.elements; | 1228 TreeElementMapping mapping = element.resolvedAst.elements; |
1228 element = element.implementation; | 1229 element = element.implementation; |
1229 if (element.impliesType) return; | 1230 if (element.impliesType) return; |
1230 assert(invariant(element, | 1231 assert(invariant(element, |
1231 element.isField || | 1232 element.isField || |
1232 element.isFunction || | 1233 element.isFunction || |
1233 element.isGenerativeConstructor || | 1234 element.isGenerativeConstructor || |
1234 element.isGetter || | 1235 element.isGetter || |
1235 element.isSetter, | 1236 element.isSetter, |
1236 message: 'Unexpected element kind: ${element.kind}')); | 1237 message: 'Unexpected element kind: ${element.kind}')); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 bool isCalledOnce(Element element) { | 1390 bool isCalledOnce(Element element) { |
1390 if (compiler.disableTypeInference) return false; | 1391 if (compiler.disableTypeInference) return false; |
1391 MemberTypeInformation info = inferrer.types.getInferredTypeOf(element); | 1392 MemberTypeInformation info = inferrer.types.getInferredTypeOf(element); |
1392 return info.isCalledOnce(); | 1393 return info.isCalledOnce(); |
1393 } | 1394 } |
1394 | 1395 |
1395 void clear() { | 1396 void clear() { |
1396 inferrer.clear(); | 1397 inferrer.clear(); |
1397 } | 1398 } |
1398 } | 1399 } |
OLD | NEW |