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 ClosureRepresentationInfo; | 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; |
(...skipping 897 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 ClosureRepresentationInfo closureData = compiler.closureDataLookup | 918 ClosureRepresentationInfo closureData = compiler |
| 919 .backendStrategy.closureDataLookup |
919 .getClosureRepresentationInfo(analyzedElement); | 920 .getClosureRepresentationInfo(analyzedElement); |
920 closureData.forEachCapturedVariable((variable, field) { | 921 closureData.forEachCapturedVariable((variable, field) { |
921 locals.setCaptured(variable, field); | 922 locals.setCaptured(variable, field); |
922 }); | 923 }); |
923 closureData.forEachBoxedVariable((variable, field) { | 924 closureData.forEachBoxedVariable((variable, field) { |
924 locals.setCapturedAndBoxed(variable, field); | 925 locals.setCapturedAndBoxed(variable, field); |
925 }); | 926 }); |
926 if (analyzedElement.isField) { | 927 if (analyzedElement.isField) { |
927 return visit(initializer); | 928 return visit(initializer); |
928 } | 929 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 LocalsHandler closureLocals = | 1096 LocalsHandler closureLocals = |
1096 new LocalsHandler.from(locals, node, useOtherTryBlock: false); | 1097 new LocalsHandler.from(locals, node, useOtherTryBlock: false); |
1097 ElementGraphBuilder visitor = new ElementGraphBuilder( | 1098 ElementGraphBuilder visitor = new ElementGraphBuilder( |
1098 element, element.resolvedAst, compiler, inferrer, closureLocals); | 1099 element, element.resolvedAst, compiler, inferrer, closureLocals); |
1099 visitor.run(); | 1100 visitor.run(); |
1100 inferrer.recordReturnType(element, visitor.returnType); | 1101 inferrer.recordReturnType(element, visitor.returnType); |
1101 | 1102 |
1102 // Record the types of captured non-boxed variables. Types of | 1103 // Record the types of captured non-boxed variables. Types of |
1103 // these variables may already be there, because of an analysis of | 1104 // these variables may already be there, because of an analysis of |
1104 // a previous closure. | 1105 // a previous closure. |
1105 ClosureRepresentationInfo nestedClosureData = | 1106 ClosureRepresentationInfo nestedClosureData = compiler |
1106 compiler.closureDataLookup.getClosureRepresentationInfo(element); | 1107 .backendStrategy.closureDataLookup |
| 1108 .getClosureRepresentationInfo(element); |
1107 nestedClosureData.forEachCapturedVariable((variable, field) { | 1109 nestedClosureData.forEachCapturedVariable((variable, field) { |
1108 if (!nestedClosureData.isVariableBoxed(variable)) { | 1110 if (!nestedClosureData.isVariableBoxed(variable)) { |
1109 if (variable == nestedClosureData.thisLocal) { | 1111 if (variable == nestedClosureData.thisLocal) { |
1110 inferrer.recordType(field, thisType); | 1112 inferrer.recordType(field, thisType); |
1111 } | 1113 } |
1112 // The type is null for type parameters. | 1114 // The type is null for type parameters. |
1113 if (locals.locals[variable] == null) return; | 1115 if (locals.locals[variable] == null) return; |
1114 inferrer.recordType(field, locals.locals[variable]); | 1116 inferrer.recordType(field, locals.locals[variable]); |
1115 } | 1117 } |
1116 capturedVariables.add(variable); | 1118 capturedVariables.add(variable); |
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2957 Selector moveNextSelector = Selectors.moveNext; | 2959 Selector moveNextSelector = Selectors.moveNext; |
2958 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node); | 2960 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node); |
2959 | 2961 |
2960 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector, | 2962 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector, |
2961 iteratorMask, expressionType, new ArgumentsTypes.empty()); | 2963 iteratorMask, expressionType, new ArgumentsTypes.empty()); |
2962 | 2964 |
2963 return handleForInLoop(node, iteratorType, currentSelector, currentMask, | 2965 return handleForInLoop(node, iteratorType, currentSelector, currentMask, |
2964 moveNextSelector, moveNextMask); | 2966 moveNextSelector, moveNextMask); |
2965 } | 2967 } |
2966 } | 2968 } |
OLD | NEW |