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 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 // works for functions and field assignments. | 916 // works for functions and field assignments. |
917 return types.nullType; | 917 return types.nullType; |
918 } | 918 } |
919 } | 919 } |
920 // Update the locals that are boxed in [locals]. These locals will | 920 // Update the locals that are boxed in [locals]. These locals will |
921 // be handled specially, in that we are computing their LUB at | 921 // be handled specially, in that we are computing their LUB at |
922 // each update, and reading them yields the type that was found in a | 922 // each update, and reading them yields the type that was found in a |
923 // previous analysis of [outermostElement]. | 923 // previous analysis of [outermostElement]. |
924 ClosureRepresentationInfo closureData = compiler | 924 ClosureRepresentationInfo closureData = compiler |
925 .backendStrategy.closureDataLookup | 925 .backendStrategy.closureDataLookup |
926 .getClosureRepresentationInfo(analyzedElement); | 926 .getClosureInfoForMember(analyzedElement); |
927 closureData.forEachCapturedVariable((variable, field) { | 927 closureData.forEachCapturedVariable((variable, field) { |
928 locals.setCaptured(variable, field); | 928 locals.setCaptured(variable, field); |
929 }); | 929 }); |
930 closureData.forEachBoxedVariable((variable, field) { | 930 closureData.forEachBoxedVariable((variable, field) { |
931 locals.setCapturedAndBoxed(variable, field); | 931 locals.setCapturedAndBoxed(variable, field); |
932 }); | 932 }); |
933 if (analyzedElement.isField) { | 933 if (analyzedElement.isField) { |
934 return visit(initializer); | 934 return visit(initializer); |
935 } | 935 } |
936 | 936 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 LocalsHandler closureLocals = | 1111 LocalsHandler closureLocals = |
1112 new LocalsHandler.from(locals, node, useOtherTryBlock: false); | 1112 new LocalsHandler.from(locals, node, useOtherTryBlock: false); |
1113 ElementGraphBuilder visitor = new ElementGraphBuilder( | 1113 ElementGraphBuilder visitor = new ElementGraphBuilder( |
1114 element.callMethod, compiler, inferrer, closureLocals); | 1114 element.callMethod, compiler, inferrer, closureLocals); |
1115 visitor.run(); | 1115 visitor.run(); |
1116 inferrer.recordReturnType(element.callMethod, visitor.returnType); | 1116 inferrer.recordReturnType(element.callMethod, visitor.returnType); |
1117 | 1117 |
1118 // Record the types of captured non-boxed variables. Types of | 1118 // Record the types of captured non-boxed variables. Types of |
1119 // these variables may already be there, because of an analysis of | 1119 // these variables may already be there, because of an analysis of |
1120 // a previous closure. | 1120 // a previous closure. |
1121 ClosureRepresentationInfo nestedClosureData = compiler | 1121 ClosureRepresentationInfo nestedClosureData = |
1122 .backendStrategy.closureDataLookup | 1122 compiler.backendStrategy.closureDataLookup.getClosureInfo(node); |
1123 .getClosureRepresentationInfo(element); | |
1124 nestedClosureData.forEachCapturedVariable((variable, field) { | 1123 nestedClosureData.forEachCapturedVariable((variable, field) { |
1125 if (!nestedClosureData.isVariableBoxed(variable)) { | 1124 if (!nestedClosureData.isVariableBoxed(variable)) { |
1126 if (variable == nestedClosureData.thisLocal) { | 1125 if (variable == nestedClosureData.thisLocal) { |
1127 inferrer.recordTypeOfField(field, thisType); | 1126 inferrer.recordTypeOfField(field, thisType); |
1128 } | 1127 } |
1129 // The type is null for type parameters. | 1128 // The type is null for type parameters. |
1130 if (locals.locals[variable] == null) return; | 1129 if (locals.locals[variable] == null) return; |
1131 inferrer.recordTypeOfField(field, locals.locals[variable]); | 1130 inferrer.recordTypeOfField(field, locals.locals[variable]); |
1132 } | 1131 } |
1133 capturedVariables.add(variable); | 1132 capturedVariables.add(variable); |
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2984 node, | 2983 node, |
2985 iteratorSelector, | 2984 iteratorSelector, |
2986 iteratorMask, | 2985 iteratorMask, |
2987 expressionType, | 2986 expressionType, |
2988 new ArgumentsTypes.empty()); | 2987 new ArgumentsTypes.empty()); |
2989 | 2988 |
2990 return handleForInLoop(node, iteratorType, currentSelector, currentMask, | 2989 return handleForInLoop(node, iteratorType, currentSelector, currentMask, |
2991 moveNextSelector, moveNextMask); | 2990 moveNextSelector, moveNextMask); |
2992 } | 2991 } |
2993 } | 2992 } |
OLD | NEW |