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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart

Issue 2903753002: Use failedAt in more places (js_emitter) (Closed)
Patch Set: Created 3 years, 7 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 dart2js.js_emitter.program_builder; 5 library dart2js.js_emitter.program_builder;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:convert' show JSON; 8 import 'dart:convert' show JSON;
9 9
10 import '../../closure.dart' show ClosureTask, ClosureFieldElement; 10 import '../../closure.dart' show ClosureTask, ClosureFieldElement;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 collector.outputClassLists 220 collector.outputClassLists
221 .forEach((OutputUnit _, List<ClassEntity> classes) { 221 .forEach((OutputUnit _, List<ClassEntity> classes) {
222 classes.forEach(_buildClass); 222 classes.forEach(_buildClass);
223 }); 223 });
224 224
225 // Resolve the superclass references after we've processed all the classes. 225 // Resolve the superclass references after we've processed all the classes.
226 _classes.forEach((ClassEntity cls, Class c) { 226 _classes.forEach((ClassEntity cls, Class c) {
227 ClassEntity superclass = _elementEnvironment.getSuperClass(cls); 227 ClassEntity superclass = _elementEnvironment.getSuperClass(cls);
228 if (superclass != null) { 228 if (superclass != null) {
229 c.setSuperclass(_classes[superclass]); 229 c.setSuperclass(_classes[superclass]);
230 assert(invariant(cls, c.superclass != null, 230 assert(
231 message: "No Class for has been created for superclass " 231 c.superclass != null,
232 failedAt(
233 cls,
234 "No Class for has been created for superclass "
232 "${superclass} of $c.")); 235 "${superclass} of $c."));
233 } 236 }
234 if (c is MixinApplication) { 237 if (c is MixinApplication) {
235 c.setMixinClass(_classes[computeMixinClass(cls)]); 238 c.setMixinClass(_classes[computeMixinClass(cls)]);
236 assert(c.mixinClass != null); 239 assert(c.mixinClass != null);
237 } 240 }
238 }); 241 });
239 242
240 List<Class> nativeClasses = collector.nativeClassesAndSubclasses 243 List<Class> nativeClasses = collector.nativeClassesAndSubclasses
241 .map((ClassEntity classElement) => _classes[classElement]) 244 .map((ClassEntity classElement) => _classes[classElement])
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 _task, 689 _task,
687 _namer, 690 _namer,
688 _nativeData, 691 _nativeData,
689 _rtiChecks, 692 _rtiChecks,
690 _rtiEncoder, 693 _rtiEncoder,
691 _rtiNeed, 694 _rtiNeed,
692 _rtiSubstitutions, 695 _rtiSubstitutions,
693 _jsInteropAnalysis); 696 _jsInteropAnalysis);
694 697
695 void visitMember(ClassElement enclosing, MemberElement member) { 698 void visitMember(ClassElement enclosing, MemberElement member) {
696 assert(invariant(element, member.isDeclaration)); 699 assert(member.isDeclaration, failedAt(element));
697 assert(invariant(element, element == enclosing)); 700 assert(element == enclosing, failedAt(element));
698 701
699 if (Elements.isNonAbstractInstanceMember(member)) { 702 if (Elements.isNonAbstractInstanceMember(member)) {
700 // TODO(herhut): Remove once _buildMethod can no longer return null. 703 // TODO(herhut): Remove once _buildMethod can no longer return null.
701 Method method = _buildMethod(member); 704 Method method = _buildMethod(member);
702 if (method != null) methods.add(method); 705 if (method != null) methods.add(method);
703 } 706 }
704 if (member.isGetter || member.isField) { 707 if (member.isGetter || member.isField) {
705 Map<Selector, SelectorConstraints> selectors = 708 Map<Selector, SelectorConstraints> selectors =
706 _worldBuilder.invocationsByName(member.name); 709 _worldBuilder.invocationsByName(member.name);
707 if (selectors != null && !selectors.isEmpty) { 710 if (selectors != null && !selectors.isEmpty) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 // Careful with operators. 900 // Careful with operators.
898 canTearOff = _worldBuilder.hasInvokedGetter(element, _closedWorld) || 901 canTearOff = _worldBuilder.hasInvokedGetter(element, _closedWorld) ||
899 (canBeReflected && !element.isOperator); 902 (canBeReflected && !element.isOperator);
900 assert(canTearOff || 903 assert(canTearOff ||
901 !_worldBuilder.methodsNeedingSuperGetter.contains(element)); 904 !_worldBuilder.methodsNeedingSuperGetter.contains(element));
902 tearOffName = _namer.getterForElement(element); 905 tearOffName = _namer.getterForElement(element);
903 } 906 }
904 } 907 }
905 908
906 if (canTearOff) { 909 if (canTearOff) {
907 assert(invariant(element, !element.isGenerativeConstructor)); 910 assert(!element.isGenerativeConstructor, failedAt(element));
908 assert(invariant(element, !element.isGenerativeConstructorBody)); 911 assert(!element.isGenerativeConstructorBody, failedAt(element));
909 assert(invariant(element, !element.isConstructor)); 912 assert(!element.isConstructor, failedAt(element));
910 } 913 }
911 914
912 js.Name callName = null; 915 js.Name callName = null;
913 if (canTearOff) { 916 if (canTearOff) {
914 Selector callSelector = 917 Selector callSelector =
915 new Selector.fromElement(element).toCallSelector(); 918 new Selector.fromElement(element).toCallSelector();
916 callName = _namer.invocationName(callSelector); 919 callName = _namer.invocationName(callSelector);
917 } 920 }
918 921
919 ResolutionDartType memberType; 922 ResolutionDartType memberType;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 {bool visitStatics, bool isHolderInterceptedClass: false}) { 1041 {bool visitStatics, bool isHolderInterceptedClass: false}) {
1039 List<Field> fields = <Field>[]; 1042 List<Field> fields = <Field>[];
1040 new FieldVisitor(_options, _worldBuilder, _nativeData, _mirrorsData, _namer, 1043 new FieldVisitor(_options, _worldBuilder, _nativeData, _mirrorsData, _namer,
1041 _closedWorld) 1044 _closedWorld)
1042 .visitFields(holder, visitStatics, (FieldElement field, 1045 .visitFields(holder, visitStatics, (FieldElement field,
1043 js.Name name, 1046 js.Name name,
1044 js.Name accessorName, 1047 js.Name accessorName,
1045 bool needsGetter, 1048 bool needsGetter,
1046 bool needsSetter, 1049 bool needsSetter,
1047 bool needsCheckedSetter) { 1050 bool needsCheckedSetter) {
1048 assert(invariant(field, field.isDeclaration)); 1051 assert(field.isDeclaration, failedAt(field));
1049 1052
1050 int getterFlags = 0; 1053 int getterFlags = 0;
1051 if (needsGetter) { 1054 if (needsGetter) {
1052 if (visitStatics || 1055 if (visitStatics ||
1053 !_interceptorData.fieldHasInterceptedGetter(field)) { 1056 !_interceptorData.fieldHasInterceptedGetter(field)) {
1054 getterFlags = 1; 1057 getterFlags = 1;
1055 } else { 1058 } else {
1056 getterFlags += 2; 1059 getterFlags += 2;
1057 // TODO(sra): 'isInterceptedClass' might not be the correct test 1060 // TODO(sra): 'isInterceptedClass' might not be the correct test
1058 // for methods forced to use the interceptor convention because 1061 // for methods forced to use the interceptor convention because
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 Constant constant = new Constant(name, holder, constantValue); 1177 Constant constant = new Constant(name, holder, constantValue);
1175 _constants[constantValue] = constant; 1178 _constants[constantValue] = constant;
1176 } 1179 }
1177 } 1180 }
1178 1181
1179 Holder _registerStaticStateHolder() { 1182 Holder _registerStaticStateHolder() {
1180 return _registry.registerHolder(_namer.staticStateHolder, 1183 return _registry.registerHolder(_namer.staticStateHolder,
1181 isStaticStateHolder: true); 1184 isStaticStateHolder: true);
1182 } 1185 }
1183 } 1186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698