@@ -38,24 +38,24 @@ private let freestandingLibrarySourceRoot = hostedLibrarySourceRoot.appendingPat
38
38
39
39
extension Utils . Host {
40
40
41
+ /// Returns an AST representing the given standard library `variant` (either `"freestanding"` or
42
+ /// `"hosted"`), conditionally compiled for targeting the host platform.
43
+ private static func libraryAST( _ variant: String ) -> Result < AST , Error > {
44
+ Result {
45
+ try CBORDecoder ( ) . forAST. decode (
46
+ AST . self,
47
+ from: Data (
48
+ contentsOf: resource ( variant, withExtension: " cbor " ) ,
49
+ options: . alwaysMapped) )
50
+ }
51
+ }
52
+
41
53
/// An AST representing the whole standard library, conditionally compiled for targeting the host
42
54
/// platform.
43
- public static let hostedLibraryAST = Result {
44
- try CBORDecoder ( ) . forAST. decode (
45
- AST . self,
46
- from: Data (
47
- contentsOf: resource ( " hosted " , withExtension: " cbor " ) ,
48
- options: . alwaysMapped) )
49
- }
55
+ public static let hostedLibraryAST : Result < AST , Error > = libraryAST ( " hosted " )
50
56
51
57
/// An AST representing the freestanding core of standard library, conditionally compiled for
52
58
/// targeting the host platform.
53
- public static let freestandingLibraryAST = Result {
54
- try CBORDecoder ( ) . forAST. decode (
55
- AST . self,
56
- from: Data (
57
- contentsOf: resource ( " freestanding " , withExtension: " cbor " ) ,
58
- options: . alwaysMapped) )
59
- }
59
+ public static let freestandingLibraryAST : Result < AST , Error > = libraryAST ( " freestanding " )
60
60
61
61
}
0 commit comments