Commit Graph

214 Commits

Author SHA1 Message Date
Maxim Moiseev
47e78c071a Merge pull request #11044 from apple/rationalize-bitshifting
[stdlib] Rationalize bitshifting in protocols
2017-07-27 14:50:14 -07:00
swift-ci
92898618cb Merge pull request #10982 from apple/stdlib-swift4-modernization 2017-07-20 18:56:23 -07:00
Dave Abrahams
33e9ec4690 [stdlib] Rationalize bitshifting in protocols
Only FixedWidthInteger, not BinaryInteger, should have masking shifts.
BinaryInteger should have a non-masking shift requirement.

Removed some dead code.
2017-07-18 16:00:44 -07:00
Dave Abrahams
fb35257511 [stdlib] Drop some @available(introduced:...)
These annotations make it hard to write code that works in both Swift 3 and Swift 4, so if they aren't needed we should remove them.
2017-07-16 07:22:09 -07:00
Dave Abrahams
c497969987 [stdlib] Swift4 Modernizations Compatible with Swift 3.2 2017-07-14 17:54:33 -07:00
Károly Lőrentey
9996d071c4 [stdlib] Define custom Words types for each standard fixed with integer
This adds 8 more collection views, but makes integer definitions
more consistent across all the available bit widths and
between 32-bit and 64-bit platforms.
2017-07-11 04:53:23 +02:00
Károly Lőrentey
735fe97242 [stdlib] Fix sign extension in word -> multi-word integer conversions
This fixes integer conversion issues on 32-bit platforms.
2017-07-11 04:33:14 +02:00
Károly Lőrentey
e975445b70 [stdlib] Make UInt.Words.var internal
We don’t need Words’ members to be @_transparent;
simple conversions use _lowWord instead.
2017-07-11 03:26:20 +02:00
Károly Lőrentey
1dccb45278 [stdlib] Revert @_transparent to prevent SIL size explosion 2017-07-11 03:17:56 +02:00
Károly Lőrentey
826f8daf4a [stdlib] _lowUWord => _lowWord 2017-07-10 22:40:52 +02:00
Károly Lőrentey
c8d4fd4242 [stdlib] Remove BinaryInteger._word(at:)
Removes BinaryInteger's _word(at:) requirement and its
countOfRepresentedWords property, making the words property the
sole way to access an integer's words.

This is a better fix for https://bugs.swift.org/browse/SR-5275.
2017-07-10 22:40:52 +02:00
Károly Lőrentey
7836268d45 [stdlib] Implement BinaryInteger.words in standard integer types.
Introduces the following new collection types as lightweight
views of a corresponding integer value:

- UInt.Words
- UInt64.Words (on 32-bit platforms)
- DoubleWidth.Words

The rest of the standard integer types define Words as a typealias
to one of the first two of these, based on their width.
2017-07-10 19:03:34 +02:00
Xiaodi Wu
3916380e7c Prefix countRepresentedWords with underscore [NFC]
Per comments, `countRepresentedWords` is slated for eventual removal along with `_words(at:)`; it's not a part of SE-0104, so let's show users that it's not intended for public consumption.
2017-06-21 20:01:14 -05:00
Max Moiseev
42e8491080 [stdlib] Default implementation for BinaryInteger._word(at:)
Temporarily addresses https://bugs.swift.org/browse/SR-5275
2017-06-21 13:46:16 -07:00
Maxim Moiseev
651aaa8b54 Merge pull request #10206 from moiseev/unambiguous-bitpattern
[stdlib] Resolve the ambiguity for Int32.init(bitPattern:)
2017-06-14 11:34:32 -07:00
Max Moiseev
90a20ea015 [stdlib] Resolve the ambiguity for Int32.init(bitPattern:)
When this initializer is invoked with an integer literal, the expression
is ambiguous, since both UIn32 and Float are
RepresentableByIntegerLiteral.

Fixes: https://bugs.swift.org/browse/SR-5176
2017-06-13 17:28:19 -07:00
Nate Cook
b7af9bfe83 [stdlib] Remove SeeAlso tags 2017-06-13 11:23:51 -05:00
Nate Cook
6133adc413 [stdlib] Move DoubleWidth into its own file 2017-06-06 08:54:15 -07:00
Maxim Moiseev
0c108340d1 Merge pull request #9367 from natecook1000/nc-doublewidth
[stdlib] DoubleWidth Implementation
2017-06-05 10:03:42 -07:00
Roman Levenstein
00d663d172 [sil-generic-specializer] Add @_semantics("optimize.sil.specialize.generic.partial.never") to disable partial specialization on functions
This new @_semantics is used to annotate some very big functions in the standard library. It reduced the code size of the stdlib by 2%.
2017-06-01 16:33:18 -07:00
Nate Cook
42efcdb246 One more from @xwu + 80-column fixes 2017-06-01 12:53:05 -05:00
Max Moiseev
53004a1015 [stdlib] Renames and tests for Swift 3 compatibility mode
Addresses <rdar://problem/32432481>
2017-05-26 16:28:11 -07:00
Nate Cook
2612e00eaf Additional notes from @xwu 2017-05-26 08:46:42 -05:00
Nate Cook
2f9bf3cb1c Add an abstract for DoubleWidth 2017-05-25 18:38:45 -05:00
Nate Cook
1149eeac16 Incorporate feedback from @moiseev
- Also clean up some 80-column issues
- And improve some tests from before literal expressibility
2017-05-25 18:32:15 -05:00
Nate Cook
237d8775dc Catch overflow into high bit in signed multiplication 2017-05-25 15:04:34 -05:00
Nate Cook
e5fb87128e Revert multipliedFullWidth for 64-bit ints on 32-bit platforms 2017-05-25 03:47:52 -05:00
Nate Cook
5ab34bf6f0 Add floating-point initializers and tests 2017-05-24 19:16:26 -05:00
Nate Cook
06490e6a44 Shortcut on binary division 2017-05-24 19:16:26 -05:00
Nate Cook
7353042a4f Fix overflow issue 2017-05-24 19:16:26 -05:00
Nate Cook
1e59f65a91 Implement tricky full-width multiply/divides 2017-05-24 19:16:26 -05:00
Nate Cook
2edbb085d0 Fix overflow issues 2017-05-24 19:16:26 -05:00
Nate Cook
788f4e81b6 Add recursive constraints for integer Magnitude 2017-05-24 19:16:26 -05:00
Nate Cook
b935be828c Remove endian operations from fixed-width ints 2017-05-24 19:16:26 -05:00
Nate Cook
b72449bc72 Provide implementations or masking bitshift operators 2017-05-24 19:16:26 -05:00
Nate Cook
a539919052 Add negation operator/method to DoubleWidth 2017-05-24 19:16:26 -05:00
Nate Cook
c866bcf3d4 Convert endian symbols to default implementations 2017-05-24 19:16:26 -05:00
Nate Cook
b2676f90ca Use literals instead of DoubleWidth inits 2017-05-24 19:16:26 -05:00
Nate Cook
8926df9bbc [stdlib] Partial implementation of DoubleWidth 2017-05-24 19:16:26 -05:00
Xiaodi Wu
afa4e12fa6 Refine wording in doc comment 2017-05-23 21:10:04 -05:00
Xiaodi Wu
e30a003bca Update BinaryInteger default initializer documentation
Some time ago, it was pointed out that "truncating" would be used only for bit pattern operations. As pointed out on Swift Evolution, this is the only spot where the same term is used for dropping the fractional part of a floating point value; elsewhere, it is always spelled--even in documentation--as "rounded toward zero." This PR updates the usage here to align with existing convention.
2017-05-23 21:07:16 -05:00
Max Moiseev
368847b5c7 [stdlib] Providing fixits for IntMax and UIntMax 2017-05-18 18:00:45 -07:00
Maxim Moiseev
130231456b Merge pull request #9714 from moiseev/int-perf
[stdlib] Speeding up typechecking for complex expressions with integers
2017-05-17 17:33:47 -07:00
Max Moiseev
fa0904f1e5 [stdlib] Adding operator overloads on concrete integer types
It looks like the compiler is having troubles with the pattern when the
non-mutaing operator is defined on the protocol, and delegates to the
mutating version, that is provided by the concrete type. Adding similar
definitions of non-mutating operators to concrete types significantly
speeds up the typechecking of complex expressions, like the one in
the ByteSwap benchmark.
2017-05-17 15:56:17 -07:00
Maxim Moiseev
a2a4a52bdf [stdlib] SignedNumber to refine Comparable in Swift 3 mode (#9668)
Fixes: https://bugs.swift.org/browse/SR-4899
2017-05-17 12:43:00 -07:00
swift-ci
a61b981cd9 Merge pull request #9610 from moiseev/no-init 2017-05-15 12:04:22 -07:00
Ben Cohen
ea2f64cad2 [stdlib] Add Sequence.Element, change ExpressibleByArrayLiteral.Element to ArrayLiteralElement (#8990)
* Give Sequence a top-level Element, constrain Iterator to match

* Remove many instances of Iterator.

* Fixed various hard-coded tests

* XFAIL a few tests that need further investigation

* Change assoc type for arrayLiteralConvertible

* Mop up remaining "better expressed as a where clause" warnings

* Fix UnicodeDecoders prototype test

* Fix UIntBuffer

* Fix hard-coded Element identifier in CSDiag

* Fix up more tests

* Account for flatMap changes
2017-05-14 06:33:25 -07:00
Max Moiseev
0a466e3ca0 Revert "[stdlib] Implementing copy constructors for integer types"
This reverts commit 3f0d1e61aa.

The copy constructors don't really solve any problems, but produce extra
work for the overload resolution.
2017-05-13 12:27:43 -07:00
Nate Cook
7fa74f590d [stdlib] Documentation revisions for string + ranges
* removing .characters from examples
* beginning new String doc revisions
* improvements to the String Foundation overlay docs
* minor revisions elsewhere
2017-05-13 10:06:05 -05:00
Nate Cook
7ec9e95b49 [stdlib] Documentation revisions for numeric types
* abstracts for integer types
* fixed discussions for floating-point operators
2017-05-13 10:06:00 -05:00