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 simple_types_inferrer; | 5 library simple_types_inferrer; |
6 | 6 |
7 import '../closure.dart' show ClosureClassMap; | 7 import '../closure.dart' show ClosureRepresentationInfo; |
8 import '../common.dart'; | 8 import '../common.dart'; |
9 import '../common/names.dart' show Identifiers, Selectors; | 9 import '../common/names.dart' show Identifiers, Selectors; |
10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
11 import '../constants/constant_system.dart'; | 11 import '../constants/constant_system.dart'; |
12 import '../constants/expressions.dart'; | 12 import '../constants/expressions.dart'; |
13 import '../constants/values.dart' show ConstantValue, IntConstantValue; | 13 import '../constants/values.dart' show ConstantValue, IntConstantValue; |
14 import '../elements/elements.dart'; | 14 import '../elements/elements.dart'; |
15 import '../elements/entities.dart'; | 15 import '../elements/entities.dart'; |
16 import '../elements/jumps.dart'; | 16 import '../elements/jumps.dart'; |
17 import '../elements/names.dart'; | 17 import '../elements/names.dart'; |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 if (initializer == null) { | 908 if (initializer == null) { |
909 // Eagerly bailout, because computing the closure data only | 909 // Eagerly bailout, because computing the closure data only |
910 // works for functions and field assignments. | 910 // works for functions and field assignments. |
911 return types.nullType; | 911 return types.nullType; |
912 } | 912 } |
913 } | 913 } |
914 // Update the locals that are boxed in [locals]. These locals will | 914 // Update the locals that are boxed in [locals]. These locals will |
915 // be handled specially, in that we are computing their LUB at | 915 // be handled specially, in that we are computing their LUB at |
916 // each update, and reading them yields the type that was found in a | 916 // each update, and reading them yields the type that was found in a |
917 // previous analysis of [outermostElement]. | 917 // previous analysis of [outermostElement]. |
918 ClosureClassMap closureData = | 918 ClosureRepresentationInfo closureData = compiler.closureToClassMapper |
919 compiler.closureToClassMapper.getClosureToClassMapping(analyzedElement); | 919 .getClosureRepresentationInfo(analyzedElement); |
920 closureData.forEachCapturedVariable((variable, field) { | 920 closureData.forEachCapturedVariable((variable, field) { |
921 locals.setCaptured(variable, field); | 921 locals.setCaptured(variable, field); |
922 }); | 922 }); |
923 closureData.forEachBoxedVariable((variable, field) { | 923 closureData.forEachBoxedVariable((variable, field) { |
924 locals.setCapturedAndBoxed(variable, field); | 924 locals.setCapturedAndBoxed(variable, field); |
925 }); | 925 }); |
926 if (analyzedElement.isField) { | 926 if (analyzedElement.isField) { |
927 return visit(initializer); | 927 return visit(initializer); |
928 } | 928 } |
929 | 929 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 LocalsHandler closureLocals = | 1092 LocalsHandler closureLocals = |
1093 new LocalsHandler.from(locals, node, useOtherTryBlock: false); | 1093 new LocalsHandler.from(locals, node, useOtherTryBlock: false); |
1094 ElementGraphBuilder visitor = new ElementGraphBuilder( | 1094 ElementGraphBuilder visitor = new ElementGraphBuilder( |
1095 element, element.resolvedAst, compiler, inferrer, closureLocals); | 1095 element, element.resolvedAst, compiler, inferrer, closureLocals); |
1096 visitor.run(); | 1096 visitor.run(); |
1097 inferrer.recordReturnType(element, visitor.returnType); | 1097 inferrer.recordReturnType(element, visitor.returnType); |
1098 | 1098 |
1099 // Record the types of captured non-boxed variables. Types of | 1099 // Record the types of captured non-boxed variables. Types of |
1100 // these variables may already be there, because of an analysis of | 1100 // these variables may already be there, because of an analysis of |
1101 // a previous closure. | 1101 // a previous closure. |
1102 ClosureClassMap nestedClosureData = | 1102 ClosureRepresentationInfo nestedClosureData = |
1103 compiler.closureToClassMapper.getClosureToClassMapping(element); | 1103 compiler.closureToClassMapper.getClosureRepresentationInfo(element); |
1104 nestedClosureData.forEachCapturedVariable((variable, field) { | 1104 nestedClosureData.forEachCapturedVariable((variable, field) { |
1105 if (!nestedClosureData.isVariableBoxed(variable)) { | 1105 if (!nestedClosureData.isVariableBoxed(variable)) { |
1106 if (variable == nestedClosureData.thisLocal) { | 1106 if (variable == nestedClosureData.thisLocal) { |
1107 inferrer.recordType(field, thisType); | 1107 inferrer.recordType(field, thisType); |
1108 } | 1108 } |
1109 // The type is null for type parameters. | 1109 // The type is null for type parameters. |
1110 if (locals.locals[variable] == null) return; | 1110 if (locals.locals[variable] == null) return; |
1111 inferrer.recordType(field, locals.locals[variable]); | 1111 inferrer.recordType(field, locals.locals[variable]); |
1112 } | 1112 } |
1113 capturedVariables.add(variable); | 1113 capturedVariables.add(variable); |
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2951 Selector moveNextSelector = Selectors.moveNext; | 2951 Selector moveNextSelector = Selectors.moveNext; |
2952 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node); | 2952 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node); |
2953 | 2953 |
2954 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector, | 2954 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector, |
2955 iteratorMask, expressionType, new ArgumentsTypes.empty()); | 2955 iteratorMask, expressionType, new ArgumentsTypes.empty()); |
2956 | 2956 |
2957 return handleForInLoop(node, iteratorType, currentSelector, currentMask, | 2957 return handleForInLoop(node, iteratorType, currentSelector, currentMask, |
2958 moveNextSelector, moveNextMask); | 2958 moveNextSelector, moveNextMask); |
2959 } | 2959 } |
2960 } | 2960 } |
OLD | NEW |