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

Unified Diff: pkg/front_end/test/src/incremental/mock_sdk.dart

Issue 2993093003: Add support for SDK outline in KernelDriver. (Closed)
Patch Set: Merge and tweaks. Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/test/src/incremental/kernel_driver_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/src/incremental/mock_sdk.dart
diff --git a/pkg/front_end/test/src/incremental/mock_sdk.dart b/pkg/front_end/test/src/incremental/mock_sdk.dart
index b4b8d81c295c10f08567c484bdf0d8201718b4c3..f82d07a622a193e04fe05d7d295d6e4119b8b2a0 100644
--- a/pkg/front_end/test/src/incremental/mock_sdk.dart
+++ b/pkg/front_end/test/src/incremental/mock_sdk.dart
@@ -5,22 +5,45 @@
import 'package:front_end/memory_file_system.dart';
import 'package:front_end/src/base/libraries_specification.dart';
-/// Create SDK libraries which are used by Fasta to perform kernel generation.
-/// The root of the SDK is `file:///sdk`, it will contain a libraries
-/// specification file at `lib/libraries.json`.
-///
-/// Returns the [TargetLibrariesSpecification] whose contents are in
-/// libraries.json.
-TargetLibrariesSpecification createSdkFiles(MemoryFileSystem fileSystem) {
- Map<String, LibraryInfo> dartLibraries = {};
- void addSdkLibrary(String name, String contents) {
- String path = '$name/$name.dart';
- Uri uri = Uri.parse('file:///sdk/lib/$path');
- fileSystem.entityForUri(uri).writeAsStringSync(contents);
- dartLibraries[name] = new LibraryInfo(name, uri, const []);
- }
+final _ASYNC = r'''
+library dart.async;
+
+class Future<T> {
+ factory Future(computation()) => null;
+ factory Future.delayed(Duration duration, [T computation()]) => null;
+ factory Future.microtask(FutureOr<T> computation()) => null;
+ factory Future.value([value]) => null;
+
+ static Future<List<T>> wait<T>(Iterable<Future<T>> futures) => null;
+ Future<R> then<R>(FutureOr<R> onValue(T value)) => null;
+
+ Future<T> whenComplete(action());
+}
+
+
+class FutureOr<T> {}
+class Stream<T> {}
+abstract class StreamIterator<T> {}
+
+abstract class Completer<T> {
+ factory Completer() => null;
+ factory Completer.sync() => null;
+ Future<T> get future;
+ void complete([FutureOr<T> value]);
+ void completeError(Object error, [StackTrace stackTrace]);
+ bool get isCompleted;
+}
+
+class _StreamIterator<T> implements StreamIterator<T> {}
+class _AsyncStarStreamController {}
+Object _asyncStackTraceHelper(Function async_op) { }
+Function _asyncThenWrapperHelper(continuation) {}
+Function _asyncErrorWrapperHelper(continuation) {}
+Future _awaitHelper(
+ object, Function thenCallback, Function errorCallback, var awaiter) {}
+''';
- addSdkLibrary('core', r'''
+final _CORE = r'''
library dart.core;
import 'dart:_internal';
import 'dart:async';
@@ -203,45 +226,27 @@ external bool identical(Object a, Object b);
void print(Object o) {}
abstract class _SyncIterable implements Iterable {}
-''');
-
- addSdkLibrary('async', r'''
-library dart.async;
+''';
-class Future<T> {
- factory Future(computation()) => null;
- factory Future.delayed(Duration duration, [T computation()]) => null;
- factory Future.microtask(FutureOr<T> computation()) => null;
- factory Future.value([value]) => null;
-
- static Future<List<T>> wait<T>(Iterable<Future<T>> futures) => null;
- Future<R> then<R>(FutureOr<R> onValue(T value)) => null;
-
- Future<T> whenComplete(action());
-}
-
-
-class FutureOr<T> {}
-class Stream<T> {}
-abstract class StreamIterator<T> {}
+/// Create SDK libraries which are used by Fasta to perform kernel generation.
+/// The root of the SDK is `file:///sdk`, it will contain a libraries
+/// specification file at `lib/libraries.json`.
+///
+/// Returns the [TargetLibrariesSpecification] whose contents are in
+/// libraries.json.
+TargetLibrariesSpecification createSdkFiles(MemoryFileSystem fileSystem) {
+ Map<String, LibraryInfo> dartLibraries = {};
+ void addSdkLibrary(String name, String contents) {
+ String path = '$name/$name.dart';
+ Uri uri = Uri.parse('file:///sdk/lib/$path');
+ fileSystem.entityForUri(uri).writeAsStringSync(contents);
+ dartLibraries[name] = new LibraryInfo(name, uri, const []);
+ }
-abstract class Completer<T> {
- factory Completer() => null;
- factory Completer.sync() => null;
- Future<T> get future;
- void complete([FutureOr<T> value]);
- void completeError(Object error, [StackTrace stackTrace]);
- bool get isCompleted;
-}
+ fileSystem.entityForUri(Uri.parse('file:///sdk/')).createDirectory();
-class _StreamIterator<T> implements StreamIterator<T> {}
-class _AsyncStarStreamController {}
-Object _asyncStackTraceHelper(Function async_op) { }
-Function _asyncThenWrapperHelper(continuation) {}
-Function _asyncErrorWrapperHelper(continuation) {}
-Future _awaitHelper(
- object, Function thenCallback, Function errorCallback, var awaiter) {}
-''');
+ addSdkLibrary('core', _CORE);
+ addSdkLibrary('async', _ASYNC);
addSdkLibrary('collection', 'library dart.collection;');
addSdkLibrary('convert', 'library dart.convert;');
@@ -256,7 +261,6 @@ external double sin(num radians);
addSdkLibrary('nativewrappers', 'library dart.nativewrappers;');
addSdkLibrary('profiler', 'library dart.profiler;');
addSdkLibrary('typed_data', 'library dart.typed_data;');
- addSdkLibrary('vmservice_io', 'library dart.vmservice_io;');
addSdkLibrary('_builtin', 'library dart._builtin;');
addSdkLibrary('_internal', '''
library dart._internal;
@@ -266,10 +270,9 @@ class ExternalName {
const ExternalName(this.name);
}
''');
- addSdkLibrary('_vmservice', 'library dart._vmservice;');
- var targetSpec = new TargetLibrariesSpecification('vm', dartLibraries);
- var spec = new LibrariesSpecification({'vm': targetSpec});
+ var targetSpec = new TargetLibrariesSpecification(null, dartLibraries);
+ var spec = new LibrariesSpecification({'none': targetSpec, 'vm': targetSpec});
Uri uri = Uri.parse('file:///sdk/lib/libraries.json');
fileSystem.entityForUri(uri).writeAsStringSync(spec.toJsonString(uri));
« no previous file with comments | « pkg/front_end/test/src/incremental/kernel_driver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698