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

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

Issue 868483006: dart2js: remove additionalProperties and store it directly as nativeBlob. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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);
11 11
12 /** 12 /**
13 * Documentation wanted -- johnniwinther 13 * Documentation wanted -- johnniwinther
14 */ 14 */
15 void emitClass(Class cls, 15 void emitClass(Class cls, ClassBuilder enclosingBuilder) {
16 ClassBuilder enclosingBuilder,
17 Map<String, jsAst.Expression> additionalProperties) {
18 ClassElement classElement = cls.element; 16 ClassElement classElement = cls.element;
19 17
20 assert(invariant(classElement, classElement.isDeclaration)); 18 assert(invariant(classElement, classElement.isDeclaration));
21 19
22 emitter.needsClassSupport = true; 20 emitter.needsClassSupport = true;
23 21
24 ClassElement superclass = classElement.superclass; 22 ClassElement superclass = classElement.superclass;
25 String superName = ""; 23 String superName = "";
26 if (superclass != null) { 24 if (superclass != null) {
27 superName = namer.getNameOfClass(superclass); 25 superName = namer.getNameOfClass(superclass);
28 } 26 }
29 27
30 if (cls.isMixinApplication) { 28 if (cls.isMixinApplication) {
31 MixinApplication mixinApplication = cls; 29 MixinApplication mixinApplication = cls;
32 String mixinName = mixinApplication.mixinClass.name; 30 String mixinName = mixinApplication.mixinClass.name;
33 superName = '$superName+$mixinName'; 31 superName = '$superName+$mixinName';
34 emitter.needsMixinSupport = true; 32 emitter.needsMixinSupport = true;
35 } 33 }
36 34
37 ClassBuilder builder = new ClassBuilder(classElement, namer); 35 ClassBuilder builder = new ClassBuilder(classElement, namer);
38 builder.superName = superName; 36 builder.superName = superName;
39 emitConstructorsForCSP(cls); 37 emitConstructorsForCSP(cls);
40 emitFields(cls, builder); 38 emitFields(cls, builder);
41 emitCheckedClassSetters(cls, builder); 39 emitCheckedClassSetters(cls, builder);
42 emitClassGettersSettersForCSP(cls, builder); 40 emitClassGettersSettersForCSP(cls, builder);
43 emitInstanceMembers(cls, builder); 41 emitInstanceMembers(cls, builder);
44 emitCallStubs(cls, builder); 42 emitCallStubs(cls, builder);
45 emitRuntimeTypeInformation(cls, builder); 43 emitRuntimeTypeInformation(cls, builder);
46 if (additionalProperties != null) { 44 emitNativeBlob(cls, builder);
47 additionalProperties.forEach(builder.addProperty);
48 }
49 45
50 if (classElement == backend.closureClass) { 46 if (classElement == backend.closureClass) {
51 // We add a special getter here to allow for tearing off a closure from 47 // We add a special getter here to allow for tearing off a closure from
52 // itself. 48 // itself.
53 String name = namer.getMappedInstanceName(Compiler.CALL_OPERATOR_NAME); 49 String name = namer.getMappedInstanceName(Compiler.CALL_OPERATOR_NAME);
54 jsAst.Fun function = js('function() { return this; }'); 50 jsAst.Fun function = js('function() { return this; }');
55 builder.addProperty(namer.getterNameFromAccessorName(name), function); 51 builder.addProperty(namer.getterNameFromAccessorName(name), function);
56 } 52 }
57 53
58 emitTypeVariableReaders(classElement, builder); 54 emitTypeVariableReaders(classElement, builder);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 assert(builder.functionType == null); 260 assert(builder.functionType == null);
265 if (cls.functionTypeIndex != null) { 261 if (cls.functionTypeIndex != null) {
266 builder.functionType = '${cls.functionTypeIndex}'; 262 builder.functionType = '${cls.functionTypeIndex}';
267 } 263 }
268 264
269 for (Method method in cls.isChecks) { 265 for (Method method in cls.isChecks) {
270 builder.addProperty(method.name, method.code); 266 builder.addProperty(method.name, method.code);
271 } 267 }
272 } 268 }
273 269
270 void emitNativeBlob(Class cls, ClassBuilder builder) {
271 if (cls.nativeBlob != null) {
272 builder.addProperty(namer.nativeSpecProperty, js.string(cls.nativeBlob));
273 }
274 }
275
274 void emitClassBuilderWithReflectionData(Class cls, 276 void emitClassBuilderWithReflectionData(Class cls,
275 ClassBuilder classBuilder, 277 ClassBuilder classBuilder,
276 ClassBuilder enclosingBuilder) { 278 ClassBuilder enclosingBuilder) {
277 ClassElement classElement = cls.element; 279 ClassElement classElement = cls.element;
278 String className = cls.name; 280 String className = cls.name;
279 281
280 var metadata = emitter.metadataEmitter.buildMetadataFunction(classElement); 282 var metadata = emitter.metadataEmitter.buildMetadataFunction(classElement);
281 if (metadata != null) { 283 if (metadata != null) {
282 classBuilder.addProperty("@", metadata); 284 classBuilder.addProperty("@", metadata);
283 } 285 }
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 js.number(index)); 588 js.number(index));
587 } 589 }
588 jsAst.Expression convertRtiToRuntimeType = emitter 590 jsAst.Expression convertRtiToRuntimeType = emitter
589 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType')); 591 .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType'));
590 compiler.dumpInfoTask.registerElementAst(element, 592 compiler.dumpInfoTask.registerElementAst(element,
591 builder.addProperty(name, 593 builder.addProperty(name,
592 js('function () { return #(#) }', 594 js('function () { return #(#) }',
593 [convertRtiToRuntimeType, computeTypeVariable]))); 595 [convertRtiToRuntimeType, computeTypeVariable])));
594 } 596 }
595 } 597 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698