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

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

Issue 2781493002: Throw AbstractClassInstantiationError on abstract classes. (Closed)
Patch Set: Update co19 status. Created 3 years, 8 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 | « pkg/front_end/lib/src/fasta/loader.dart ('k') | tests/co19/co19-kernel.status » ('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.target_implementation; 5 library fasta.target_implementation;
6 6
7 import 'package:kernel/target/vm.dart' show VmTarget; 7 import 'package:kernel/target/vm.dart' show VmTarget;
8 8
9 import 'builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder; 9 import 'builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder;
10 10
11 import 'loader.dart' show Loader; 11 import 'loader.dart' show Loader;
12 12
13 import 'target.dart' show Target; 13 import 'target.dart' show Target;
14 14
15 import 'ticker.dart' show Ticker; 15 import 'ticker.dart' show Ticker;
16 16
17 import 'translate_uri.dart' show TranslateUri; 17 import 'translate_uri.dart' show TranslateUri;
18 18
19 /// Provides the implementation details used by a loader for a target. 19 /// Provides the implementation details used by a loader for a target.
20 abstract class TargetImplementation extends Target { 20 abstract class TargetImplementation extends Target {
21 final TranslateUri uriTranslator; 21 final TranslateUri uriTranslator;
22 Builder cachedCompileTimeError; 22 Builder cachedCompileTimeError;
23 Builder cachedAbstractClassInstantiationError;
23 Builder cachedNativeAnnotation; 24 Builder cachedNativeAnnotation;
24 25
25 TargetImplementation(Ticker ticker, this.uriTranslator) : super(ticker); 26 TargetImplementation(Ticker ticker, this.uriTranslator) : super(ticker);
26 27
27 /// Creates a [LibraryBuilder] corresponding to [uri], if one doesn't exist 28 /// Creates a [LibraryBuilder] corresponding to [uri], if one doesn't exist
28 /// already. 29 /// already.
29 LibraryBuilder createLibraryBuilder(Uri uri, Uri fileUri); 30 LibraryBuilder createLibraryBuilder(Uri uri, Uri fileUri);
30 31
31 /// Add the classes extended or implemented directly by [cls] to [set]. 32 /// Add the classes extended or implemented directly by [cls] to [set].
32 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set); 33 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set);
(...skipping 10 matching lines...) Expand all
43 44
44 /// Returns a reference to the constructor used for creating a compile-time 45 /// Returns a reference to the constructor used for creating a compile-time
45 /// error. The constructor is expected to accept a single argument of type 46 /// error. The constructor is expected to accept a single argument of type
46 /// String, which is the compile-time error message. 47 /// String, which is the compile-time error message.
47 Builder getCompileTimeError(Loader loader) { 48 Builder getCompileTimeError(Loader loader) {
48 if (cachedCompileTimeError != null) return cachedCompileTimeError; 49 if (cachedCompileTimeError != null) return cachedCompileTimeError;
49 return cachedCompileTimeError = 50 return cachedCompileTimeError =
50 loader.coreLibrary.getConstructor("_CompileTimeError", isPrivate: true); 51 loader.coreLibrary.getConstructor("_CompileTimeError", isPrivate: true);
51 } 52 }
52 53
54 /// Returns a reference to the constructor of
55 /// [AbstractClassInstantiationError] error. The constructor is expected to
56 /// accept a single argument of type String, which is the name of the
57 /// abstract class.
58 Builder getAbstractClassInstantiationError(Loader loader) {
59 if (cachedAbstractClassInstantiationError != null) {
60 return cachedAbstractClassInstantiationError;
61 }
62 return cachedAbstractClassInstantiationError =
63 loader.coreLibrary.getConstructor("AbstractClassInstantiationError");
64 }
65
53 /// Returns a reference to the constructor used for creating `native` 66 /// Returns a reference to the constructor used for creating `native`
54 /// annotations. The constructor is expected to accept a single argument of 67 /// annotations. The constructor is expected to accept a single argument of
55 /// type String, which is the name of the native method. 68 /// type String, which is the name of the native method.
56 Builder getNativeAnnotation(Loader loader) { 69 Builder getNativeAnnotation(Loader loader) {
57 if (cachedNativeAnnotation != null) return cachedNativeAnnotation; 70 if (cachedNativeAnnotation != null) return cachedNativeAnnotation;
58 LibraryBuilder internal = loader.read(Uri.parse("dart:_internal")); 71 LibraryBuilder internal = loader.read(Uri.parse("dart:_internal"));
59 return cachedNativeAnnotation = internal.getConstructor("ExternalName"); 72 return cachedNativeAnnotation = internal.getConstructor("ExternalName");
60 } 73 }
61 74
62 void loadExtraRequiredLibraries(Loader loader) { 75 void loadExtraRequiredLibraries(Loader loader) {
63 for (String uri in new VmTarget(null).extraRequiredLibraries) { 76 for (String uri in new VmTarget(null).extraRequiredLibraries) {
64 loader.read(Uri.parse(uri)); 77 loader.read(Uri.parse(uri));
65 } 78 }
66 } 79 }
67 80
68 void addSourceInformation( 81 void addSourceInformation(
69 Uri uri, List<int> lineStarts, List<int> sourceCode); 82 Uri uri, List<int> lineStarts, List<int> sourceCode);
70 } 83 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/loader.dart ('k') | tests/co19/co19-kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698