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

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

Issue 840563005: dart2js: Use is-checks from the model in the old emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 5 years, 11 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 | Annotate | Revision Log
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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 class ClassEmitter extends CodeEmitterHelper { 7 class ClassEmitter extends CodeEmitterHelper {
8 8
9 ClassStubGenerator get _stubGenerator => 9 ClassStubGenerator get _stubGenerator =>
10 new ClassStubGenerator(compiler, namer, backend); 10 new ClassStubGenerator(compiler, namer, backend);
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 ClassBuilder builder = new ClassBuilder(classElement, namer); 41 ClassBuilder builder = new ClassBuilder(classElement, namer);
42 builder.superName = superName; 42 builder.superName = superName;
43 emitConstructorsForCSP(classElement, onlyForRti: onlyForRti); 43 emitConstructorsForCSP(classElement, onlyForRti: onlyForRti);
44 emitFields(classElement, builder, onlyForRti: onlyForRti); 44 emitFields(classElement, builder, onlyForRti: onlyForRti);
45 emitCheckedClassSetters(classElement, builder, onlyForRti: onlyForRti); 45 emitCheckedClassSetters(classElement, builder, onlyForRti: onlyForRti);
46 emitClassGettersSettersForCSP(classElement, builder, 46 emitClassGettersSettersForCSP(classElement, builder,
47 onlyForRti: onlyForRti); 47 onlyForRti: onlyForRti);
48 emitInstanceMembers(classElement, builder, onlyForRti: onlyForRti); 48 emitInstanceMembers(classElement, builder, onlyForRti: onlyForRti);
49 emitter.typeTestEmitter.emitIsTests(classElement, builder); 49 emitRuntimeTypeInformation(cls, builder);
50 if (additionalProperties != null) { 50 if (additionalProperties != null) {
51 additionalProperties.forEach(builder.addProperty); 51 additionalProperties.forEach(builder.addProperty);
52 } 52 }
53 53
54 if (classElement == backend.closureClass) { 54 if (classElement == backend.closureClass) {
55 // We add a special getter here to allow for tearing off a closure from 55 // We add a special getter here to allow for tearing off a closure from
56 // itself. 56 // itself.
57 String name = namer.getMappedInstanceName(Compiler.CALL_OPERATOR_NAME); 57 String name = namer.getMappedInstanceName(Compiler.CALL_OPERATOR_NAME);
58 jsAst.Fun function = js('function() { return this; }'); 58 jsAst.Fun function = js('function() { return this; }');
59 builder.addProperty(namer.getterNameFromAccessorName(name), function); 59 builder.addProperty(namer.getterNameFromAccessorName(name), function);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // Emit the noSuchMethod handlers on the Object prototype now, 299 // Emit the noSuchMethod handlers on the Object prototype now,
300 // so that the code in the dynamicFunction helper can find 300 // so that the code in the dynamicFunction helper can find
301 // them. Note that this helper is invoked before analyzing the 301 // them. Note that this helper is invoked before analyzing the
302 // full JS script. 302 // full JS script.
303 if (!emitter.nativeEmitter.handleNoSuchMethod) { 303 if (!emitter.nativeEmitter.handleNoSuchMethod) {
304 emitter.nsmEmitter.emitNoSuchMethodHandlers(builder.addProperty); 304 emitter.nsmEmitter.emitNoSuchMethodHandlers(builder.addProperty);
305 } 305 }
306 } 306 }
307 } 307 }
308 308
309 /// Emits the members from the model.
310 void emitRuntimeTypeInformation(Class cls, ClassBuilder builder) {
311 assert(builder.functionType == null);
312 if (cls.functionTypeIndex != null) {
313 builder.functionType = '${cls.functionTypeIndex}';
314 }
315
316 for (Method method in cls.isChecks) {
317 builder.addProperty(method.name, method.code);
318 }
319 }
320
309 void emitClassBuilderWithReflectionData(String className, 321 void emitClassBuilderWithReflectionData(String className,
310 ClassElement classElement, 322 ClassElement classElement,
311 ClassBuilder classBuilder, 323 ClassBuilder classBuilder,
312 ClassBuilder enclosingBuilder) { 324 ClassBuilder enclosingBuilder) {
313 var metadata = emitter.metadataEmitter.buildMetadataFunction(classElement); 325 var metadata = emitter.metadataEmitter.buildMetadataFunction(classElement);
314 if (metadata != null) { 326 if (metadata != null) {
315 classBuilder.addProperty("@", metadata); 327 classBuilder.addProperty("@", metadata);
316 } 328 }
317 329
318 if (backend.isAccessibleByReflection(classElement)) { 330 if (backend.isAccessibleByReflection(classElement)) {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 js.number(index)); 631 js.number(index));
620 } 632 }
621 jsAst.Expression convertRtiToRuntimeType = emitter 633 jsAst.Expression convertRtiToRuntimeType = emitter
622 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType')); 634 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType'));
623 compiler.dumpInfoTask.registerElementAst(element, 635 compiler.dumpInfoTask.registerElementAst(element,
624 builder.addProperty(name, 636 builder.addProperty(name,
625 js('function () { return #(#) }', 637 js('function () { return #(#) }',
626 [convertRtiToRuntimeType, computeTypeVariable]))); 638 [convertRtiToRuntimeType, computeTypeVariable])));
627 } 639 }
628 } 640 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698