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

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

Issue 2898403002: Use failedAt in more places (Closed)
Patch Set: merge; address comments 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/apiimpl.dart ('k') | pkg/compiler/lib/src/common/resolution.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 library closureToClassMapper; 5 library closureToClassMapper;
6 6
7 import 'common/names.dart' show Identifiers; 7 import 'common/names.dart' show Identifiers;
8 import 'common/resolution.dart' show ParsingContext, Resolution; 8 import 'common/resolution.dart' show ParsingContext, Resolution;
9 import 'common/tasks.dart' show CompilerTask; 9 import 'common/tasks.dart' show CompilerTask;
10 import 'common.dart'; 10 import 'common.dart';
(...skipping 26 matching lines...) Expand all
37 37
38 /// Returns the [ClosureClassMap] computed for [resolvedAst]. 38 /// Returns the [ClosureClassMap] computed for [resolvedAst].
39 ClosureClassMap getClosureToClassMapping(ResolvedAst resolvedAst) { 39 ClosureClassMap getClosureToClassMapping(ResolvedAst resolvedAst) {
40 return measure(() { 40 return measure(() {
41 Element element = resolvedAst.element; 41 Element element = resolvedAst.element;
42 if (element.isGenerativeConstructorBody) { 42 if (element.isGenerativeConstructorBody) {
43 ConstructorBodyElement constructorBody = element; 43 ConstructorBodyElement constructorBody = element;
44 element = constructorBody.constructor; 44 element = constructorBody.constructor;
45 } 45 }
46 ClosureClassMap closureClassMap = _closureMappingCache[element]; 46 ClosureClassMap closureClassMap = _closureMappingCache[element];
47 assert(invariant(resolvedAst.element, closureClassMap != null, 47 assert(
48 message: "No ClosureClassMap computed for ${element}.")); 48 closureClassMap != null,
49 failedAt(resolvedAst.element,
50 "No ClosureClassMap computed for ${element}."));
49 return closureClassMap; 51 return closureClassMap;
50 }); 52 });
51 } 53 }
52 54
53 /// Create [ClosureClassMap]s for all live members. 55 /// Create [ClosureClassMap]s for all live members.
54 void createClosureClasses(ClosedWorldRefiner closedWorldRefiner) { 56 void createClosureClasses(ClosedWorldRefiner closedWorldRefiner) {
55 compiler.enqueuer.resolution.processedEntities 57 compiler.enqueuer.resolution.processedEntities
56 .forEach((MemberElement element) { 58 .forEach((MemberElement element) {
57 ResolvedAst resolvedAst = element.resolvedAst; 59 ResolvedAst resolvedAst = element.resolvedAst;
58 if (element.isAbstract) return; 60 if (element.isAbstract) return;
(...skipping 27 matching lines...) Expand all
86 // The translator will store the computed closure-mappings inside the 88 // The translator will store the computed closure-mappings inside the
87 // cache. One for given node and one for each nested closure. 89 // cache. One for given node and one for each nested closure.
88 if (node is FunctionExpression) { 90 if (node is FunctionExpression) {
89 translator.translateFunction(element, node); 91 translator.translateFunction(element, node);
90 } else if (element.isSynthesized) { 92 } else if (element.isSynthesized) {
91 reporter.internalError( 93 reporter.internalError(
92 element, "Unexpected synthesized element: $element"); 94 element, "Unexpected synthesized element: $element");
93 _closureMappingCache[element] = 95 _closureMappingCache[element] =
94 new ClosureClassMap(null, null, null, new ThisLocal(element)); 96 new ClosureClassMap(null, null, null, new ThisLocal(element));
95 } else { 97 } else {
96 assert(invariant(element, element.isField, 98 assert(element.isField,
97 message: "Expected $element to be a field.")); 99 failedAt(element, "Expected $element to be a field."));
98 Node initializer = resolvedAst.body; 100 Node initializer = resolvedAst.body;
99 if (initializer != null) { 101 if (initializer != null) {
100 // The lazy initializer of a static. 102 // The lazy initializer of a static.
101 translator.translateLazyInitializer(element, node, initializer); 103 translator.translateLazyInitializer(element, node, initializer);
102 } else { 104 } else {
103 assert(invariant(element, element.isInstanceMember, 105 assert(
104 message: "Expected $element (${element 106 element.isInstanceMember,
105 .runtimeType}) to be an instance field.")); 107 failedAt(
108 element,
109 "Expected $element (${element.runtimeType}) "
110 "to be an instance field."));
106 _closureMappingCache[element] = 111 _closureMappingCache[element] =
107 new ClosureClassMap(null, null, null, new ThisLocal(element)); 112 new ClosureClassMap(null, null, null, new ThisLocal(element));
108 } 113 }
109 } 114 }
110 assert(invariant(element, _closureMappingCache[element] != null, 115 assert(_closureMappingCache[element] != null,
111 message: "No ClosureClassMap computed for ${element}.")); 116 failedAt(element, "No ClosureClassMap computed for ${element}."));
112 return _closureMappingCache[element]; 117 return _closureMappingCache[element];
113 }); 118 });
114 }); 119 });
115 } 120 }
116 } 121 }
117 122
118 /// Common interface for [BoxFieldElement] and [ClosureFieldElement] as 123 /// Common interface for [BoxFieldElement] and [ClosureFieldElement] as
119 /// non-elements. 124 /// non-elements.
120 // TODO(johnniwinther): Remove `implements Element`. 125 // TODO(johnniwinther): Remove `implements Element`.
121 abstract class CapturedVariable implements Element {} 126 abstract class CapturedVariable implements Element {}
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 /// 1227 ///
1223 /// Move the below classes to a JS model eventually. 1228 /// Move the below classes to a JS model eventually.
1224 /// 1229 ///
1225 abstract class JSEntity implements Entity { 1230 abstract class JSEntity implements Entity {
1226 Entity get declaredEntity; 1231 Entity get declaredEntity;
1227 } 1232 }
1228 1233
1229 abstract class PrivatelyNamedJSEntity implements JSEntity { 1234 abstract class PrivatelyNamedJSEntity implements JSEntity {
1230 Entity get rootOfScope; 1235 Entity get rootOfScope;
1231 } 1236 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/apiimpl.dart ('k') | pkg/compiler/lib/src/common/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698