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 import 'package:front_end/src/base/libraries_specification.dart'; |
6 | 7 |
7 /// Create SDK libraries which are used by Fasta to perform kernel generation. | 8 /// 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 /// The root of the SDK is `file:///sdk`, it will contain a libraries |
9 /// in the given [fileSystem]. The root of the SDK is `file:///sdk`. | 10 /// specification file at `lib/libraries.json`. |
10 Map<String, Uri> createSdkFiles(MemoryFileSystem fileSystem) { | 11 /// |
11 Map<String, Uri> dartLibraries = {}; | 12 /// Returns the [TargetLibrariesSpecification] whose contents are in |
12 | 13 /// libraries.json. |
| 14 TargetLibrariesSpecification createSdkFiles(MemoryFileSystem fileSystem) { |
| 15 Map<String, LibraryInfo> dartLibraries = {}; |
13 void addSdkLibrary(String name, String contents) { | 16 void addSdkLibrary(String name, String contents) { |
14 String path = '$name/$name.dart'; | 17 String path = '$name/$name.dart'; |
15 Uri uri = Uri.parse('file:///sdk/lib/$path'); | 18 Uri uri = Uri.parse('file:///sdk/lib/$path'); |
16 fileSystem.entityForUri(uri).writeAsStringSync(contents); | 19 fileSystem.entityForUri(uri).writeAsStringSync(contents); |
17 dartLibraries[name] = uri; | 20 dartLibraries[name] = new LibraryInfo(name, uri, const []); |
18 } | 21 } |
19 | 22 |
20 addSdkLibrary('core', r''' | 23 addSdkLibrary('core', r''' |
21 library dart.core; | 24 library dart.core; |
22 import 'dart:_internal'; | 25 import 'dart:_internal'; |
23 import 'dart:async'; | 26 import 'dart:async'; |
24 | 27 |
25 class Object { | 28 class Object { |
26 const Object(); | 29 const Object(); |
27 bool operator ==(other) => identical(this, other); | 30 bool operator ==(other) => identical(this, other); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 addSdkLibrary('_internal', ''' | 261 addSdkLibrary('_internal', ''' |
259 library dart._internal; | 262 library dart._internal; |
260 class Symbol {} | 263 class Symbol {} |
261 class ExternalName { | 264 class ExternalName { |
262 final String name; | 265 final String name; |
263 const ExternalName(this.name); | 266 const ExternalName(this.name); |
264 } | 267 } |
265 '''); | 268 '''); |
266 addSdkLibrary('_vmservice', 'library dart._vmservice;'); | 269 addSdkLibrary('_vmservice', 'library dart._vmservice;'); |
267 | 270 |
268 return dartLibraries; | 271 var targetSpec = new TargetLibrariesSpecification('vm', dartLibraries); |
| 272 var spec = new LibrariesSpecification({'vm': targetSpec}); |
| 273 |
| 274 Uri uri = Uri.parse('file:///sdk/lib/libraries.json'); |
| 275 fileSystem.entityForUri(uri).writeAsStringSync(spec.toJsonString(uri)); |
| 276 return targetSpec; |
269 } | 277 } |
OLD | NEW |