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

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

Issue 2941033002: Finish strong mode cleaning of dart2js. (Closed)
Patch Set: 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.Expression> fieldMetadata;
ahe 2017/06/15 09:36:39 I'm concerned about causing a checked mode problem
Johnni Winther 2017/06/15 10:21:26 If you change `var fieldMetadata = [];` in class_e
ahe 2017/06/15 11:41:57 Done.
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.forLibrary(LibraryEntity library, this.namer) 27 ClassBuilder.forLibrary(LibraryEntity library, this.namer)
28 : isForActualClass = false, 28 : isForActualClass = false,
29 element = library; 29 element = library;
30 30
31 ClassBuilder.forClass(ClassEntity cls, this.namer) 31 ClassBuilder.forClass(ClassEntity cls, this.namer)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (functionType != null) { 68 if (functionType != null) {
69 // See [functionTypeEncodingDescription] above. 69 // See [functionTypeEncodingDescription] above.
70 parts.add(js.stringPart(':')); 70 parts.add(js.stringPart(':'));
71 parts.add(functionType); 71 parts.add(functionType);
72 } 72 }
73 } 73 }
74 parts.add(js.stringPart(';')); 74 parts.add(js.stringPart(';'));
75 } 75 }
76 // See [fieldEncodingDescription] above. 76 // See [fieldEncodingDescription] above.
77 parts.addAll(js.joinLiterals(fields, js.stringPart(','))); 77 parts.addAll(js.joinLiterals(fields, js.stringPart(',')));
78 var classData = js.concatenateStrings(parts, addQuotes: true); 78 dynamic classData = js.concatenateStrings(parts, addQuotes: true);
79 if (fieldMetadata != null) { 79 if (fieldMetadata != null) {
80 // If we need to store fieldMetadata, classData is turned into an array, 80 // If we need to store fieldMetadata, classData is turned into an array,
81 // and the field metadata is appended. So if classData is just a string, 81 // and the field metadata is appended. So if classData is just a string,
82 // there is no field metadata. 82 // there is no field metadata.
83 classData = 83 classData =
84 new jsAst.ArrayInitializer([classData]..addAll(fieldMetadata)); 84 new jsAst.ArrayInitializer([classData]..addAll(fieldMetadata));
85 } 85 }
86 List<jsAst.Property> fieldsAndProperties; 86 List<jsAst.Property> fieldsAndProperties;
87 if (emitClassDescriptor) { 87 if (emitClassDescriptor) {
88 fieldsAndProperties = <jsAst.Property>[]; 88 fieldsAndProperties = <jsAst.Property>[];
89 fieldsAndProperties.add(new jsAst.Property( 89 fieldsAndProperties.add(new jsAst.Property(
90 js.string(namer.classDescriptorProperty), classData)); 90 js.string(namer.classDescriptorProperty), classData));
91 fieldsAndProperties.addAll(properties); 91 fieldsAndProperties.addAll(properties);
92 } else { 92 } else {
93 fieldsAndProperties = properties; 93 fieldsAndProperties = properties;
94 } 94 }
95 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false); 95 return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false);
96 } 96 }
97 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698