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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.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) 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 dart2js.js_emitter.full_emitter.class_emitter; 5 library dart2js.js_emitter.full_emitter.class_emitter;
6 6
7 import '../../common.dart'; 7 import '../../common.dart';
8 import '../../common/names.dart' show Names; 8 import '../../common/names.dart' show Names;
9 import '../../elements/resolution_types.dart' show ResolutionDartType; 9 import '../../elements/resolution_types.dart' show ResolutionDartType;
10 import '../../deferred_load.dart' show OutputUnit; 10 import '../../deferred_load.dart' show OutputUnit;
(...skipping 18 matching lines...) Expand all
29 ClassStubGenerator get _stubGenerator => new ClassStubGenerator(task.emitter, 29 ClassStubGenerator get _stubGenerator => new ClassStubGenerator(task.emitter,
30 compiler.commonElements, namer, codegenWorldBuilder, closedWorld, 30 compiler.commonElements, namer, codegenWorldBuilder, closedWorld,
31 enableMinification: compiler.options.enableMinification); 31 enableMinification: compiler.options.enableMinification);
32 32
33 /** 33 /**
34 * Documentation wanted -- johnniwinther 34 * Documentation wanted -- johnniwinther
35 */ 35 */
36 void emitClass(Class cls, ClassBuilder enclosingBuilder, Fragment fragment) { 36 void emitClass(Class cls, ClassBuilder enclosingBuilder, Fragment fragment) {
37 ClassElement classElement = cls.element; 37 ClassElement classElement = cls.element;
38 38
39 assert(invariant(classElement, classElement.isDeclaration)); 39 assert(classElement.isDeclaration, failedAt(classElement));
40 40
41 emitter.needsClassSupport = true; 41 emitter.needsClassSupport = true;
42 42
43 ClassElement superclass = classElement.superclass; 43 ClassElement superclass = classElement.superclass;
44 jsAst.Name superName; 44 jsAst.Name superName;
45 if (superclass != null) { 45 if (superclass != null) {
46 superName = namer.className(superclass); 46 superName = namer.className(superclass);
47 } 47 }
48 48
49 if (cls.isMixinApplication) { 49 if (cls.isMixinApplication) {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 } 252 }
253 253
254 /** 254 /**
255 * Documentation wanted -- johnniwinther 255 * Documentation wanted -- johnniwinther
256 * 256 *
257 * Invariant: [classElement] must be a declaration element. 257 * Invariant: [classElement] must be a declaration element.
258 */ 258 */
259 void emitInstanceMembers(Class cls, ClassBuilder builder) { 259 void emitInstanceMembers(Class cls, ClassBuilder builder) {
260 ClassElement classElement = cls.element; 260 ClassElement classElement = cls.element;
261 assert(invariant(classElement, classElement.isDeclaration)); 261 assert(classElement.isDeclaration, failedAt(classElement));
262 262
263 if (cls.onlyForRti || cls.isMixinApplication) return; 263 if (cls.onlyForRti || cls.isMixinApplication) return;
264 264
265 // TODO(herhut): This is a no-op. Should it be removed? 265 // TODO(herhut): This is a no-op. Should it be removed?
266 for (Field field in cls.fields) { 266 for (Field field in cls.fields) {
267 emitter.containerBuilder.addMemberField(field, builder); 267 emitter.containerBuilder.addMemberField(field, builder);
268 } 268 }
269 269
270 for (Method method in cls.methods) { 270 for (Method method in cls.methods) {
271 assert(invariant(classElement, method.element.isInstanceMember)); 271 assert(method.element.isInstanceMember, failedAt(classElement));
272 emitter.containerBuilder.addMemberMethod(method, builder); 272 emitter.containerBuilder.addMemberMethod(method, builder);
273 } 273 }
274 274
275 if (classElement.isObject && closedWorld.backendUsage.isNoSuchMethodUsed) { 275 if (classElement.isObject && closedWorld.backendUsage.isNoSuchMethodUsed) {
276 // Emit the noSuchMethod handlers on the Object prototype now, 276 // Emit the noSuchMethod handlers on the Object prototype now,
277 // so that the code in the dynamicFunction helper can find 277 // so that the code in the dynamicFunction helper can find
278 // them. Note that this helper is invoked before analyzing the 278 // them. Note that this helper is invoked before analyzing the
279 // full JS script. 279 // full JS script.
280 emitter.nsmEmitter.emitNoSuchMethodHandlers(builder.addProperty); 280 emitter.nsmEmitter.emitNoSuchMethodHandlers(builder.addProperty);
281 } 281 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 FieldElement member, jsAst.Name accessorName, String memberName) { 381 FieldElement member, jsAst.Name accessorName, String memberName) {
382 if (!backend.mirrorsData.shouldRetainGetter(member)) return; 382 if (!backend.mirrorsData.shouldRetainGetter(member)) return;
383 String previousName; 383 String previousName;
384 if (member.isInstanceMember) { 384 if (member.isInstanceMember) {
385 previousName = emitter.mangledFieldNames 385 previousName = emitter.mangledFieldNames
386 .putIfAbsent(namer.deriveGetterName(accessorName), () => memberName); 386 .putIfAbsent(namer.deriveGetterName(accessorName), () => memberName);
387 } else { 387 } else {
388 previousName = emitter.mangledGlobalFieldNames 388 previousName = emitter.mangledGlobalFieldNames
389 .putIfAbsent(accessorName, () => memberName); 389 .putIfAbsent(accessorName, () => memberName);
390 } 390 }
391 assert(invariant(member, previousName == memberName, 391 assert(previousName == memberName,
392 message: '$previousName != ${memberName}')); 392 failedAt(member, '$previousName != ${memberName}'));
393 } 393 }
394 394
395 void emitGetterForCSP(FieldElement member, jsAst.Name fieldName, 395 void emitGetterForCSP(FieldElement member, jsAst.Name fieldName,
396 jsAst.Name accessorName, ClassBuilder builder) { 396 jsAst.Name accessorName, ClassBuilder builder) {
397 jsAst.Expression function = 397 jsAst.Expression function =
398 _stubGenerator.generateGetter(member, fieldName); 398 _stubGenerator.generateGetter(member, fieldName);
399 399
400 jsAst.Name getterName = namer.deriveGetterName(accessorName); 400 jsAst.Name getterName = namer.deriveGetterName(accessorName);
401 ClassElement cls = member.enclosingClass; 401 ClassElement cls = member.enclosingClass;
402 jsAst.Name className = namer.className(cls); 402 jsAst.Name className = namer.className(cls);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 String reflectionName = emitter.getReflectionName(selector, name); 442 String reflectionName = emitter.getReflectionName(selector, name);
443 if (reflectionName != null) { 443 if (reflectionName != null) {
444 var reflectable = js( 444 var reflectable = js(
445 backend.mirrorsData.isMemberAccessibleByReflection(member) 445 backend.mirrorsData.isMemberAccessibleByReflection(member)
446 ? '1' 446 ? '1'
447 : '0'); 447 : '0');
448 builder.addPropertyByName('+$reflectionName', reflectable); 448 builder.addPropertyByName('+$reflectionName', reflectable);
449 } 449 }
450 } 450 }
451 } 451 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/code_emitter_task.dart ('k') | pkg/compiler/lib/src/js_emitter/native_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698