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

Side by Side Diff: pkg/compiler/lib/src/closure.dart

Issue 2975433002: Assert that we don't mix K and J elements (Closed)
Patch Set: Updated cf. comments Created 3 years, 5 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 | « no previous file | pkg/compiler/lib/src/compiler.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import 'common/names.dart' show Identifiers; 5 import 'common/names.dart' show Identifiers;
6 import 'common/resolution.dart' show ParsingContext, Resolution; 6 import 'common/resolution.dart' show ParsingContext, Resolution;
7 import 'common/tasks.dart' show CompilerTask, Measurer; 7 import 'common/tasks.dart' show CompilerTask, Measurer;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'compiler.dart' show Compiler; 9 import 'compiler.dart' show Compiler;
10 import 'constants/expressions.dart'; 10 import 'constants/expressions.dart';
11 import 'elements/elements.dart'; 11 import 'elements/elements.dart';
12 import 'elements/entities.dart'; 12 import 'elements/entities.dart';
13 import 'elements/entity_utils.dart' as utils; 13 import 'elements/entity_utils.dart' as utils;
14 import 'elements/modelx.dart' 14 import 'elements/modelx.dart'
15 show BaseFunctionElementX, ClassElementX, ElementX; 15 show BaseFunctionElementX, ClassElementX, ElementX;
16 import 'elements/resolution_types.dart'; 16 import 'elements/resolution_types.dart';
17 import 'elements/types.dart'; 17 import 'elements/types.dart';
18 import 'elements/visitor.dart' show ElementVisitor; 18 import 'elements/visitor.dart' show ElementVisitor;
19 import 'js_backend/js_backend.dart' show JavaScriptBackend; 19 import 'js_backend/js_backend.dart' show JavaScriptBackend;
20 import 'js_backend/runtime_types.dart';
20 import 'resolution/tree_elements.dart' show TreeElements; 21 import 'resolution/tree_elements.dart' show TreeElements;
21 import 'package:front_end/src/fasta/scanner.dart' show Token; 22 import 'package:front_end/src/fasta/scanner.dart' show Token;
22 import 'tree/tree.dart'; 23 import 'tree/tree.dart';
23 import 'util/util.dart'; 24 import 'util/util.dart';
24 import 'world.dart' show ClosedWorldRefiner; 25 import 'world.dart' show ClosedWorldRefiner;
25 26
26 // TODO(johnniwinther,efortuna): Split [ClosureConversionTask] from 27 // TODO(johnniwinther,efortuna): Split [ClosureConversionTask] from
27 // [ClosureDataLookup]. 28 // [ClosureDataLookup].
28 abstract class ClosureConversionTask<T> extends CompilerTask 29 abstract class ClosureConversionTask<T> extends CompilerTask
29 implements ClosureDataLookup<T> { 30 implements ClosureDataLookup<T> {
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 // The closureData of the currentFunctionElement. 862 // The closureData of the currentFunctionElement.
862 ClosureClassMap closureData; 863 ClosureClassMap closureData;
863 864
864 bool insideClosure = false; 865 bool insideClosure = false;
865 866
866 ClosureTranslator(this.compiler, this.closedWorldRefiner, this.elements, 867 ClosureTranslator(this.compiler, this.closedWorldRefiner, this.elements,
867 this.closureMappingCache, this.closureInfo); 868 this.closureMappingCache, this.closureInfo);
868 869
869 DiagnosticReporter get reporter => compiler.reporter; 870 DiagnosticReporter get reporter => compiler.reporter;
870 871
872 RuntimeTypesNeed get rtiNeed => closedWorldRefiner.closedWorld.rtiNeed;
873
871 /// Generate a unique name for the [id]th closure field, with proposed name 874 /// Generate a unique name for the [id]th closure field, with proposed name
872 /// [name]. 875 /// [name].
873 /// 876 ///
874 /// The result is used as the name of [ClosureFieldElement]s, and must 877 /// The result is used as the name of [ClosureFieldElement]s, and must
875 /// therefore be unique to avoid breaking an invariant in the element model 878 /// therefore be unique to avoid breaking an invariant in the element model
876 /// (classes cannot declare multiple fields with the same name). 879 /// (classes cannot declare multiple fields with the same name).
877 /// 880 ///
878 /// Also, the names should be distinct from real field names to prevent 881 /// Also, the names should be distinct from real field names to prevent
879 /// clashes with selectors for those fields. 882 /// clashes with selectors for those fields.
880 /// 883 ///
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 } else { 1197 } else {
1195 useTypeVariableAsLocal(typeVariable); 1198 useTypeVariableAsLocal(typeVariable);
1196 } 1199 }
1197 }); 1200 });
1198 } 1201 }
1199 1202
1200 void analyzeType(ResolutionDartType type) { 1203 void analyzeType(ResolutionDartType type) {
1201 // TODO(johnniwinther): Find out why this can be null. 1204 // TODO(johnniwinther): Find out why this can be null.
1202 if (type == null) return; 1205 if (type == null) return;
1203 if (outermostElement.isClassMember && 1206 if (outermostElement.isClassMember &&
1204 compiler.backend.rtiNeed 1207 rtiNeed.classNeedsRti(outermostElement.enclosingClass)) {
1205 .classNeedsRti(outermostElement.enclosingClass)) {
1206 if (outermostElement.isConstructor || outermostElement.isField) { 1208 if (outermostElement.isConstructor || outermostElement.isField) {
1207 analyzeTypeVariables(type); 1209 analyzeTypeVariables(type);
1208 } else if (outermostElement.isInstanceMember) { 1210 } else if (outermostElement.isInstanceMember) {
1209 if (type.containsTypeVariables) { 1211 if (type.containsTypeVariables) {
1210 registerNeedsThis(); 1212 registerNeedsThis();
1211 } 1213 }
1212 } 1214 }
1213 } 1215 }
1214 } 1216 }
1215 1217
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 1390
1389 insideClosure = outermostElement != null; 1391 insideClosure = outermostElement != null;
1390 LocalFunctionElement closure; 1392 LocalFunctionElement closure;
1391 executableContext = element; 1393 executableContext = element;
1392 bool needsRti = false; 1394 bool needsRti = false;
1393 if (insideClosure) { 1395 if (insideClosure) {
1394 closure = element; 1396 closure = element;
1395 closures.add(closure); 1397 closures.add(closure);
1396 closureData = globalizeClosure(node, closure); 1398 closureData = globalizeClosure(node, closure);
1397 needsRti = compiler.options.enableTypeAssertions || 1399 needsRti = compiler.options.enableTypeAssertions ||
1398 compiler.backend.rtiNeed.localFunctionNeedsRti(closure); 1400 rtiNeed.localFunctionNeedsRti(closure);
1399 } else { 1401 } else {
1400 outermostElement = element; 1402 outermostElement = element;
1401 ThisLocal thisElement = null; 1403 ThisLocal thisElement = null;
1402 if (element.isInstanceMember || element.isGenerativeConstructor) { 1404 if (element.isInstanceMember || element.isGenerativeConstructor) {
1403 MemberElement member = element; 1405 MemberElement member = element;
1404 thisElement = new ThisLocal(member); 1406 thisElement = new ThisLocal(member);
1405 } 1407 }
1406 closureData = new ClosureClassMap(null, null, null, thisElement); 1408 closureData = new ClosureClassMap(null, null, null, thisElement);
1407 if (element is MethodElement) { 1409 if (element is MethodElement) {
1408 needsRti = compiler.options.enableTypeAssertions || 1410 needsRti = compiler.options.enableTypeAssertions ||
1409 compiler.backend.rtiNeed.methodNeedsRti(element); 1411 rtiNeed.methodNeedsRti(element);
1410 } 1412 }
1411 } 1413 }
1412 closureMappingCache[element] = closureData; 1414 closureMappingCache[element] = closureData;
1413 closureMappingCache[element.declaration] = closureData; 1415 closureMappingCache[element.declaration] = closureData;
1414 if (closureData.callMethod != null) { 1416 if (closureData.callMethod != null) {
1415 closureMappingCache[closureData.callMethod] = closureData; 1417 closureMappingCache[closureData.callMethod] = closureData;
1416 } 1418 }
1417 1419
1418 inNewScope(node, () { 1420 inNewScope(node, () {
1419 // If the method needs RTI, or checked mode is set, we need to 1421 // If the method needs RTI, or checked mode is set, we need to
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 /// 1527 ///
1526 /// Move the below classes to a JS model eventually. 1528 /// Move the below classes to a JS model eventually.
1527 /// 1529 ///
1528 abstract class JSEntity implements MemberEntity { 1530 abstract class JSEntity implements MemberEntity {
1529 Local get declaredEntity; 1531 Local get declaredEntity;
1530 } 1532 }
1531 1533
1532 abstract class PrivatelyNamedJSEntity implements JSEntity { 1534 abstract class PrivatelyNamedJSEntity implements JSEntity {
1533 Entity get rootOfScope; 1535 Entity get rootOfScope;
1534 } 1536 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698