File tree 5 files changed +42
-9
lines changed
5 files changed +42
-9
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,6 @@ extension Bool: Hashable {
197
197
}
198
198
}
199
199
200
- @_unavailableInEmbedded
201
200
extension Bool : LosslessStringConvertible {
202
201
/// Creates a new Boolean value from the given string.
203
202
///
Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ split_embedded_sources(
252
252
OUT_LIST_NORMAL SWIFTLIB_GYB_SOURCES
253
253
254
254
NORMAL AtomicInt.swift.gyb
255
- NORMAL FloatingPointParsing.swift.gyb
255
+ EMBEDDED FloatingPointParsing.swift.gyb
256
256
EMBEDDED FloatingPointTypes.swift.gyb
257
257
EMBEDDED IntegerTypes.swift.gyb
258
258
EMBEDDED LegacyInt128.swift.gyb
Original file line number Diff line number Diff line change @@ -1705,12 +1705,6 @@ extension BinaryInteger {
1705
1705
}
1706
1706
}
1707
1707
1708
- #if !$Embedded
1709
- public typealias _LosslessStringConvertibleOrNone = LosslessStringConvertible
1710
- #else
1711
- public protocol _LosslessStringConvertibleOrNone { }
1712
- #endif
1713
-
1714
1708
//===----------------------------------------------------------------------===//
1715
1709
//===--- FixedWidthInteger ------------------------------------------------===//
1716
1710
//===----------------------------------------------------------------------===//
@@ -1779,7 +1773,7 @@ public protocol _LosslessStringConvertibleOrNone {}
1779
1773
/// customization points for arithmetic operations. When you provide just those
1780
1774
/// methods, the standard library provides default implementations for all
1781
1775
/// other arithmetic methods and operators.
1782
- public protocol FixedWidthInteger : BinaryInteger , _LosslessStringConvertibleOrNone
1776
+ public protocol FixedWidthInteger : BinaryInteger , LosslessStringConvertible
1783
1777
where Magnitude: FixedWidthInteger & UnsignedInteger ,
1784
1778
Stride: FixedWidthInteger & SignedInteger {
1785
1779
/// 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)
30
30
if ' SWIFT_USE_OLD_DRIVER' in config.environment: del config.environment[' SWIFT_USE_OLD_DRIVER' ]
31
31
if ' SWIFT_AVOID_WARNING_USING_OLD_DRIVER' in config.environment: del config.environment[' SWIFT_AVOID_WARNING_USING_OLD_DRIVER' ]
32
32
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
+
33
36
# (5) Provide some useful substitutions to simplify writing tests that work across platforms (macOS, Linux, etc.)
34
37
if " OS=linux-gnu" in config.available_features:
35
38
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" ))
36
43
else:
37
44
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