| 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 10 matching lines...) Expand all Loading... |
| 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 '../fasta_codes.dart' show messageNoUnnamedConstructorInObject; |
| 32 |
| 31 import '../modifier.dart' show constMask, finalMask, staticMask; | 33 import '../modifier.dart' show constMask, finalMask, staticMask; |
| 32 | 34 |
| 33 import '../names.dart' show indexGetName; | 35 import '../names.dart' show indexGetName; |
| 34 | 36 |
| 35 import '../source/source_class_builder.dart' show SourceClassBuilder; | 37 import '../source/source_class_builder.dart' show SourceClassBuilder; |
| 36 | 38 |
| 37 import 'kernel_builder.dart' | 39 import 'kernel_builder.dart' |
| 38 show | 40 show |
| 39 Builder, | 41 Builder, |
| 40 EnumBuilder, | 42 EnumBuilder, |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 new VariableGet(constructor.function.positionalParameters.single)) | 254 new VariableGet(constructor.function.positionalParameters.single)) |
| 253 ..parent = constructor); | 255 ..parent = constructor); |
| 254 KernelClassBuilder objectClass = objectType.builder; | 256 KernelClassBuilder objectClass = objectType.builder; |
| 255 MemberBuilder superConstructor = objectClass.findConstructorOrFactory( | 257 MemberBuilder superConstructor = objectClass.findConstructorOrFactory( |
| 256 "", charOffset, fileUri, libraryBuilder); | 258 "", charOffset, fileUri, libraryBuilder); |
| 257 if (superConstructor == null || !superConstructor.isConstructor) { | 259 if (superConstructor == null || !superConstructor.isConstructor) { |
| 258 // TODO(ahe): Ideally, we would also want to check that [Object]'s | 260 // TODO(ahe): Ideally, we would also want to check that [Object]'s |
| 259 // unnamed constructor requires no arguments. But that information isn't | 261 // unnamed constructor requires no arguments. But that information isn't |
| 260 // always available at this point, and it's not really a situation that | 262 // always available at this point, and it's not really a situation that |
| 261 // can happen unless you start modifying the SDK sources. | 263 // can happen unless you start modifying the SDK sources. |
| 262 deprecated_addCompileTimeError( | 264 addCompileTimeError(messageNoUnnamedConstructorInObject, -1); |
| 263 -1, "'Object' has no unnamed constructor."); | |
| 264 } else { | 265 } else { |
| 265 constructor.initializers.add( | 266 constructor.initializers.add( |
| 266 new SuperInitializer(superConstructor.target, new Arguments.empty()) | 267 new SuperInitializer(superConstructor.target, new Arguments.empty()) |
| 267 ..parent = constructor); | 268 ..parent = constructor); |
| 268 } | 269 } |
| 269 int index = 0; | 270 int index = 0; |
| 270 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { | 271 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { |
| 271 String constant = constantNamesAndOffsets[i]; | 272 String constant = constantNamesAndOffsets[i]; |
| 272 if (constant != null) { | 273 if (constant != null) { |
| 273 KernelFieldBuilder field = this[constant]; | 274 KernelFieldBuilder field = this[constant]; |
| 274 field.build(libraryBuilder); | 275 field.build(libraryBuilder); |
| 275 Arguments arguments = | 276 Arguments arguments = |
| 276 new Arguments(<Expression>[new IntLiteral(index++)]); | 277 new Arguments(<Expression>[new IntLiteral(index++)]); |
| 277 field.initializer = | 278 field.initializer = |
| 278 new ConstructorInvocation(constructor, arguments, isConst: true); | 279 new ConstructorInvocation(constructor, arguments, isConst: true); |
| 279 } | 280 } |
| 280 } | 281 } |
| 281 return super.build(libraryBuilder, coreLibrary); | 282 return super.build(libraryBuilder, coreLibrary); |
| 282 } | 283 } |
| 283 | 284 |
| 284 @override | 285 @override |
| 285 Builder findConstructorOrFactory( | 286 Builder findConstructorOrFactory( |
| 286 String name, int charOffset, Uri uri, LibraryBuilder library) { | 287 String name, int charOffset, Uri uri, LibraryBuilder library) { |
| 287 return null; | 288 return null; |
| 288 } | 289 } |
| 289 } | 290 } |
| OLD | NEW |