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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart

Issue 236313012: Don't hide interceptors in mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 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 | 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 /** 7 /**
8 * A data structure for collecting fragments of a class definition. 8 * A data structure for collecting fragments of a class definition.
9 */ 9 */
10 class ClassBuilder { 10 class ClassBuilder {
11 final List<jsAst.Property> properties = <jsAst.Property>[]; 11 final List<jsAst.Property> properties = <jsAst.Property>[];
12 final List<String> fields = <String>[]; 12 final List<String> fields = <String>[];
13 13
14 String superName; 14 String superName;
15 String nativeName;
16 String functionType; 15 String functionType;
17 List<jsAst.Node> fieldMetadata; 16 List<jsAst.Node> fieldMetadata;
18 17
19 final Namer namer; 18 final Namer namer;
20 19
21 /// Set to true by user if class is indistinguishable from its superclass. 20 /// Set to true by user if class is indistinguishable from its superclass.
22 bool isTrivial = false; 21 bool isTrivial = false;
23 22
24 ClassBuilder(this.namer); 23 ClassBuilder(this.namer);
25 24
26 // Has the same signature as [DefineStubFunction]. 25 // Has the same signature as [DefineStubFunction].
27 void addProperty(String name, jsAst.Expression value) { 26 void addProperty(String name, jsAst.Expression value) {
28 properties.add(new jsAst.Property(js.string(name), value)); 27 properties.add(new jsAst.Property(js.string(name), value));
29 } 28 }
30 29
31 void addField(String field) { 30 void addField(String field) {
32 fields.add(field); 31 fields.add(field);
33 } 32 }
34 33
35 jsAst.ObjectInitializer toObjectInitializer() { 34 jsAst.ObjectInitializer toObjectInitializer() {
36 StringBuffer buffer = new StringBuffer(); 35 StringBuffer buffer = new StringBuffer();
37 if (superName != null) { 36 if (superName != null) {
38 if (nativeName != null) {
39 buffer.write('$nativeName/');
40 }
41 buffer.write('$superName'); 37 buffer.write('$superName');
42 if (functionType != null) { 38 if (functionType != null) {
43 buffer.write(':$functionType'); 39 buffer.write(':$functionType');
44 } 40 }
45 buffer.write(';'); 41 buffer.write(';');
46 } 42 }
47 buffer.writeAll(fields, ','); 43 buffer.writeAll(fields, ',');
48 var classData = js.string('$buffer'); 44 var classData = js.string('$buffer');
49 if (fieldMetadata != null) { 45 if (fieldMetadata != null) {
50 // If we need to store fieldMetadata, classData is turned into an array, 46 // If we need to store fieldMetadata, classData is turned into an array,
51 // and the field metadata is appended. So if classData is just a string, 47 // and the field metadata is appended. So if classData is just a string,
52 // there is no field metadata. 48 // there is no field metadata.
53 classData = 49 classData =
54 new jsAst.ArrayInitializer.from([classData]..addAll(fieldMetadata)); 50 new jsAst.ArrayInitializer.from([classData]..addAll(fieldMetadata));
55 } 51 }
56 var fieldsAndProperties = 52 var fieldsAndProperties =
57 [new jsAst.Property(js.string(namer.classDescriptorProperty), 53 [new jsAst.Property(js.string(namer.classDescriptorProperty),
58 classData)] 54 classData)]
59 ..addAll(properties); 55 ..addAll(properties);
60 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false); 56 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false);
61 } 57 }
62 58
63 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698