| OLD | NEW |
| 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 /// 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 | 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`. | 9 /// in the given [fileSystem]. The root of the SDK is `file:///sdk`. |
| 10 Map<String, Uri> createSdkFiles(MemoryFileSystem fileSystem) { | 10 Map<String, Uri> createSdkFiles(MemoryFileSystem fileSystem) { |
| 11 Map<String, Uri> dartLibraries = {}; | 11 Map<String, Uri> dartLibraries = {}; |
| 12 | 12 |
| 13 void addSdkLibrary(String name, String contents) { | 13 void addSdkLibrary(String name, String contents) { |
| 14 String path = '$name/$name.dart'; | 14 String path = '$name/$name.dart'; |
| 15 Uri uri = Uri.parse('file:///sdk/lib/$path'); | 15 Uri uri = Uri.parse('file:///sdk/lib/$path'); |
| 16 fileSystem.entityForUri(uri).writeAsStringSync(contents); | 16 fileSystem.entityForUri(uri).writeAsStringSync(contents); |
| 17 dartLibraries[name] = uri; | 17 dartLibraries[name] = uri; |
| 18 } | 18 } |
| 19 | 19 |
| 20 addSdkLibrary( | 20 addSdkLibrary('core', r''' |
| 21 'core', | |
| 22 r''' | |
| 23 library dart.core; | 21 library dart.core; |
| 24 import 'dart:_internal'; | 22 import 'dart:_internal'; |
| 25 import 'dart:async'; | 23 import 'dart:async'; |
| 26 | 24 |
| 27 class Object { | 25 class Object { |
| 28 const Object(); | 26 const Object(); |
| 29 bool operator ==(other) => identical(this, other); | 27 bool operator ==(other) => identical(this, other); |
| 30 String toString() => 'a string'; | 28 String toString() => 'a string'; |
| 31 int get hashCode => 0; | 29 int get hashCode => 0; |
| 32 Type get runtimeType => null; | 30 Type get runtimeType => null; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 195 |
| 198 class Duration implements Comparable<Duration> {} | 196 class Duration implements Comparable<Duration> {} |
| 199 | 197 |
| 200 external bool identical(Object a, Object b); | 198 external bool identical(Object a, Object b); |
| 201 | 199 |
| 202 void print(Object o) {} | 200 void print(Object o) {} |
| 203 | 201 |
| 204 abstract class _SyncIterable implements Iterable {} | 202 abstract class _SyncIterable implements Iterable {} |
| 205 '''); | 203 '''); |
| 206 | 204 |
| 207 addSdkLibrary( | 205 addSdkLibrary('async', r''' |
| 208 'async', | |
| 209 r''' | |
| 210 library dart.async; | 206 library dart.async; |
| 211 | 207 |
| 212 class Future<T> { | 208 class Future<T> { |
| 213 factory Future(computation()) => null; | 209 factory Future(computation()) => null; |
| 214 factory Future.delayed(Duration duration, [T computation()]) => null; | 210 factory Future.delayed(Duration duration, [T computation()]) => null; |
| 215 factory Future.microtask(FutureOr<T> computation()) => null; | 211 factory Future.microtask(FutureOr<T> computation()) => null; |
| 216 factory Future.value([value]) => null; | 212 factory Future.value([value]) => null; |
| 217 | 213 |
| 218 static Future<List<T>> wait<T>(Iterable<Future<T>> futures) => null; | 214 static Future<List<T>> wait<T>(Iterable<Future<T>> futures) => null; |
| 219 Future<R> then<R>(FutureOr<R> onValue(T value)) => null; | 215 Future<R> then<R>(FutureOr<R> onValue(T value)) => null; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 241 Function _asyncErrorWrapperHelper(continuation) {} | 237 Function _asyncErrorWrapperHelper(continuation) {} |
| 242 Future _awaitHelper( | 238 Future _awaitHelper( |
| 243 object, Function thenCallback, Function errorCallback, var awaiter) {} | 239 object, Function thenCallback, Function errorCallback, var awaiter) {} |
| 244 '''); | 240 '''); |
| 245 | 241 |
| 246 addSdkLibrary('collection', 'library dart.collection;'); | 242 addSdkLibrary('collection', 'library dart.collection;'); |
| 247 addSdkLibrary('convert', 'library dart.convert;'); | 243 addSdkLibrary('convert', 'library dart.convert;'); |
| 248 addSdkLibrary('developer', 'library dart.developer;'); | 244 addSdkLibrary('developer', 'library dart.developer;'); |
| 249 addSdkLibrary('io', 'library dart.io;'); | 245 addSdkLibrary('io', 'library dart.io;'); |
| 250 addSdkLibrary('isolate', 'library dart.isolate;'); | 246 addSdkLibrary('isolate', 'library dart.isolate;'); |
| 251 addSdkLibrary( | 247 addSdkLibrary('math', ''' |
| 252 'math', | |
| 253 ''' | |
| 254 library dart.math; | 248 library dart.math; |
| 255 external double sin(num radians); | 249 external double sin(num radians); |
| 256 '''); | 250 '''); |
| 257 addSdkLibrary('mirrors', 'library dart.mirrors;'); | 251 addSdkLibrary('mirrors', 'library dart.mirrors;'); |
| 258 addSdkLibrary('nativewrappers', 'library dart.nativewrappers;'); | 252 addSdkLibrary('nativewrappers', 'library dart.nativewrappers;'); |
| 259 addSdkLibrary('profiler', 'library dart.profiler;'); | 253 addSdkLibrary('profiler', 'library dart.profiler;'); |
| 260 addSdkLibrary('typed_data', 'library dart.typed_data;'); | 254 addSdkLibrary('typed_data', 'library dart.typed_data;'); |
| 261 addSdkLibrary('vmservice_io', 'library dart.vmservice_io;'); | 255 addSdkLibrary('vmservice_io', 'library dart.vmservice_io;'); |
| 262 addSdkLibrary('_builtin', 'library dart._builtin;'); | 256 addSdkLibrary('_builtin', 'library dart._builtin;'); |
| 263 addSdkLibrary( | 257 addSdkLibrary('_internal', ''' |
| 264 '_internal', | |
| 265 ''' | |
| 266 library dart._internal; | 258 library dart._internal; |
| 267 class Symbol {} | 259 class Symbol {} |
| 268 class ExternalName { | 260 class ExternalName { |
| 269 final String name; | 261 final String name; |
| 270 const ExternalName(this.name); | 262 const ExternalName(this.name); |
| 271 } | 263 } |
| 272 '''); | 264 '''); |
| 273 addSdkLibrary('_vmservice', 'library dart._vmservice;'); | 265 addSdkLibrary('_vmservice', 'library dart._vmservice;'); |
| 274 | 266 |
| 275 return dartLibraries; | 267 return dartLibraries; |
| 276 } | 268 } |
| OLD | NEW |