Chromium Code Reviews| Index: dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart |
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart b/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart |
| index 627f359c8c7ffe6efeaa29eefc51e73bb45f20ad..7c09c68d5bf196eee516d3b083576a2119cf804e 100644 |
| --- a/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart |
| +++ b/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart |
| @@ -11,6 +11,12 @@ class ClassBuilder { |
| // TODO (sigurdm) this is just a bag of properties, rename this class |
|
kasperl
2013/11/29 10:10:55
Remove this TODO now?
ahe
2013/12/06 15:57:53
Done.
|
| final List<jsAst.Property> properties = <jsAst.Property>[]; |
| + final List<String> fields = <String>[]; |
| + |
| + String superName; |
| + String nativeName; |
| + String functionType; |
| + List<jsAst.Node> fieldMetadata; |
| /// Set to true by user if class is indistinguishable from its superclass. |
| bool isTrivial = false; |
| @@ -20,8 +26,32 @@ class ClassBuilder { |
| properties.add(new jsAst.Property(js.string(name), value)); |
| } |
| - jsAst.Expression toObjectInitializer() { |
| - return new jsAst.ObjectInitializer(properties); |
| + void addField(String field) { |
| + fields.add(field); |
|
kasperl
2013/11/29 10:10:55
Should we be asserting that we aren't adding the s
ahe
2013/12/06 15:57:53
We could do that, but it does require an amount of
|
| + } |
| + |
| + jsAst.ObjectInitializer toObjectInitializer() { |
| + StringBuffer buffer = new StringBuffer(); |
| + if (superName != null) { |
| + if (nativeName != null) { |
| + buffer.write('$nativeName/'); |
| + } |
| + buffer.write('$superName'); |
| + if (functionType != null) { |
| + buffer.write(':$functionType'); |
| + } |
| + buffer.write(';'); |
| + } |
| + buffer.writeAll(fields, ','); |
| + var classData = js.string('$buffer'); |
| + if (fieldMetadata != null) { |
|
kasperl
2013/11/29 10:10:55
Maybe add a comment here that explains how metadat
ahe
2013/12/06 15:57:53
Done.
|
| + classData = |
| + new jsAst.ArrayInitializer.from([classData]..addAll(fieldMetadata)); |
| + } |
| + var fieldsAndProperties = |
| + [new jsAst.Property(js.string(''), classData)] |
| + ..addAll(properties); |
| + return new jsAst.ObjectInitializer(fieldsAndProperties); |
| } |
| } |