OLD | NEW |
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 astFactory, |
128 parent.loader.topLevelTypeInferrer, | 128 parent.loader.typeInferenceEngine, |
129 null, | 129 null, |
130 intType, | 130 intType, |
131 "index", | 131 "index", |
132 finalMask, | 132 finalMask, |
133 parent, | 133 parent, |
134 charOffset, | 134 charOffset, |
135 null); | 135 null); |
136 KernelConstructorBuilder constructorBuilder = new KernelConstructorBuilder( | 136 KernelConstructorBuilder constructorBuilder = new KernelConstructorBuilder( |
137 null, | 137 null, |
138 constMask, | 138 constMask, |
139 null, | 139 null, |
140 "", | 140 "", |
141 null, | 141 null, |
142 <FormalParameterBuilder>[ | 142 <FormalParameterBuilder>[ |
143 new KernelFormalParameterBuilder( | 143 new KernelFormalParameterBuilder( |
144 null, 0, intType, "index", true, parent, charOffset) | 144 null, 0, intType, "index", true, parent, charOffset) |
145 ], | 145 ], |
146 parent, | 146 parent, |
147 charOffset, | 147 charOffset, |
148 charOffset, | 148 charOffset, |
149 charEndOffset); | 149 charEndOffset); |
150 constructors[""] = constructorBuilder; | 150 constructors[""] = constructorBuilder; |
151 int index = 0; | 151 int index = 0; |
152 List<MapEntry> toStringEntries = <MapEntry>[]; | 152 List<MapEntry> toStringEntries = <MapEntry>[]; |
153 KernelFieldBuilder valuesBuilder = new KernelFieldBuilder( | 153 KernelFieldBuilder valuesBuilder = new KernelFieldBuilder( |
154 astFactory, | 154 astFactory, |
155 parent.loader.topLevelTypeInferrer, | 155 parent.loader.typeInferenceEngine, |
156 null, | 156 null, |
157 listType, | 157 listType, |
158 "values", | 158 "values", |
159 constMask | staticMask, | 159 constMask | staticMask, |
160 parent, | 160 parent, |
161 charOffset, | 161 charOffset, |
162 null); | 162 null); |
163 members["values"] = valuesBuilder; | 163 members["values"] = valuesBuilder; |
164 KernelProcedureBuilder toStringBuilder = new KernelProcedureBuilder( | 164 KernelProcedureBuilder toStringBuilder = new KernelProcedureBuilder( |
165 null, | 165 null, |
(...skipping 12 matching lines...) Expand all Loading... |
178 String className = name; | 178 String className = name; |
179 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { | 179 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { |
180 String name = constantNamesAndOffsets[i]; | 180 String name = constantNamesAndOffsets[i]; |
181 int charOffset = constantNamesAndOffsets[i + 1]; | 181 int charOffset = constantNamesAndOffsets[i + 1]; |
182 if (members.containsKey(name)) { | 182 if (members.containsKey(name)) { |
183 inputError(null, null, "Duplicated name: $name"); | 183 inputError(null, null, "Duplicated name: $name"); |
184 continue; | 184 continue; |
185 } | 185 } |
186 KernelFieldBuilder fieldBuilder = new KernelFieldBuilder( | 186 KernelFieldBuilder fieldBuilder = new KernelFieldBuilder( |
187 astFactory, | 187 astFactory, |
188 parent.loader.topLevelTypeInferrer, | 188 parent.loader.typeInferenceEngine, |
189 null, | 189 null, |
190 selfType, | 190 selfType, |
191 name, | 191 name, |
192 constMask | staticMask, | 192 constMask | staticMask, |
193 parent, | 193 parent, |
194 charOffset, | 194 charOffset, |
195 null); | 195 null); |
196 members[name] = fieldBuilder; | 196 members[name] = fieldBuilder; |
197 toStringEntries.add(new MapEntry( | 197 toStringEntries.add(new MapEntry( |
198 new IntLiteral(index), new StringLiteral("$className.$name"))); | 198 new IntLiteral(index), new StringLiteral("$className.$name"))); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 new ConstructorInvocation(constructor, arguments, isConst: true); | 295 new ConstructorInvocation(constructor, arguments, isConst: true); |
296 } | 296 } |
297 return super.build(libraryBuilder, coreLibrary); | 297 return super.build(libraryBuilder, coreLibrary); |
298 } | 298 } |
299 | 299 |
300 @override | 300 @override |
301 Builder findConstructorOrFactory(String name, int charOffset, Uri uri) { | 301 Builder findConstructorOrFactory(String name, int charOffset, Uri uri) { |
302 return null; | 302 return null; |
303 } | 303 } |
304 } | 304 } |
OLD | NEW |