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

Side by Side Diff: pkg/front_end/test/src/incremental/mock_sdk.dart

Issue 2993093003: Add support for SDK outline in KernelDriver. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:front_end/memory_file_system.dart'; 5 import 'package:front_end/memory_file_system.dart';
6 6
7 /// Create SDK libraries which are used by Fasta to perform kernel generation. 7 final _ASYNC = r'''
Siggi Cherem (dart-lang) 2017/08/05 03:22:47 Yay - thank you, even with syntax highlighting, ha
8 /// Return the mapping from the simple names of these library to the URIs 8 library dart.async;
9 /// in the given [fileSystem]. The root of the SDK is `file:///sdk`.
10 Map<String, Uri> createSdkFiles(MemoryFileSystem fileSystem) {
11 Map<String, Uri> dartLibraries = {};
12 9
13 void addSdkLibrary(String name, String contents) { 10 class Future<T> {
14 String path = '$name/$name.dart'; 11 factory Future(computation()) => null;
15 Uri uri = Uri.parse('file:///sdk/lib/$path'); 12 factory Future.delayed(Duration duration, [T computation()]) => null;
16 fileSystem.entityForUri(uri).writeAsStringSync(contents); 13 factory Future.microtask(FutureOr<T> computation()) => null;
17 dartLibraries[name] = uri; 14 factory Future.value([value]) => null;
18 }
19 15
20 addSdkLibrary('core', r''' 16 static Future<List<T>> wait<T>(Iterable<Future<T>> futures) => null;
17 Future<R> then<R>(FutureOr<R> onValue(T value)) => null;
18
19 Future<T> whenComplete(action());
20 }
21
22
23 class FutureOr<T> {}
24 class Stream<T> {}
25 abstract class StreamIterator<T> {}
26
27 abstract class Completer<T> {
28 factory Completer() => null;
29 factory Completer.sync() => null;
30 Future<T> get future;
31 void complete([FutureOr<T> value]);
32 void completeError(Object error, [StackTrace stackTrace]);
33 bool get isCompleted;
34 }
35
36 class _StreamIterator<T> implements StreamIterator<T> {}
37 class _AsyncStarStreamController {}
38 Object _asyncStackTraceHelper(Function async_op) { }
39 Function _asyncThenWrapperHelper(continuation) {}
40 Function _asyncErrorWrapperHelper(continuation) {}
41 Future _awaitHelper(
42 object, Function thenCallback, Function errorCallback, var awaiter) {}
43 ''';
44
45 final _CORE = r'''
21 library dart.core; 46 library dart.core;
22 import 'dart:_internal'; 47 import 'dart:_internal';
23 import 'dart:async'; 48 import 'dart:async';
24 49
25 class Object { 50 class Object {
26 const Object(); 51 const Object();
27 bool operator ==(other) => identical(this, other); 52 bool operator ==(other) => identical(this, other);
28 String toString() => 'a string'; 53 String toString() => 'a string';
29 int get hashCode => 0; 54 int get hashCode => 0;
30 Type get runtimeType => null; 55 Type get runtimeType => null;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 Iterable<V> get values; 218 Iterable<V> get values;
194 } 219 }
195 220
196 class Duration implements Comparable<Duration> {} 221 class Duration implements Comparable<Duration> {}
197 222
198 external bool identical(Object a, Object b); 223 external bool identical(Object a, Object b);
199 224
200 void print(Object o) {} 225 void print(Object o) {}
201 226
202 abstract class _SyncIterable implements Iterable {} 227 abstract class _SyncIterable implements Iterable {}
228 ''';
229
230 /// Create SDK libraries which are used by Fasta to perform kernel generation.
231 /// Return the mapping from the simple names of these library to the URIs
232 /// in the given [fileSystem]. The root of the SDK is `file:///sdk`.
233 Map<String, Uri> createSdkFiles(MemoryFileSystem fileSystem) {
234 Map<String, Uri> dartLibraries = {};
235
236 void addSdkLibrary(String name, String contents) {
237 String path = '$name/$name.dart';
238 Uri uri = Uri.parse('file:///sdk/lib/$path');
239 fileSystem.entityForUri(uri).writeAsStringSync(contents);
240 dartLibraries[name] = uri;
241 }
242
243 fileSystem.entityForUri(Uri.parse('file:///sdk/')).createDirectory();
244
245 fileSystem
246 .entityForUri(Uri.parse('file:///sdk/lib/libraries.json'))
247 .writeAsStringSync(r'''
248 {
249 "libraries": {
250 "core": "core/core.dart",
251 "async": "async/async.dart",
252 "collection": "collection/collection.dart",
253 "convert": "convert/convert.dart",
254 "developer": "developer/developer.dart",
255 "io": "io/io.dart",
256 "isolate": "isolate/isolate.dart",
257 "math": "math/math.dart",
258 "mirrors": "mirrors/mirrors.dart",
259 "nativewrappers": "nativewrappers/nativewrappers.dart",
260 "profiler": "profiler/profiler.dart",
261 "typed_data": "typed_data/typed_data.dart",
262 "_builtin": "_builtin/_builtin.dart",
263 "_internal": "_internal/_internal.dart"
264 }
265 }
203 '''); 266 ''');
204 267
205 addSdkLibrary('async', r''' 268 addSdkLibrary('core', _CORE);
206 library dart.async;
207 269
208 class Future<T> { 270 addSdkLibrary('async', _ASYNC);
209 factory Future(computation()) => null;
210 factory Future.delayed(Duration duration, [T computation()]) => null;
211 factory Future.microtask(FutureOr<T> computation()) => null;
212 factory Future.value([value]) => null;
213
214 static Future<List<T>> wait<T>(Iterable<Future<T>> futures) => null;
215 Future<R> then<R>(FutureOr<R> onValue(T value)) => null;
216
217 Future<T> whenComplete(action());
218 }
219
220
221 class FutureOr<T> {}
222 class Stream<T> {}
223 abstract class StreamIterator<T> {}
224
225 abstract class Completer<T> {
226 factory Completer() => null;
227 factory Completer.sync() => null;
228 Future<T> get future;
229 void complete([FutureOr<T> value]);
230 void completeError(Object error, [StackTrace stackTrace]);
231 bool get isCompleted;
232 }
233
234 class _StreamIterator<T> implements StreamIterator<T> {}
235 class _AsyncStarStreamController {}
236 Object _asyncStackTraceHelper(Function async_op) { }
237 Function _asyncThenWrapperHelper(continuation) {}
238 Function _asyncErrorWrapperHelper(continuation) {}
239 Future _awaitHelper(
240 object, Function thenCallback, Function errorCallback, var awaiter) {}
241 ''');
242 271
243 addSdkLibrary('collection', 'library dart.collection;'); 272 addSdkLibrary('collection', 'library dart.collection;');
244 addSdkLibrary('convert', 'library dart.convert;'); 273 addSdkLibrary('convert', 'library dart.convert;');
245 addSdkLibrary('developer', 'library dart.developer;'); 274 addSdkLibrary('developer', 'library dart.developer;');
246 addSdkLibrary('io', 'library dart.io;'); 275 addSdkLibrary('io', 'library dart.io;');
247 addSdkLibrary('isolate', 'library dart.isolate;'); 276 addSdkLibrary('isolate', 'library dart.isolate;');
248 addSdkLibrary('math', ''' 277 addSdkLibrary('math', '''
249 library dart.math; 278 library dart.math;
250 external double sin(num radians); 279 external double sin(num radians);
251 '''); 280 ''');
252 addSdkLibrary('mirrors', 'library dart.mirrors;'); 281 addSdkLibrary('mirrors', 'library dart.mirrors;');
253 addSdkLibrary('nativewrappers', 'library dart.nativewrappers;'); 282 addSdkLibrary('nativewrappers', 'library dart.nativewrappers;');
254 addSdkLibrary('profiler', 'library dart.profiler;'); 283 addSdkLibrary('profiler', 'library dart.profiler;');
255 addSdkLibrary('typed_data', 'library dart.typed_data;'); 284 addSdkLibrary('typed_data', 'library dart.typed_data;');
256 addSdkLibrary('vmservice_io', 'library dart.vmservice_io;');
257 addSdkLibrary('_builtin', 'library dart._builtin;'); 285 addSdkLibrary('_builtin', 'library dart._builtin;');
258 addSdkLibrary('_internal', ''' 286 addSdkLibrary('_internal', '''
259 library dart._internal; 287 library dart._internal;
260 class Symbol {} 288 class Symbol {}
261 class ExternalName { 289 class ExternalName {
262 final String name; 290 final String name;
263 const ExternalName(this.name); 291 const ExternalName(this.name);
264 } 292 }
265 '''); 293 ''');
266 addSdkLibrary('_vmservice', 'library dart._vmservice;');
267 294
268 return dartLibraries; 295 return dartLibraries;
269 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698