File tree Expand file tree Collapse file tree 5 files changed +42
-9
lines changed Expand file tree Collapse file tree 5 files changed +42
-9
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,6 @@ extension Bool: Hashable {
197197 }
198198}
199199
200- @_unavailableInEmbedded
201200extension Bool : LosslessStringConvertible {
202201 /// Creates a new Boolean value from the given string.
203202 ///
Original file line number Diff line number Diff line change @@ -259,7 +259,7 @@ split_embedded_sources(
259259 OUT_LIST_NORMAL SWIFTLIB_GYB_SOURCES
260260
261261 NORMAL AtomicInt.swift.gyb
262- NORMAL FloatingPointParsing.swift.gyb
262+ EMBEDDED FloatingPointParsing.swift.gyb
263263 EMBEDDED FloatingPointTypes.swift.gyb
264264 EMBEDDED IntegerTypes.swift.gyb
265265 EMBEDDED LegacyInt128.swift.gyb
Original file line number Diff line number Diff line change @@ -1705,12 +1705,6 @@ extension BinaryInteger {
17051705 }
17061706}
17071707
1708- #if !$Embedded
1709- public typealias _LosslessStringConvertibleOrNone = LosslessStringConvertible
1710- #else
1711- public protocol _LosslessStringConvertibleOrNone { }
1712- #endif
1713-
17141708//===----------------------------------------------------------------------===//
17151709//===--- FixedWidthInteger ------------------------------------------------===//
17161710//===----------------------------------------------------------------------===//
@@ -1779,7 +1773,7 @@ public protocol _LosslessStringConvertibleOrNone {}
17791773/// customization points for arithmetic operations. When you provide just those
17801774/// methods, the standard library provides default implementations for all
17811775/// other arithmetic methods and operators.
1782- public protocol FixedWidthInteger : BinaryInteger , _LosslessStringConvertibleOrNone
1776+ public protocol FixedWidthInteger : BinaryInteger , LosslessStringConvertible
17831777where Magnitude: FixedWidthInteger & UnsignedInteger ,
17841778 Stride: FixedWidthInteger & SignedInteger {
17851779 /// The number of bits used for the underlying binary representation of
Original file line number Diff line number Diff line change @@ -30,8 +30,16 @@ config.environment = dict(config.environment)
3030if ' SWIFT_USE_OLD_DRIVER' in config.environment: del config.environment[' SWIFT_USE_OLD_DRIVER' ]
3131if ' SWIFT_AVOID_WARNING_USING_OLD_DRIVER' in config.environment: del config.environment[' SWIFT_AVOID_WARNING_USING_OLD_DRIVER' ]
3232
33+ target_cpu = [y for (x, y) in config.substitutions if x == " %target-cpu" ][0]
34+ target_triple = [y for (x, y) in config.substitutions if x == " %target-triple" ][0]
35+
3336# (5) Provide some useful substitutions to simplify writing tests that work across platforms (macOS, Linux, etc.)
3437if " OS=linux-gnu" in config.available_features:
3538 config.substitutions.append((" %target-embedded-link" , config.target_clang + " -x c %S/Inputs/linux-rng-support.c -x none" ))
39+ config.substitutions.append((" %embedded-unicode-tables" , f" -Xlinker {config.swift_obj_root}/lib/swift/embedded/{target_cpu}-unknown-linux-gnu/libswiftUnicodeDataTables.a" ))
40+ elif " OS=macosx" in config.available_features:
41+ config.substitutions.append((" %target-embedded-link" , config.target_clang))
42+ config.substitutions.append((" %embedded-unicode-tables" , f" -Xlinker {config.swift_obj_root}/lib/swift/embedded/{target_cpu}-apple-macos/libswiftUnicodeDataTables.a" ))
3643else:
3744 config.substitutions.append((" %target-embedded-link" , config.target_clang))
45+ config.substitutions.append((" %embedded-unicode-tables" , f" -Xlinker {config.swift_obj_root}/lib/swift/embedded/{target_triple}/libswiftUnicodeDataTables.a" ))
Original file line number Diff line number Diff line change 1+ // RUN: %target-run-simple-swift(-enable-experimental-feature Embedded -parse-as-library -wmo %embedded-unicode-tables) | %FileCheck %s
2+
3+ // REQUIRES: swift_in_compiler
4+ // REQUIRES: executable_test
5+ // REQUIRES: optimized_stdlib
6+ // REQUIRES: OS=macosx || OS=linux-gnu
7+ // REQUIRES: swift_feature_Embedded
8+
9+ func f< T: LosslessStringConvertible > ( t: inout T ? , s: String ) {
10+ t = . init( s)
11+ }
12+
13+ @main
14+ struct Main {
15+ static func main( ) {
16+ if let b = Bool . init ( " true " ) , b == true { print ( " OK 1 " ) } // CHECK: OK 1
17+ var b : Bool ?
18+ f ( t: & b, s: " false " )
19+ if let b, b == false { print ( " OK 2 " ) } // CHECK: OK 2
20+
21+ if let i = Int . init ( " 17 " ) , i == 17 { print ( " OK 3 " ) } // CHECK: OK 3
22+ var i : Int ?
23+ f ( t: & i, s: " 777 " )
24+ if let i, i == 777 { print ( " OK 4 " ) } // CHECK: OK 4
25+
26+ // TODO: Add float parsing to Embedded Swift that does not rely on libc
27+ // if let fl = Float.init("42.42"), fl == 42.42 { print("OK 5") } // XXX: OK 5
28+ // var fl: Float?
29+ // f(t: &fl, s: "12.34")
30+ // if let fl, fl == 12.34 { print("OK 6") } // XXX: OK 6
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments