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

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

Issue 2933363003: Add ClosureRepresentationInfo, the new public face of ClosureClassMap (Closed)
Patch Set: . 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
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 ClosureRepresentationInfo closureData = compiler.closureToClassMapper
918 compiler.closureToClassMapper.getClosureToClassMapping(analyzedElement); 918 .getClosureRepresentationInfo(analyzedElement);
919 closureData.forEachCapturedVariable((variable, field) { 919 closureData.forEachCapturedVariable((variable, field) {
920 locals.setCaptured(variable, field); 920 locals.setCaptured(variable, field);
921 }); 921 });
922 closureData.forEachBoxedVariable((variable, field) { 922 closureData.forEachBoxedVariable((variable, field) {
923 locals.setCapturedAndBoxed(variable, field); 923 locals.setCapturedAndBoxed(variable, field);
924 }); 924 });
925 if (analyzedElement.isField) { 925 if (analyzedElement.isField) {
926 return visit(initializer); 926 return visit(initializer);
927 } 927 }
928 928
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 LocalsHandler closureLocals = 1091 LocalsHandler closureLocals =
1092 new LocalsHandler.from(locals, node, useOtherTryBlock: false); 1092 new LocalsHandler.from(locals, node, useOtherTryBlock: false);
1093 ElementGraphBuilder visitor = new ElementGraphBuilder( 1093 ElementGraphBuilder visitor = new ElementGraphBuilder(
1094 element, element.resolvedAst, compiler, inferrer, closureLocals); 1094 element, element.resolvedAst, compiler, inferrer, closureLocals);
1095 visitor.run(); 1095 visitor.run();
1096 inferrer.recordReturnType(element, visitor.returnType); 1096 inferrer.recordReturnType(element, visitor.returnType);
1097 1097
1098 // Record the types of captured non-boxed variables. Types of 1098 // Record the types of captured non-boxed variables. Types of
1099 // these variables may already be there, because of an analysis of 1099 // these variables may already be there, because of an analysis of
1100 // a previous closure. 1100 // a previous closure.
1101 ClosureClassMap nestedClosureData = 1101 ClosureRepresentationInfo nestedClosureData =
1102 compiler.closureToClassMapper.getClosureToClassMapping(element); 1102 compiler.closureToClassMapper.getClosureRepresentationInfo(element);
1103 nestedClosureData.forEachCapturedVariable((variable, field) { 1103 nestedClosureData.forEachCapturedVariable((variable, field) {
1104 if (!nestedClosureData.isVariableBoxed(variable)) { 1104 if (!nestedClosureData.isVariableBoxed(variable)) {
1105 if (variable == nestedClosureData.thisLocal) { 1105 if (variable == nestedClosureData.thisLocal) {
1106 inferrer.recordType(field, thisType); 1106 inferrer.recordType(field, thisType);
1107 } 1107 }
1108 // The type is null for type parameters. 1108 // The type is null for type parameters.
1109 if (locals.locals[variable] == null) return; 1109 if (locals.locals[variable] == null) return;
1110 inferrer.recordType(field, locals.locals[variable]); 1110 inferrer.recordType(field, locals.locals[variable]);
1111 } 1111 }
1112 capturedVariables.add(variable); 1112 capturedVariables.add(variable);
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 Selector moveNextSelector = Selectors.moveNext; 2949 Selector moveNextSelector = Selectors.moveNext;
2950 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node); 2950 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node);
2951 2951
2952 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector, 2952 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector,
2953 iteratorMask, expressionType, new ArgumentsTypes.empty()); 2953 iteratorMask, expressionType, new ArgumentsTypes.empty());
2954 2954
2955 return handleForInLoop(node, iteratorType, currentSelector, currentMask, 2955 return handleForInLoop(node, iteratorType, currentSelector, currentMask,
2956 moveNextSelector, moveNextMask); 2956 moveNextSelector, moveNextMask);
2957 } 2957 }
2958 } 2958 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698