Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: pkg/compiler/lib/src/inferrer/builder.dart

Issue 2915523003: Create new interface instead of ClosureClassMap for variable usage information that is not Element-…
Patch Set: merge with master Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/dump_info.dart ('k') | pkg/compiler/lib/src/inferrer/builder_kernel.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/names.dart'; 16 import '../elements/names.dart';
17 import '../elements/operators.dart' as op; 17 import '../elements/operators.dart' as op;
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 if (initializer == null) { 907 if (initializer == null) {
908 // Eagerly bailout, because computing the closure data only 908 // Eagerly bailout, because computing the closure data only
909 // works for functions and field assignments. 909 // works for functions and field assignments.
910 return types.nullType; 910 return types.nullType;
911 } 911 }
912 } 912 }
913 // Update the locals that are boxed in [locals]. These locals will 913 // Update the locals that are boxed in [locals]. These locals will
914 // be handled specially, in that we are computing their LUB at 914 // be handled specially, in that we are computing their LUB at
915 // each update, and reading them yields the type that was found in a 915 // each update, and reading them yields the type that was found in a
916 // previous analysis of [outermostElement]. 916 // previous analysis of [outermostElement].
917 ClosureClassMap closureData = 917 // TODO(efortuna): elminiate getClosureToClassMapping
918 ClosureRepresentationInfo closureData =
918 compiler.closureToClassMapper.getClosureToClassMapping(analyzedElement); 919 compiler.closureToClassMapper.getClosureToClassMapping(analyzedElement);
919 closureData.forEachCapturedVariable((variable, field) { 920 closureData.forEachCapturedVariable((variable, field) {
920 locals.setCaptured(variable, field); 921 locals.setCaptured(variable, field);
921 }); 922 });
922 closureData.forEachBoxedVariable((variable, field) { 923 closureData.forEachBoxedVariable((variable, field) {
923 locals.setCapturedAndBoxed(variable, field); 924 locals.setCapturedAndBoxed(variable, field);
924 }); 925 });
925 if (analyzedElement.isField) { 926 if (analyzedElement.isField) {
926 return visit(initializer); 927 return visit(initializer);
927 } 928 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 LocalsHandler closureLocals = 1092 LocalsHandler closureLocals =
1092 new LocalsHandler.from(locals, node, useOtherTryBlock: false); 1093 new LocalsHandler.from(locals, node, useOtherTryBlock: false);
1093 ElementGraphBuilder visitor = new ElementGraphBuilder( 1094 ElementGraphBuilder visitor = new ElementGraphBuilder(
1094 element, element.resolvedAst, compiler, inferrer, closureLocals); 1095 element, element.resolvedAst, compiler, inferrer, closureLocals);
1095 visitor.run(); 1096 visitor.run();
1096 inferrer.recordReturnType(element, visitor.returnType); 1097 inferrer.recordReturnType(element, visitor.returnType);
1097 1098
1098 // Record the types of captured non-boxed variables. Types of 1099 // Record the types of captured non-boxed variables. Types of
1099 // these variables may already be there, because of an analysis of 1100 // these variables may already be there, because of an analysis of
1100 // a previous closure. 1101 // a previous closure.
1101 ClosureClassMap nestedClosureData = 1102 // TODO (efortuna): eliminate.
1103 ClosureRepresentationInfo nestedClosureData =
1102 compiler.closureToClassMapper.getClosureToClassMapping(element); 1104 compiler.closureToClassMapper.getClosureToClassMapping(element);
1103 nestedClosureData.forEachCapturedVariable((variable, field) { 1105 nestedClosureData.forEachCapturedVariable((variable, field) {
1104 if (!nestedClosureData.isVariableBoxed(variable)) { 1106 if (!nestedClosureData.isVariableBoxed(variable)) {
1105 if (variable == nestedClosureData.thisLocal) { 1107 if (variable == nestedClosureData.thisLocal) {
1106 inferrer.recordType(field, thisType); 1108 inferrer.recordType(field, thisType);
1107 } 1109 }
1108 // The type is null for type parameters. 1110 // The type is null for type parameters.
1109 if (locals.locals[variable] == null) return; 1111 if (locals.locals[variable] == null) return;
1110 inferrer.recordType(field, locals.locals[variable]); 1112 inferrer.recordType(field, locals.locals[variable]);
1111 } 1113 }
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 Selector moveNextSelector = Selectors.moveNext; 2951 Selector moveNextSelector = Selectors.moveNext;
2950 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node); 2952 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node);
2951 2953
2952 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector, 2954 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector,
2953 iteratorMask, expressionType, new ArgumentsTypes.empty()); 2955 iteratorMask, expressionType, new ArgumentsTypes.empty());
2954 2956
2955 return handleForInLoop(node, iteratorType, currentSelector, currentMask, 2957 return handleForInLoop(node, iteratorType, currentSelector, currentMask,
2956 moveNextSelector, moveNextMask); 2958 moveNextSelector, moveNextMask);
2957 } 2959 }
2958 } 2960 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dump_info.dart ('k') | pkg/compiler/lib/src/inferrer/builder_kernel.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698