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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/full_emitter/class_builder.dart

Issue 2908153003: It's alive! (Closed)
Patch Set: Updated cf. comments Created 3 years, 6 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
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 library dart2js.js_emitter.full_emitter.class_builder; 5 library dart2js.js_emitter.full_emitter.class_builder;
6 6
7 import '../../elements/entities.dart'; 7 import '../../elements/entities.dart';
8 import '../../js/js.dart' as jsAst; 8 import '../../js/js.dart' as jsAst;
9 import '../../js/js.dart' show js; 9 import '../../js/js.dart' show js;
10 import '../../js_backend/js_backend.dart' show Namer; 10 import '../../js_backend/js_backend.dart' show Namer;
11 11
12 /** 12 /**
13 * A data structure for collecting fragments of a class definition. 13 * A data structure for collecting fragments of a class definition.
14 */ 14 */
15 class ClassBuilder { 15 class ClassBuilder {
16 final List<jsAst.Property> properties = <jsAst.Property>[]; 16 final List<jsAst.Property> properties = <jsAst.Property>[];
17 final List<jsAst.Literal> fields = <jsAst.Literal>[]; 17 final List<jsAst.Literal> fields = <jsAst.Literal>[];
18 18
19 jsAst.Name superName; 19 jsAst.Name superName;
20 jsAst.Node functionType; 20 jsAst.Node functionType;
21 List<jsAst.Node> fieldMetadata; 21 List<jsAst.Node> fieldMetadata;
22 22
23 final Entity element; 23 final Entity element;
24 final Namer namer; 24 final Namer namer;
25 final bool isForActualClass; 25 final bool isForActualClass;
26 26
27 ClassBuilder(this.element, this.namer, this.isForActualClass); 27 ClassBuilder.forLibrary(LibraryEntity library, this.namer)
28 : isForActualClass = false,
29 element = library;
28 30
29 ClassBuilder.forClass(ClassEntity cls, this.namer) 31 ClassBuilder.forClass(ClassEntity cls, this.namer)
30 : isForActualClass = true, 32 : isForActualClass = true,
31 element = cls; 33 element = cls;
32 34
33 ClassBuilder.forStatics(this.element, this.namer) : isForActualClass = false; 35 ClassBuilder.forStatics(this.element, this.namer) : isForActualClass = false;
34 36
35 jsAst.Property addProperty(jsAst.Literal name, jsAst.Expression value) { 37 jsAst.Property addProperty(jsAst.Literal name, jsAst.Expression value) {
36 jsAst.Property property = new jsAst.Property(js.quoteName(name), value); 38 jsAst.Property property = new jsAst.Property(js.quoteName(name), value);
37 properties.add(property); 39 properties.add(property);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 fieldsAndProperties = <jsAst.Property>[]; 88 fieldsAndProperties = <jsAst.Property>[];
87 fieldsAndProperties.add(new jsAst.Property( 89 fieldsAndProperties.add(new jsAst.Property(
88 js.string(namer.classDescriptorProperty), classData)); 90 js.string(namer.classDescriptorProperty), classData));
89 fieldsAndProperties.addAll(properties); 91 fieldsAndProperties.addAll(properties);
90 } else { 92 } else {
91 fieldsAndProperties = properties; 93 fieldsAndProperties = properties;
92 } 94 }
93 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false); 95 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false);
94 } 96 }
95 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698