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