| OLD | NEW |
| 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 functionType; | 15 String functionType; |
| 16 List<jsAst.Node> fieldMetadata; | 16 List<jsAst.Node> fieldMetadata; |
| 17 | 17 |
| 18 final Element element; | 18 final Element element; |
| 19 final Namer namer; | 19 final Namer namer; |
| 20 | 20 |
| 21 ClassBuilder(this.element, this.namer); | 21 ClassBuilder(this.element, this.namer); |
| 22 | 22 |
| 23 // Has the same signature as [DefineStubFunction]. | |
| 24 jsAst.Property addProperty(String name, jsAst.Expression value) { | 23 jsAst.Property addProperty(String name, jsAst.Expression value) { |
| 25 jsAst.Property property = new jsAst.Property(js.string(name), value); | 24 jsAst.Property property = new jsAst.Property(js.string(name), value); |
| 26 properties.add(property); | 25 properties.add(property); |
| 27 return property; | 26 return property; |
| 28 } | 27 } |
| 29 | 28 |
| 30 void addField(String field) { | 29 void addField(String field) { |
| 31 fields.add(field); | 30 fields.add(field); |
| 32 } | 31 } |
| 33 | 32 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 fieldsAndProperties.add( | 66 fieldsAndProperties.add( |
| 68 new jsAst.Property( | 67 new jsAst.Property( |
| 69 js.string(namer.classDescriptorProperty), classData)); | 68 js.string(namer.classDescriptorProperty), classData)); |
| 70 fieldsAndProperties.addAll(properties); | 69 fieldsAndProperties.addAll(properties); |
| 71 } else { | 70 } else { |
| 72 fieldsAndProperties = properties; | 71 fieldsAndProperties = properties; |
| 73 } | 72 } |
| 74 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false); | 73 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false); |
| 75 } | 74 } |
| 76 } | 75 } |
| OLD | NEW |