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

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

Issue 171713016: Revert "Avoid use of empty string as a property name." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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; 15 String nativeName;
16 String functionType; 16 String functionType;
17 List<jsAst.Node> fieldMetadata; 17 List<jsAst.Node> fieldMetadata;
18 18
19 final Namer namer;
20
21 /// Set to true by user if class is indistinguishable from its superclass. 19 /// Set to true by user if class is indistinguishable from its superclass.
22 bool isTrivial = false; 20 bool isTrivial = false;
23 21
24 ClassBuilder(this.namer);
25
26 // Has the same signature as [DefineStubFunction]. 22 // Has the same signature as [DefineStubFunction].
27 void addProperty(String name, jsAst.Expression value) { 23 void addProperty(String name, jsAst.Expression value) {
28 properties.add(new jsAst.Property(js.string(name), value)); 24 properties.add(new jsAst.Property(js.string(name), value));
29 } 25 }
30 26
31 void addField(String field) { 27 void addField(String field) {
32 fields.add(field); 28 fields.add(field);
33 } 29 }
34 30
35 jsAst.ObjectInitializer toObjectInitializer() { 31 jsAst.ObjectInitializer toObjectInitializer() {
(...skipping 11 matching lines...) Expand all
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(''), classData)]
58 classData)]
59 ..addAll(properties); 54 ..addAll(properties);
60 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false); 55 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false);
61 } 56 }
62 57
63 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698