| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import '../common.dart'; | 5 import '../common.dart'; |
| 6 import '../common/names.dart'; | 6 import '../common/names.dart'; |
| 7 import '../compiler.dart'; | 7 import '../compiler.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
| 10 import '../core_types.dart'; | 10 import '../core_types.dart'; |
| 11 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
| 12 import '../js_backend/js_backend.dart'; | 12 import '../js_backend/js_backend.dart'; |
| 13 import '../native/behavior.dart' as native; | 13 import '../native/behavior.dart' as native; |
| 14 import '../resolution/tree_elements.dart'; | 14 import '../resolution/tree_elements.dart'; |
| 15 import '../tree/nodes.dart' as ast; | 15 import '../tree/nodes.dart' as ast; |
| 16 import '../types/constants.dart'; | 16 import '../types/constants.dart'; |
| 17 import '../types/types.dart'; | 17 import '../types/types.dart'; |
| 18 import '../universe/call_structure.dart'; | 18 import '../universe/call_structure.dart'; |
| 19 import '../universe/selector.dart'; | 19 import '../universe/selector.dart'; |
| 20 import '../universe/side_effects.dart'; | 20 import '../universe/side_effects.dart'; |
| 21 import '../util/util.dart'; | 21 import '../util/util.dart'; |
| 22 import '../world.dart'; | 22 import '../world.dart'; |
| 23 import 'closure_tracer.dart'; | 23 import 'closure_tracer.dart'; |
| 24 import 'debug.dart' as debug; | 24 import 'debug.dart' as debug; |
| 25 import 'inferrer_visitor.dart'; | 25 import 'locals_handler.dart'; |
| 26 import 'list_tracer.dart'; | 26 import 'list_tracer.dart'; |
| 27 import 'map_tracer.dart'; | 27 import 'map_tracer.dart'; |
| 28 import 'simple_types_inferrer.dart'; | 28 import 'builder.dart'; |
| 29 import 'type_graph_dump.dart'; | 29 import 'type_graph_dump.dart'; |
| 30 import 'type_graph_inferrer.dart'; | 30 import 'type_graph_inferrer.dart'; |
| 31 import 'type_graph_nodes.dart'; | 31 import 'type_graph_nodes.dart'; |
| 32 import 'type_system.dart'; | 32 import 'type_system.dart'; |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * An inferencing engine that computes a call graph of | 35 * An inferencing engine that computes a call graph of |
| 36 * [TypeInformation] nodes by visiting the AST of the application, and | 36 * [TypeInformation] nodes by visiting the AST of the application, and |
| 37 * then does the inferencing on the graph. | 37 * then does the inferencing on the graph. |
| 38 */ | 38 */ |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 reporter.log('Inferred $overallRefineCount types.'); | 457 reporter.log('Inferred $overallRefineCount types.'); |
| 458 | 458 |
| 459 processLoopInformation(); | 459 processLoopInformation(); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void analyze(ResolvedAst resolvedAst, ArgumentsTypes arguments) { | 462 void analyze(ResolvedAst resolvedAst, ArgumentsTypes arguments) { |
| 463 AstElement element = resolvedAst.element.implementation; | 463 AstElement element = resolvedAst.element.implementation; |
| 464 if (analyzedElements.contains(element)) return; | 464 if (analyzedElements.contains(element)) return; |
| 465 analyzedElements.add(element); | 465 analyzedElements.add(element); |
| 466 | 466 |
| 467 SimpleTypeInferrerVisitor visitor = | 467 ElementGraphBuilder visitor = |
| 468 new SimpleTypeInferrerVisitor(element, resolvedAst, compiler, this); | 468 new ElementGraphBuilder(element, resolvedAst, compiler, this); |
| 469 TypeInformation type; | 469 TypeInformation type; |
| 470 reporter.withCurrentElement(element, () { | 470 reporter.withCurrentElement(element, () { |
| 471 type = visitor.run(); | 471 type = visitor.run(); |
| 472 }); | 472 }); |
| 473 addedInGraph++; | 473 addedInGraph++; |
| 474 | 474 |
| 475 if (element.isField) { | 475 if (element.isField) { |
| 476 VariableElement fieldElement = element; | 476 VariableElement fieldElement = element; |
| 477 ast.Node node = resolvedAst.node; | 477 ast.Node node = resolvedAst.node; |
| 478 ast.Node initializer = resolvedAst.body; | 478 ast.Node initializer = resolvedAst.body; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 info.addAssignment(types.boolType); | 781 info.addAssignment(types.boolType); |
| 782 } | 782 } |
| 783 // TODO(ngeoffray): Clean up. We do these checks because | 783 // TODO(ngeoffray): Clean up. We do these checks because |
| 784 // [SimpleTypesInferrer] deals with two different inferrers. | 784 // [SimpleTypesInferrer] deals with two different inferrers. |
| 785 if (type == null) return; | 785 if (type == null) return; |
| 786 if (info.assignments.isEmpty) info.addAssignment(type); | 786 if (info.assignments.isEmpty) info.addAssignment(type); |
| 787 } | 787 } |
| 788 | 788 |
| 789 /** | 789 /** |
| 790 * Notifies to the inferrer that [analyzedElement] can have return | 790 * Notifies to the inferrer that [analyzedElement] can have return |
| 791 * type [newType]. [currentType] is the type the [InferrerVisitor] | 791 * type [newType]. [currentType] is the type the [ElementGraphBuilder] |
| 792 * currently found. | 792 * currently found. |
| 793 * | 793 * |
| 794 * Returns the new type for [analyzedElement]. | 794 * Returns the new type for [analyzedElement]. |
| 795 */ | 795 */ |
| 796 TypeInformation addReturnTypeFor( | 796 TypeInformation addReturnTypeFor( |
| 797 Element element, TypeInformation unused, TypeInformation newType) { | 797 Element element, TypeInformation unused, TypeInformation newType) { |
| 798 TypeInformation type = types.getInferredTypeOf(element); | 798 TypeInformation type = types.getInferredTypeOf(element); |
| 799 // TODO(ngeoffray): Clean up. We do this check because | 799 // TODO(ngeoffray): Clean up. We do this check because |
| 800 // [SimpleTypesInferrer] deals with two different inferrers. | 800 // [SimpleTypesInferrer] deals with two different inferrers. |
| 801 if (element.isGenerativeConstructor) return type; | 801 if (element.isGenerativeConstructor) return type; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 /** | 1042 /** |
| 1043 * Records that the captured variable [local] is read. | 1043 * Records that the captured variable [local] is read. |
| 1044 */ | 1044 */ |
| 1045 void recordCapturedLocalRead(Local local) {} | 1045 void recordCapturedLocalRead(Local local) {} |
| 1046 | 1046 |
| 1047 /** | 1047 /** |
| 1048 * Records that the variable [local] is being updated. | 1048 * Records that the variable [local] is being updated. |
| 1049 */ | 1049 */ |
| 1050 void recordLocalUpdate(Local local, TypeInformation type) {} | 1050 void recordLocalUpdate(Local local, TypeInformation type) {} |
| 1051 } | 1051 } |
| OLD | NEW |