| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.sdk.io; | 8 library engine.sdk.io; |
| 9 | 9 |
| 10 import 'java_core.dart'; | 10 import 'java_core.dart'; |
| 11 import 'java_io.dart'; | 11 import 'java_io.dart'; |
| 12 import 'java_engine_io.dart'; | 12 import 'java_engine_io.dart'; |
| 13 import 'source_io.dart'; | 13 import 'source_io.dart'; |
| 14 import 'error.dart'; | 14 import 'error.dart'; |
| 15 import 'scanner.dart'; | 15 import 'scanner.dart'; |
| 16 import 'ast.dart'; | 16 import 'ast.dart'; |
| 17 import 'parser.dart'; | 17 import 'parser.dart'; |
| 18 import 'sdk.dart'; | 18 import 'sdk.dart'; |
| 19 import 'engine.dart'; | 19 import 'engine.dart'; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Instances of the class `SdkLibrariesReader` read and parse the libraries file |
| 23 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The |
| 24 * library information is represented as a Dart file containing a single top-lev
el variable whose |
| 25 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the |
| 26 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK |
| 27 * might have a libraries file that looks like the following: |
| 28 * |
| 29 * <pre> |
| 30 * final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { |
| 31 * // Used by VM applications |
| 32 * "builtin" : const LibraryInfo( |
| 33 * "builtin/builtin_runtime.dart", |
| 34 * category: "Server", |
| 35 * platforms: VM_PLATFORM), |
| 36 * |
| 37 * "compiler" : const LibraryInfo( |
| 38 * "compiler/compiler.dart", |
| 39 * category: "Tools", |
| 40 * platforms: 0), |
| 41 * }; |
| 42 * </pre> |
| 43 */ |
| 44 class SdkLibrariesReader { |
| 45 /** |
| 46 * A flag indicating whether the dart2js path should be used when it is availa
ble. |
| 47 */ |
| 48 final bool _useDart2jsPaths; |
| 49 |
| 50 /** |
| 51 * Initialize a newly created library reader to use the dart2js path if the gi
ven value is |
| 52 * `true`. |
| 53 * |
| 54 * @param useDart2jsPaths `true` if the dart2js path should be used when it is
available |
| 55 */ |
| 56 SdkLibrariesReader(this._useDart2jsPaths); |
| 57 |
| 58 /** |
| 59 * Return the library map read from the given source. |
| 60 * |
| 61 * @param file the [File] of the library file |
| 62 * @param libraryFileContents the contents from the library file |
| 63 * @return the library map read from the given source |
| 64 */ |
| 65 LibraryMap readFromFile(JavaFile file, String libraryFileContents) => readFrom
Source(new FileBasedSource.con2(file, UriKind.FILE_URI), libraryFileContents); |
| 66 |
| 67 /** |
| 68 * Return the library map read from the given source. |
| 69 * |
| 70 * @param source the source of the library file |
| 71 * @param libraryFileContents the contents from the library file |
| 72 * @return the library map read from the given source |
| 73 */ |
| 74 LibraryMap readFromSource(Source source, String libraryFileContents) { |
| 75 BooleanErrorListener errorListener = new BooleanErrorListener(); |
| 76 Scanner scanner = new Scanner(source, new CharSequenceReader(libraryFileCont
ents), errorListener); |
| 77 Parser parser = new Parser(source, errorListener); |
| 78 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); |
| 79 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(_useDart2jsPaths); |
| 80 // If any syntactic errors were found then don't try to visit the AST struct
ure. |
| 81 if (!errorListener.errorReported) { |
| 82 unit.accept(libraryBuilder); |
| 83 } |
| 84 return libraryBuilder.librariesMap; |
| 85 } |
| 86 } |
| 87 |
| 88 /** |
| 22 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed
in a | 89 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed
in a |
| 23 * specified directory. Typical Dart SDK layout is something like... | 90 * specified directory. Typical Dart SDK layout is something like... |
| 24 * | 91 * |
| 25 * <pre> | 92 * <pre> |
| 26 * dart-sdk/ | 93 * dart-sdk/ |
| 27 * bin/ | 94 * bin/ |
| 28 * dart[.exe] <-- VM | 95 * dart[.exe] <-- VM |
| 29 * lib/ | 96 * lib/ |
| 30 * core/ | 97 * core/ |
| 31 * core.dart | 98 * core.dart |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 } | 544 } |
| 478 } | 545 } |
| 479 | 546 |
| 480 /** | 547 /** |
| 481 * Verify that the given executable file exists and is executable. | 548 * Verify that the given executable file exists and is executable. |
| 482 * | 549 * |
| 483 * @param file the binary file | 550 * @param file the binary file |
| 484 * @return the file if it exists and is executable, else `null` | 551 * @return the file if it exists and is executable, else `null` |
| 485 */ | 552 */ |
| 486 JavaFile _verifyExecutable(JavaFile file) => file.isExecutable() ? file : null
; | 553 JavaFile _verifyExecutable(JavaFile file) => file.isExecutable() ? file : null
; |
| 487 } | |
| 488 | |
| 489 /** | |
| 490 * Instances of the class `SdkLibrariesReader` read and parse the libraries file | |
| 491 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The | |
| 492 * library information is represented as a Dart file containing a single top-lev
el variable whose | |
| 493 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the | |
| 494 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK | |
| 495 * might have a libraries file that looks like the following: | |
| 496 * | |
| 497 * <pre> | |
| 498 * final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { | |
| 499 * // Used by VM applications | |
| 500 * "builtin" : const LibraryInfo( | |
| 501 * "builtin/builtin_runtime.dart", | |
| 502 * category: "Server", | |
| 503 * platforms: VM_PLATFORM), | |
| 504 * | |
| 505 * "compiler" : const LibraryInfo( | |
| 506 * "compiler/compiler.dart", | |
| 507 * category: "Tools", | |
| 508 * platforms: 0), | |
| 509 * }; | |
| 510 * </pre> | |
| 511 */ | |
| 512 class SdkLibrariesReader { | |
| 513 /** | |
| 514 * A flag indicating whether the dart2js path should be used when it is availa
ble. | |
| 515 */ | |
| 516 final bool _useDart2jsPaths; | |
| 517 | |
| 518 /** | |
| 519 * Initialize a newly created library reader to use the dart2js path if the gi
ven value is | |
| 520 * `true`. | |
| 521 * | |
| 522 * @param useDart2jsPaths `true` if the dart2js path should be used when it is
available | |
| 523 */ | |
| 524 SdkLibrariesReader(this._useDart2jsPaths); | |
| 525 | |
| 526 /** | |
| 527 * Return the library map read from the given source. | |
| 528 * | |
| 529 * @param file the [File] of the library file | |
| 530 * @param libraryFileContents the contents from the library file | |
| 531 * @return the library map read from the given source | |
| 532 */ | |
| 533 LibraryMap readFromFile(JavaFile file, String libraryFileContents) => readFrom
Source(new FileBasedSource.con2(file, UriKind.FILE_URI), libraryFileContents); | |
| 534 | |
| 535 /** | |
| 536 * Return the library map read from the given source. | |
| 537 * | |
| 538 * @param source the source of the library file | |
| 539 * @param libraryFileContents the contents from the library file | |
| 540 * @return the library map read from the given source | |
| 541 */ | |
| 542 LibraryMap readFromSource(Source source, String libraryFileContents) { | |
| 543 BooleanErrorListener errorListener = new BooleanErrorListener(); | |
| 544 Scanner scanner = new Scanner(source, new CharSequenceReader(libraryFileCont
ents), errorListener); | |
| 545 Parser parser = new Parser(source, errorListener); | |
| 546 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); | |
| 547 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(_useDart2jsPaths); | |
| 548 // If any syntactic errors were found then don't try to visit the AST struct
ure. | |
| 549 if (!errorListener.errorReported) { | |
| 550 unit.accept(libraryBuilder); | |
| 551 } | |
| 552 return libraryBuilder.librariesMap; | |
| 553 } | |
| 554 } | 554 } |
| OLD | NEW |