| 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.target_implementation; | 5 library fasta.target_implementation; |
| 6 | 6 |
| 7 import 'package:kernel/target/vm.dart' show VmTarget; | 7 import 'package:kernel/target/targets.dart' as backend show Target; |
| 8 | 8 |
| 9 import 'builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder; | 9 import 'builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder; |
| 10 | 10 |
| 11 import 'parser/dart_vm_native.dart' as vm show skipNativeClause; | 11 import 'parser/dart_vm_native.dart' as vm show skipNativeClause; |
| 12 | 12 |
| 13 import '../scanner/token.dart' show Token; | 13 import '../scanner/token.dart' show Token; |
| 14 | 14 |
| 15 import 'loader.dart' show Loader; | 15 import 'loader.dart' show Loader; |
| 16 | 16 |
| 17 import 'quote.dart' show unescapeString; | 17 import 'quote.dart' show unescapeString; |
| 18 | 18 |
| 19 import 'target.dart' show Target; | 19 import 'target.dart' show Target; |
| 20 | 20 |
| 21 import 'ticker.dart' show Ticker; | 21 import 'ticker.dart' show Ticker; |
| 22 | 22 |
| 23 import 'translate_uri.dart' show TranslateUri; | 23 import 'translate_uri.dart' show TranslateUri; |
| 24 | 24 |
| 25 /// Provides the implementation details used by a loader for a target. | 25 /// Provides the implementation details used by a loader for a target. |
| 26 abstract class TargetImplementation extends Target { | 26 abstract class TargetImplementation extends Target { |
| 27 final TranslateUri uriTranslator; | 27 final TranslateUri uriTranslator; |
| 28 |
| 29 final backend.Target backendTarget; |
| 30 |
| 28 Builder cachedCompileTimeError; | 31 Builder cachedCompileTimeError; |
| 29 Builder cachedAbstractClassInstantiationError; | 32 Builder cachedAbstractClassInstantiationError; |
| 30 Builder cachedNativeAnnotation; | 33 Builder cachedNativeAnnotation; |
| 31 | 34 |
| 32 TargetImplementation(Ticker ticker, this.uriTranslator) : super(ticker); | 35 TargetImplementation(Ticker ticker, this.uriTranslator, this.backendTarget) |
| 36 : super(ticker); |
| 33 | 37 |
| 34 /// Creates a [LibraryBuilder] corresponding to [uri], if one doesn't exist | 38 /// Creates a [LibraryBuilder] corresponding to [uri], if one doesn't exist |
| 35 /// already. | 39 /// already. |
| 36 LibraryBuilder createLibraryBuilder(Uri uri, Uri fileUri); | 40 LibraryBuilder createLibraryBuilder(Uri uri, Uri fileUri); |
| 37 | 41 |
| 38 /// Add the classes extended or implemented directly by [cls] to [set]. | 42 /// Add the classes extended or implemented directly by [cls] to [set]. |
| 39 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set); | 43 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set); |
| 40 | 44 |
| 41 /// Returns all classes that will be included in the resulting program. | 45 /// Returns all classes that will be included in the resulting program. |
| 42 List<ClassBuilder> collectAllClasses(); | 46 List<ClassBuilder> collectAllClasses(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 72 /// Returns a reference to the constructor used for creating `native` | 76 /// Returns a reference to the constructor used for creating `native` |
| 73 /// annotations. The constructor is expected to accept a single argument of | 77 /// annotations. The constructor is expected to accept a single argument of |
| 74 /// type String, which is the name of the native method. | 78 /// type String, which is the name of the native method. |
| 75 Builder getNativeAnnotation(Loader loader) { | 79 Builder getNativeAnnotation(Loader loader) { |
| 76 if (cachedNativeAnnotation != null) return cachedNativeAnnotation; | 80 if (cachedNativeAnnotation != null) return cachedNativeAnnotation; |
| 77 LibraryBuilder internal = loader.read(Uri.parse("dart:_internal")); | 81 LibraryBuilder internal = loader.read(Uri.parse("dart:_internal")); |
| 78 return cachedNativeAnnotation = internal.getConstructor("ExternalName"); | 82 return cachedNativeAnnotation = internal.getConstructor("ExternalName"); |
| 79 } | 83 } |
| 80 | 84 |
| 81 void loadExtraRequiredLibraries(Loader loader) { | 85 void loadExtraRequiredLibraries(Loader loader) { |
| 82 for (String uri in new VmTarget(null).extraRequiredLibraries) { | 86 for (String uri in backendTarget.extraRequiredLibraries) { |
| 83 loader.read(Uri.parse(uri)); | 87 loader.read(Uri.parse(uri)); |
| 84 } | 88 } |
| 85 } | 89 } |
| 86 | 90 |
| 87 Token skipNativeClause(Token token) => vm.skipNativeClause(token); | 91 Token skipNativeClause(Token token) => vm.skipNativeClause(token); |
| 88 | 92 |
| 89 String extractNativeMethodName(Token token) => | 93 String extractNativeMethodName(Token token) => |
| 90 unescapeString(token.next.lexeme); | 94 unescapeString(token.next.lexeme); |
| 91 | 95 |
| 92 void addSourceInformation( | 96 void addSourceInformation( |
| 93 Uri uri, List<int> lineStarts, List<int> sourceCode); | 97 Uri uri, List<int> lineStarts, List<int> sourceCode); |
| 94 } | 98 } |
| OLD | NEW |