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

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

Issue 2850683004: Get astBuilder and typeInferenceEngine from SourceLoader. (Closed)
Patch Set: Created 3 years, 7 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) 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:front_end/src/fasta/builder/ast_factory.dart' show AstFactory; 7 import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory;
8 8
9 import 'package:kernel/ast.dart' 9 import 'package:kernel/ast.dart'
10 show 10 show
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 /// metadata class E { 117 /// metadata class E {
118 /// final int index; 118 /// final int index;
119 /// const E(this.index); 119 /// const E(this.index);
120 /// static const E id0 = const E(0); 120 /// static const E id0 = const E(0);
121 /// ... 121 /// ...
122 /// static const E idn-1 = const E(n - 1); 122 /// static const E idn-1 = const E(n - 1);
123 /// static const List<E> values = const <E>[id0, ..., idn-1]; 123 /// static const List<E> values = const <E>[id0, ..., idn-1];
124 /// String toString() => { 0: ‘E.id0’, . . ., n-1: ‘E.idn-1’}[index] 124 /// String toString() => { 0: ‘E.id0’, . . ., n-1: ‘E.idn-1’}[index]
125 /// } 125 /// }
126 members["index"] = new KernelFieldBuilder( 126 members["index"] = new KernelFieldBuilder(
127 astFactory, 127 null, intType, "index", finalMask, parent, charOffset, null);
128 parent.loader.typeInferenceEngine,
129 null,
130 intType,
131 "index",
132 finalMask,
133 parent,
134 charOffset,
135 null);
136 KernelConstructorBuilder constructorBuilder = new KernelConstructorBuilder( 128 KernelConstructorBuilder constructorBuilder = new KernelConstructorBuilder(
137 null, 129 null,
138 constMask, 130 constMask,
139 null, 131 null,
140 "", 132 "",
141 null, 133 null,
142 <FormalParameterBuilder>[ 134 <FormalParameterBuilder>[
143 new KernelFormalParameterBuilder( 135 new KernelFormalParameterBuilder(
144 null, 0, intType, "index", true, parent, charOffset) 136 null, 0, intType, "index", true, parent, charOffset)
145 ], 137 ],
146 parent, 138 parent,
147 charOffset, 139 charOffset,
148 charOffset, 140 charOffset,
149 charEndOffset); 141 charEndOffset);
150 constructors[""] = constructorBuilder; 142 constructors[""] = constructorBuilder;
151 int index = 0; 143 int index = 0;
152 List<MapEntry> toStringEntries = <MapEntry>[]; 144 List<MapEntry> toStringEntries = <MapEntry>[];
153 KernelFieldBuilder valuesBuilder = new KernelFieldBuilder( 145 KernelFieldBuilder valuesBuilder = new KernelFieldBuilder(null, listType,
154 astFactory, 146 "values", constMask | staticMask, parent, charOffset, null);
155 parent.loader.typeInferenceEngine,
156 null,
157 listType,
158 "values",
159 constMask | staticMask,
160 parent,
161 charOffset,
162 null);
163 members["values"] = valuesBuilder; 147 members["values"] = valuesBuilder;
164 KernelProcedureBuilder toStringBuilder = new KernelProcedureBuilder( 148 KernelProcedureBuilder toStringBuilder = new KernelProcedureBuilder(
165 null, 149 null,
166 0, 150 0,
167 stringType, 151 stringType,
168 "toString", 152 "toString",
169 null, 153 null,
170 null, 154 null,
171 AsyncMarker.Sync, 155 AsyncMarker.Sync,
172 ProcedureKind.Method, 156 ProcedureKind.Method,
173 parent, 157 parent,
174 charOffset, 158 charOffset,
175 charOffset, 159 charOffset,
176 charEndOffset); 160 charEndOffset);
177 members["toString"] = toStringBuilder; 161 members["toString"] = toStringBuilder;
178 String className = name; 162 String className = name;
179 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { 163 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) {
180 String name = constantNamesAndOffsets[i]; 164 String name = constantNamesAndOffsets[i];
181 int charOffset = constantNamesAndOffsets[i + 1]; 165 int charOffset = constantNamesAndOffsets[i + 1];
182 if (members.containsKey(name)) { 166 if (members.containsKey(name)) {
183 inputError(null, null, "Duplicated name: $name"); 167 inputError(null, null, "Duplicated name: $name");
184 continue; 168 continue;
185 } 169 }
186 KernelFieldBuilder fieldBuilder = new KernelFieldBuilder( 170 KernelFieldBuilder fieldBuilder = new KernelFieldBuilder(null, selfType,
187 astFactory, 171 name, constMask | staticMask, parent, charOffset, null);
188 parent.loader.typeInferenceEngine,
189 null,
190 selfType,
191 name,
192 constMask | staticMask,
193 parent,
194 charOffset,
195 null);
196 members[name] = fieldBuilder; 172 members[name] = fieldBuilder;
197 toStringEntries.add(new MapEntry( 173 toStringEntries.add(new MapEntry(
198 new IntLiteral(index), new StringLiteral("$className.$name"))); 174 new IntLiteral(index), new StringLiteral("$className.$name")));
199 index++; 175 index++;
200 } 176 }
201 MapLiteral toStringMap = new MapLiteral(toStringEntries, isConst: true); 177 MapLiteral toStringMap = new MapLiteral(toStringEntries, isConst: true);
202 KernelEnumBuilder enumBuilder = new KernelEnumBuilder.internal( 178 KernelEnumBuilder enumBuilder = new KernelEnumBuilder.internal(
203 metadata, 179 metadata,
204 name, 180 name,
205 new Scope(members, null, parent.scope, isModifiable: false), 181 new Scope(members, null, parent.scope, isModifiable: false),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 new ConstructorInvocation(constructor, arguments, isConst: true); 271 new ConstructorInvocation(constructor, arguments, isConst: true);
296 } 272 }
297 return super.build(libraryBuilder, coreLibrary); 273 return super.build(libraryBuilder, coreLibrary);
298 } 274 }
299 275
300 @override 276 @override
301 Builder findConstructorOrFactory(String name, int charOffset, Uri uri) { 277 Builder findConstructorOrFactory(String name, int charOffset, Uri uri) {
302 return null; 278 return null;
303 } 279 }
304 } 280 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698