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

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

Issue 2310573002: dart2js: Pass type information to constructor rather than add later. (Closed)
Patch Set: Filter out type info pseudofield when parsing fieldspec for mirrors Created 4 years, 3 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 part of dart2js.js_emitter.full_emitter; 5 part of dart2js.js_emitter.full_emitter;
6 6
7 class ClassEmitter extends CodeEmitterHelper { 7 class ClassEmitter extends CodeEmitterHelper {
8 ClassStubGenerator get _stubGenerator => 8 ClassStubGenerator get _stubGenerator =>
9 new ClassStubGenerator(compiler, namer, backend); 9 new ClassStubGenerator(compiler, namer, backend);
10 10
(...skipping 17 matching lines...) Expand all
28 MixinApplication mixinApplication = cls; 28 MixinApplication mixinApplication = cls;
29 jsAst.Name mixinName = mixinApplication.mixinClass.name; 29 jsAst.Name mixinName = mixinApplication.mixinClass.name;
30 superName = new CompoundName([superName, Namer.literalPlus, mixinName]); 30 superName = new CompoundName([superName, Namer.literalPlus, mixinName]);
31 emitter.needsMixinSupport = true; 31 emitter.needsMixinSupport = true;
32 } 32 }
33 33
34 ClassBuilder builder = new ClassBuilder.forClass(classElement, namer); 34 ClassBuilder builder = new ClassBuilder.forClass(classElement, namer);
35 builder.superName = superName; 35 builder.superName = superName;
36 emitConstructorsForCSP(cls); 36 emitConstructorsForCSP(cls);
37 emitFields(cls, builder); 37 emitFields(cls, builder);
38 if (cls.hasRtiField) {
39 builder.addField(namer.rtiFieldName);
40 }
38 emitCheckedClassSetters(cls, builder); 41 emitCheckedClassSetters(cls, builder);
39 emitClassGettersSettersForCSP(cls, builder); 42 emitClassGettersSettersForCSP(cls, builder);
40 emitInstanceMembers(cls, builder); 43 emitInstanceMembers(cls, builder);
41 emitStubs(cls.callStubs, builder); 44 emitStubs(cls.callStubs, builder);
42 emitStubs(cls.typeVariableReaderStubs, builder); 45 emitStubs(cls.typeVariableReaderStubs, builder);
43 emitRuntimeTypeInformation(cls, builder); 46 emitRuntimeTypeInformation(cls, builder);
44 emitNativeInfo(cls, builder); 47 emitNativeInfo(cls, builder);
45 48
46 if (classElement == backend.helpers.closureClass) { 49 if (classElement == backend.helpers.closureClass) {
47 // We add a special getter here to allow for tearing off a closure from 50 // We add a special getter here to allow for tearing off a closure from
(...skipping 14 matching lines...) Expand all
62 List<jsAst.Name> fieldNames = <jsAst.Name>[]; 65 List<jsAst.Name> fieldNames = <jsAst.Name>[];
63 66
64 if (!compiler.options.useContentSecurityPolicy) return; 67 if (!compiler.options.useContentSecurityPolicy) return;
65 68
66 if (!cls.onlyForRti && !cls.isNative) { 69 if (!cls.onlyForRti && !cls.isNative) {
67 fieldNames = cls.fields.map((Field field) => field.name).toList(); 70 fieldNames = cls.fields.map((Field field) => field.name).toList();
68 } 71 }
69 72
70 ClassElement classElement = cls.element; 73 ClassElement classElement = cls.element;
71 74
72 jsAst.Expression constructorAst = 75 jsAst.Expression constructorAst = _stubGenerator.generateClassConstructor(
73 _stubGenerator.generateClassConstructor(classElement, fieldNames); 76 classElement, fieldNames, cls.hasRtiField);
74 77
75 jsAst.Name constructorName = namer.className(classElement); 78 jsAst.Name constructorName = namer.className(classElement);
76 OutputUnit outputUnit = 79 OutputUnit outputUnit =
77 compiler.deferredLoadTask.outputUnitForElement(classElement); 80 compiler.deferredLoadTask.outputUnitForElement(classElement);
78 emitter.assemblePrecompiledConstructor( 81 emitter.assemblePrecompiledConstructor(
79 outputUnit, constructorName, constructorAst, fieldNames); 82 outputUnit, constructorName, constructorAst, fieldNames);
80 } 83 }
81 84
82 /// Returns `true` if fields added. 85 /// Returns `true` if fields added.
83 bool emitFields(FieldContainer container, ClassBuilder builder, 86 bool emitFields(FieldContainer container, ClassBuilder builder,
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 : new Selector.setter( 417 : new Selector.setter(
415 new Name(member.name, member.library, isSetter: true)); 418 new Name(member.name, member.library, isSetter: true));
416 String reflectionName = emitter.getReflectionName(selector, name); 419 String reflectionName = emitter.getReflectionName(selector, name);
417 if (reflectionName != null) { 420 if (reflectionName != null) {
418 var reflectable = 421 var reflectable =
419 js(backend.isAccessibleByReflection(member) ? '1' : '0'); 422 js(backend.isAccessibleByReflection(member) ? '1' : '0');
420 builder.addPropertyByName('+$reflectionName', reflectable); 423 builder.addPropertyByName('+$reflectionName', reflectable);
421 } 424 }
422 } 425 }
423 } 426 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698