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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart

Issue 2941093002: Only attempt to do type inference on fields that lack a declared type. (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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 fasta.kernel_enum_builder; 5 library fasta.kernel_enum_builder;
6 6
7 import 'package:kernel/ast.dart' 7 import 'package:kernel/ast.dart'
8 show 8 show
9 Arguments, 9 Arguments,
10 Class, 10 Class,
(...skipping 10 matching lines...) Expand all
21 MapLiteral, 21 MapLiteral,
22 MethodInvocation, 22 MethodInvocation,
23 ProcedureKind, 23 ProcedureKind,
24 ReturnStatement, 24 ReturnStatement,
25 StaticGet, 25 StaticGet,
26 StringLiteral, 26 StringLiteral,
27 SuperInitializer, 27 SuperInitializer,
28 ThisExpression, 28 ThisExpression,
29 VariableGet; 29 VariableGet;
30 30
31 import 'package:front_end/src/scanner/token.dart' show Token;
32
33 import '../modifier.dart' show constMask, finalMask, staticMask; 31 import '../modifier.dart' show constMask, finalMask, staticMask;
34 32
35 import '../names.dart' show indexGetName; 33 import '../names.dart' show indexGetName;
36 34
37 import '../source/source_class_builder.dart' show SourceClassBuilder; 35 import '../source/source_class_builder.dart' show SourceClassBuilder;
38 36
39 import 'kernel_builder.dart' 37 import 'kernel_builder.dart'
40 show 38 show
41 Builder, 39 Builder,
42 EnumBuilder, 40 EnumBuilder,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 /// metadata class E { 111 /// metadata class E {
114 /// final int index; 112 /// final int index;
115 /// const E(this.index); 113 /// const E(this.index);
116 /// static const E id0 = const E(0); 114 /// static const E id0 = const E(0);
117 /// ... 115 /// ...
118 /// static const E idn-1 = const E(n - 1); 116 /// static const E idn-1 = const E(n - 1);
119 /// static const List<E> values = const <E>[id0, ..., idn-1]; 117 /// static const List<E> values = const <E>[id0, ..., idn-1];
120 /// String toString() => { 0: ‘E.id0’, . . ., n-1: ‘E.idn-1’}[index] 118 /// String toString() => { 0: ‘E.id0’, . . ., n-1: ‘E.idn-1’}[index]
121 /// } 119 /// }
122 members["index"] = new KernelFieldBuilder( 120 members["index"] = new KernelFieldBuilder(
123 null, 121 null, intType, "index", finalMask, parent, charOffset, null, true);
124 intType,
125 "index",
126 finalMask,
127 parent,
128 charOffset,
129 // Synthetic token to signal this field is initialized.
130 new Token.eof(charOffset));
131 KernelConstructorBuilder constructorBuilder = new KernelConstructorBuilder( 122 KernelConstructorBuilder constructorBuilder = new KernelConstructorBuilder(
132 null, 123 null,
133 constMask, 124 constMask,
134 null, 125 null,
135 "", 126 "",
136 null, 127 null,
137 <FormalParameterBuilder>[ 128 <FormalParameterBuilder>[
138 new KernelFormalParameterBuilder( 129 new KernelFormalParameterBuilder(
139 null, 0, intType, "index", true, parent, charOffset) 130 null, 0, intType, "index", true, parent, charOffset)
140 ], 131 ],
141 parent, 132 parent,
142 charOffset, 133 charOffset,
143 charOffset, 134 charOffset,
144 charEndOffset); 135 charEndOffset);
145 constructors[""] = constructorBuilder; 136 constructors[""] = constructorBuilder;
146 int index = 0; 137 int index = 0;
147 List<MapEntry> toStringEntries = <MapEntry>[]; 138 List<MapEntry> toStringEntries = <MapEntry>[];
148 KernelFieldBuilder valuesBuilder = new KernelFieldBuilder( 139 KernelFieldBuilder valuesBuilder = new KernelFieldBuilder(null, listType,
149 null, 140 "values", constMask | staticMask, parent, charOffset, null, true);
150 listType,
151 "values",
152 constMask | staticMask,
153 parent,
154 charOffset,
155 // Synthetic token to signal this field is initialized.
156 new Token.eof(charOffset));
157 members["values"] = valuesBuilder; 141 members["values"] = valuesBuilder;
158 KernelProcedureBuilder toStringBuilder = new KernelProcedureBuilder( 142 KernelProcedureBuilder toStringBuilder = new KernelProcedureBuilder(
159 null, 143 null,
160 0, 144 0,
161 stringType, 145 stringType,
162 "toString", 146 "toString",
163 null, 147 null,
164 null, 148 null,
165 ProcedureKind.Method, 149 ProcedureKind.Method,
166 parent, 150 parent,
(...skipping 11 matching lines...) Expand all
178 continue; 162 continue;
179 } 163 }
180 if (name == className) { 164 if (name == className) {
181 parent.addCompileTimeError( 165 parent.addCompileTimeError(
182 charOffset, 166 charOffset,
183 "Name of enum constant '$name' can't be the same as the enum's " 167 "Name of enum constant '$name' can't be the same as the enum's "
184 "own name."); 168 "own name.");
185 constantNamesAndOffsets[i] = null; 169 constantNamesAndOffsets[i] = null;
186 continue; 170 continue;
187 } 171 }
188 KernelFieldBuilder fieldBuilder = new KernelFieldBuilder( 172 KernelFieldBuilder fieldBuilder = new KernelFieldBuilder(null, selfType,
189 null, 173 name, constMask | staticMask, parent, charOffset, null, true);
190 selfType,
191 name,
192 constMask | staticMask,
193 parent,
194 charOffset,
195 // Synthetic token to signal this field is initialized.
196 new Token.eof(charOffset));
197 members[name] = fieldBuilder; 174 members[name] = fieldBuilder;
198 toStringEntries.add(new MapEntry( 175 toStringEntries.add(new MapEntry(
199 new IntLiteral(index), new StringLiteral("$className.$name"))); 176 new IntLiteral(index), new StringLiteral("$className.$name")));
200 index++; 177 index++;
201 } 178 }
202 MapLiteral toStringMap = new MapLiteral(toStringEntries, isConst: true); 179 MapLiteral toStringMap = new MapLiteral(toStringEntries, isConst: true);
203 KernelEnumBuilder enumBuilder = new KernelEnumBuilder.internal( 180 KernelEnumBuilder enumBuilder = new KernelEnumBuilder.internal(
204 metadata, 181 metadata,
205 name, 182 name,
206 new Scope(members, null, parent.scope, isModifiable: false), 183 new Scope(members, null, parent.scope, isModifiable: false),
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 278 }
302 return super.build(libraryBuilder, coreLibrary); 279 return super.build(libraryBuilder, coreLibrary);
303 } 280 }
304 281
305 @override 282 @override
306 Builder findConstructorOrFactory( 283 Builder findConstructorOrFactory(
307 String name, int charOffset, Uri uri, LibraryBuilder library) { 284 String name, int charOffset, Uri uri, LibraryBuilder library) {
308 return null; 285 return null;
309 } 286 }
310 } 287 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698