| 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:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
| 8 show | 8 show |
| 9 Arguments, | 9 Arguments, |
| 10 Class, | 10 Class, |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 valuesBuilder.initializer = | 235 valuesBuilder.initializer = |
| 236 new ListLiteral(values, typeArgument: cls.rawType, isConst: true); | 236 new ListLiteral(values, typeArgument: cls.rawType, isConst: true); |
| 237 KernelConstructorBuilder constructorBuilder = constructorScopeBuilder[""]; | 237 KernelConstructorBuilder constructorBuilder = constructorScopeBuilder[""]; |
| 238 Constructor constructor = constructorBuilder.build(libraryBuilder); | 238 Constructor constructor = constructorBuilder.build(libraryBuilder); |
| 239 constructor.initializers.insert( | 239 constructor.initializers.insert( |
| 240 0, | 240 0, |
| 241 new FieldInitializer(indexField, | 241 new FieldInitializer(indexField, |
| 242 new VariableGet(constructor.function.positionalParameters.single)) | 242 new VariableGet(constructor.function.positionalParameters.single)) |
| 243 ..parent = constructor); | 243 ..parent = constructor); |
| 244 KernelClassBuilder objectClass = objectType.builder; | 244 KernelClassBuilder objectClass = objectType.builder; |
| 245 MemberBuilder superConstructor = | 245 MemberBuilder superConstructor = objectClass.findConstructorOrFactory( |
| 246 objectClass.findConstructorOrFactory("", charOffset, fileUri); | 246 "", charOffset, fileUri, libraryBuilder); |
| 247 if (superConstructor == null || !superConstructor.isConstructor) { | 247 if (superConstructor == null || !superConstructor.isConstructor) { |
| 248 // TODO(ahe): Ideally, we would also want to check that [Object]'s | 248 // TODO(ahe): Ideally, we would also want to check that [Object]'s |
| 249 // unnamed constructor requires no arguments. But that information isn't | 249 // unnamed constructor requires no arguments. But that information isn't |
| 250 // always available at this point, and it's not really a situation that | 250 // always available at this point, and it's not really a situation that |
| 251 // can happen unless you start modifying the SDK sources. | 251 // can happen unless you start modifying the SDK sources. |
| 252 addCompileTimeError(-1, "'Object' has no unnamed constructor."); | 252 addCompileTimeError(-1, "'Object' has no unnamed constructor."); |
| 253 } else { | 253 } else { |
| 254 constructor.initializers.add( | 254 constructor.initializers.add( |
| 255 new SuperInitializer(superConstructor.target, new Arguments.empty()) | 255 new SuperInitializer(superConstructor.target, new Arguments.empty()) |
| 256 ..parent = constructor); | 256 ..parent = constructor); |
| 257 } | 257 } |
| 258 int index = 0; | 258 int index = 0; |
| 259 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { | 259 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { |
| 260 String constant = constantNamesAndOffsets[i]; | 260 String constant = constantNamesAndOffsets[i]; |
| 261 KernelFieldBuilder field = this[constant]; | 261 KernelFieldBuilder field = this[constant]; |
| 262 field.build(libraryBuilder); | 262 field.build(libraryBuilder); |
| 263 Arguments arguments = | 263 Arguments arguments = |
| 264 new Arguments(<Expression>[new IntLiteral(index++)]); | 264 new Arguments(<Expression>[new IntLiteral(index++)]); |
| 265 field.initializer = | 265 field.initializer = |
| 266 new ConstructorInvocation(constructor, arguments, isConst: true); | 266 new ConstructorInvocation(constructor, arguments, isConst: true); |
| 267 } | 267 } |
| 268 return super.build(libraryBuilder, coreLibrary); | 268 return super.build(libraryBuilder, coreLibrary); |
| 269 } | 269 } |
| 270 | 270 |
| 271 @override | 271 @override |
| 272 Builder findConstructorOrFactory(String name, int charOffset, Uri uri) { | 272 Builder findConstructorOrFactory( |
| 273 String name, int charOffset, Uri uri, LibraryBuilder library) { |
| 273 return null; | 274 return null; |
| 274 } | 275 } |
| 275 } | 276 } |
| OLD | NEW |