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

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

Issue 2869563002: Initial version of Fasta based IncrementalKernelGenerator. (Closed)
Patch Set: Add mock SDK. Created 3 years, 7 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:front_end/memory_file_system.dart';
6
7 /// Create SDK libraries which are used by Fasta to perform kernel generation.
8 /// Return the mapping from the simple names of these library to the URIs
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
13 void addSdkLibrary(String name, String contents) {
14 String path = '$name/$name.dart';
15 Uri uri = Uri.parse('file:///sdk/lib/$path');
16 fileSystem.entityForUri(uri).writeAsStringSync(contents);
17 dartLibraries[name] = uri;
18 }
19
20 addSdkLibrary(
21 'core',
22 r'''
23 library dart.core;
24 import 'dart:_internal';
25 import 'dart:async';
26
27 class Object {
28 const Object();
29 }
30
31 class Null {}
32 class Symbol {}
33 class Type {}
34 class Function {}
35 class Invocation {}
36 class StackTrace {}
37 class bool {}
38 class String {}
39 class num {}
40 class int extends num {}
41 class double {}
42 class Iterable<T> {}
43 class Iterator<T> {}
44 class List<T> extends Iterable<T> {}
45 class Map<K, V> {}
46
47 void print(Object o) {}
48
49 abstract class _SyncIterable implements Iterable {}
50 ''');
51
52 addSdkLibrary(
53 'async',
54 r'''
55 library dart.async;
56
57 class Future<T> {
58 factory Future.microtask(FutureOr<T> computation()) => null;
59 }
60
61 class FutureOr<T> {}
62 class Stream<T> {}
63 abstract class StreamIterator<T> {}
64
65 abstract class Completer<T> {
66 factory Completer() => null;
67 factory Completer.sync() => null;
68 Future<T> get future;
69 void complete([FutureOr<T> value]);
70 void completeError(Object error, [StackTrace stackTrace]);
71 bool get isCompleted;
72 }
73
74 class _StreamIterator<T> implements StreamIterator<T> {}
75 class _AsyncStarStreamController {}
76 Function _asyncThenWrapperHelper(continuation) {}
77 Function _asyncErrorWrapperHelper(continuation) {}
78 Future _awaitHelper(
79 object, Function thenCallback, Function errorCallback, var awaiter) {}
80 ''');
81
82 addSdkLibrary('collection', 'library dart.collection;');
83 addSdkLibrary('convert', 'library dart.convert;');
84 addSdkLibrary('developer', 'library dart.developer;');
85 addSdkLibrary('io', 'library dart.io;');
86 addSdkLibrary('isolate', 'library dart.isolate;');
87 addSdkLibrary('math', 'library dart.math;');
88 addSdkLibrary('mirrors', 'library dart.mirrors;');
89 addSdkLibrary('nativewrappers', 'library dart.nativewrappers;');
90 addSdkLibrary('profiler', 'library dart.profiler;');
91 addSdkLibrary('typed_data', 'library dart.typed_data;');
92 addSdkLibrary('vmservice_io', 'library dart.vmservice_io;');
93 addSdkLibrary('_builtin', 'library dart._builtin;');
94 addSdkLibrary('_internal', 'library dart._internal; class Symbol {}');
95 addSdkLibrary('_vmservice', 'library dart._vmservice;');
96
97 return dartLibraries;
98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698