Commit Graph

5543 Commits

Author SHA1 Message Date
Dave Abrahams
9421aa8db7 [stdlib] Expose base of the new reverse indices
Swift SVN r30550
2015-07-23 21:02:41 +00:00
Dmitri Hrybenko
ce71984eb8 stdlib: add the missing initializer to NonObjectiveCBase
rdar://20321708

Swift SVN r30527
2015-07-23 05:21:43 +00:00
David Farler
9aa5ff1743 Clarify SequenceType.forEach's doc comment
- Add notes for the differences between forEach and for-in loops
- Use TSPL terminology

Swift SVN r30511
2015-07-22 22:56:14 +00:00
Chris Lattner
0001dc27bb remove support for the experiemental "character literals" feature.
Swift SVN r30509
2015-07-22 22:35:19 +00:00
Slava Pestov
05d695f192 stdlib: Fix Linux build breakage from r30493
Swift SVN r30502
2015-07-22 20:38:02 +00:00
Dave Abrahams
7578e2d568 [stdlib] underscore names that were prematurely not underscored
They need to go through API review first.

Swift SVN r30497
2015-07-22 15:43:39 +00:00
David Farler
5eb9f396d6 Default removeFirst for Slice, ArraySlice
Add a default implementation for CollectionTypes where their SubSequence
== Self. That is, mainly, Slice and ArraySlice. This changes the slice's
view of, but not modifying or copying, the underlying collection.

rdar://problem/20302034

Swift SVN r30496
2015-07-22 08:07:37 +00:00
Slava Pestov
56cde6c8ec stdlib: Another simplification in HashedCollections.swift.gyb
Review feedback from Dmitri.

Swift SVN r30495
2015-07-22 07:01:48 +00:00
Slava Pestov
3175c90eac stdlib: Clean up HashedCollection FIXMEs now that generic subclasses of @objc classes work
Fixes <rdar://problem/16824792>.

Swift SVN r30493
2015-07-22 06:34:13 +00:00
Dmitri Hrybenko
0525573de7 stdlib: use syntax sugar for Array
Swift SVN r30489
2015-07-22 04:16:22 +00:00
Joe Groff
eaa1ef8e35 stdlib: Fix sign bug in Float*(integerLiteral:).
Int is signed, not unsigned, so should be converted using sitofp. Fixes rdar://problem/20467684.

Swift SVN r30487
2015-07-22 02:44:37 +00:00
Dave Abrahams
524810f579 [stdlib] Documentation touch-ups for LazyCollection
Swift SVN r30472
2015-07-21 22:35:40 +00:00
Dave Abrahams
6be395d638 [stdlib] Documentation touch-ups for flatten
Swift SVN r30471
2015-07-21 22:35:39 +00:00
Dave Abrahams
b184e6df59 [stdlib] Document complexity of flatMaps
Swift SVN r30470
2015-07-21 22:35:38 +00:00
Ted Kremenek
771761f9f6 Re-apply "stdlib: eliminate unused typealias and tidy up the doc comment""
This reverts commit r30468.

It's not clear if the original commit caused a build regression, but it appears to be resolved now.

Swift SVN r30469
2015-07-21 22:30:59 +00:00
Ted Kremenek
3f41e175b3 Revert "stdlib: eliminate unused typealias and tidy up the doc comment"
This reverts commit r30458.

This is breaking test 'Swift :: stdlib/Algorithm.swift.gyb'

Swift SVN r30468
2015-07-21 22:10:21 +00:00
Dave Abrahams
2088a71259 [stdlib] Document the lazy flatMaps
Swift SVN r30467
2015-07-21 22:01:24 +00:00
Dave Abrahams
a10ef17759 [stdlib] Document flatMap in terms of map + flatten
Swift SVN r30466
2015-07-21 22:01:23 +00:00
Dave Abrahams
e52fb0694d [stdlib] Unbalanced braces in gyb'd source makes my indentation unhappy.
Swift SVN r30465
2015-07-21 22:01:23 +00:00
Dave Abrahams
bccf396bd3 [stdlib] Lazy filter: expose critical base properties + API tweaks
The lazy components, in particular generators and indices, need to offer
access to their base values so they can be mapped back into the
underlying sequences and collections.  Along the way, give some love to:

* documentation comments
* argument labels for predicates
* not storing unneeded properties
* public constructors where appropriate

Swift SVN r30460
2015-07-21 21:22:25 +00:00
Dmitri Hrybenko
8d4866ae9b stdlib: eliminate unused typealias and tidy up the doc comment
Swift SVN r30458
2015-07-21 20:40:37 +00:00
Joe Groff
a7b65aeea1 stdlib: Use shim functions to avoid name+type collisions with CoreFoundation functions.
Fixes rdar://problem/20981649.

Swift SVN r30426
2015-07-21 01:02:04 +00:00
David Farler
ada08bdf2b SequenceType.split enhancements
- De-underscore the API that takes an equatable separator, add doc
  comment, and add a test for it.
- Add a test for the negative maxSplit case.
- Add lifetime tracker for isSeparator closure in the semantic test.

Swift SVN r30413
2015-07-20 21:34:19 +00:00
David Farler
deb69972a7 Clarify equivalence between SequenceType.forEach and for-in loops in doc comment
No functional change.

Swift SVN r30375
2015-07-18 09:08:13 +00:00
David Farler
e930494f35 Don't copy ring buffer in SequenceType.suffix
If the start of the ring buffer is aligned at the left, just wrap the
whole thing directly in an AnySequence and return it. Otherwise, return
a lazy concatenation of the the two slices of the ring buffer. This
prevents a forced full copy of the result.

rdar://problem/21885925

Swift SVN r30374
2015-07-18 09:04:56 +00:00
David Farler
0d1b03086d Add slicing extensions to SequenceType and CollectionType.
rdar://problem/21663830

Add the following new requirements to SequenceType with default implementations:

- dropFirst(n)
- dropLast(n)
- prefix(n)
- suffix(n)
- split(n)

In addition, provide specialized default implementations of these for CollectionTypes with forward, bidirectional, and random-access Index types where possible.

Add the following new requirements to CollectionType with default implementations:

- prefixThrough(n)
- prefixUpTo(n)
- suffixFrom(n)
- split() // isSeparator closure

Add the following convenience APIs:

- dropFirst() -> calls dropFirst(1)
- dropLast() -> calls dropLast(1)

Add a tentative underscored API:

- split() // takes Equatable separator.

Some APIs have undefined behavior when creating slices where the endpoints go beyond the bounds of the underlying collection. This will be fixed later by trapping creation of slices with invalid indices (rdar://problem/21822657).

Swift SVN r30371
2015-07-18 06:51:22 +00:00
Dave Abrahams
03f879bb87 [stdlib] Lazy flatMap
Addresses <rdar://problem/20138472>, can close after API review.

Swift SVN r30370
2015-07-18 06:50:27 +00:00
Dave Abrahams
8b9d9a3a25 [stdlib] LazyCollection commenting and cleanup.
Swift SVN r30368
2015-07-18 05:36:27 +00:00
Dave Abrahams
cc1ee51cc5 [stdlib] Make new Reverse*Collection not drop laziness
We used to be only propagating laziness through reverse collections when
the base collection was a LazyCollection<T>, rather than all
LazyCollectionType's. Also updated the flatten tests to check for the
same issue.

Swift SVN r30367
2015-07-18 05:36:27 +00:00
Dave Abrahams
24f930ee67 [stdlib] Add ._prext_flatten for sequences-of-sequences
Swift SVN r30361
2015-07-18 02:58:36 +00:00
Dave Abrahams
9f59c9d52d [stdlib] More lazy doc comment updates
Swift SVN r30359
2015-07-18 02:58:34 +00:00
Andrew Trick
c4f141a121 Reapply "Add test cases for isUnique sanity checks."
Handle linux.

Swift SVN r30357
2015-07-18 02:36:57 +00:00
Dmitri Hrybenko
4f6bedfc51 stdlib: mark some _HeapBuffer APIs public/@testable so that they can be used in tests
Should fix the broken buildbots.

Swift SVN r30354
2015-07-18 01:53:02 +00:00
Joe Groff
6608221a72 stdlib: Remove _UnitTestArray.
rdar://problem/20246497

Swift SVN r30348
2015-07-18 00:14:28 +00:00
Doug Gregor
89ff140503 Move the default implementation of ErrorType._domain into the standard library.
There is no reason for the compiler to be synthesizing a body of
_domain when it can be implemented in a protocol extension. As part of
this, fix a recent regression in the computed domain: it was using
string interpolation, which means that the recent changes not to print
qualified names affected the domain of the generated NSErrors. Oops.

Swift SVN r30343
2015-07-17 23:37:59 +00:00
Andrew Trick
6672ea0dbc Revert "Add test cases for isUnique sanity checks."
This reverts commit r30339.

Temporarilly remove these tests because I forgot to handle linux and
may end up reorganizing the tests.

Swift SVN r30340
2015-07-17 23:37:15 +00:00
Andrew Trick
59909cbd5a Add test cases for isUnique sanity checks.
Swift SVN r30339
2015-07-17 23:22:06 +00:00
Roman Levenstein
8624834b9e Clean-up of the stdlib file forcing pre-specializations.
- Remove public symbols.
- Only one top-level element called _Prespecialize.
- Simpler code.

Swift SVN r30333
2015-07-17 21:20:05 +00:00
Dmitri Hrybenko
4e1efd5e11 stdlib: move the implemnentation comment for AnyObject out of the doc comment
Swift SVN r30324
2015-07-17 20:25:31 +00:00
Argyrios Kyrtzidis
310d92ecc1 [stdlib] Add RawOptionSetType as unavailable with a 'renamed' fixit to OptionSetType.
rdar://21800523

Swift SVN r30313
2015-07-17 07:16:10 +00:00
Andrew Trick
e024f7fe41 Add sanity checks to the _isUnique_native API.
This is a low-level API that bypasses the usual type checks. To avoid
misuse, we add a dynamic type check that kicks in when stdlib asserts
are enabled.

Swift SVN r30311
2015-07-17 06:52:09 +00:00
Roman Levenstein
19a3821a56 Implementation of the pre-specialization for the most popular stdlib generic types.
This patch implements the pre-specialization for the most popular generic types from the standard library. If there are invocations of generic functions from the standard library in the user-code and the compiler can find the specialized, optimized versions of these functions, then calls of generic functions are simply replaced by the calls of the specialized functions.

This feature is supposed to be used with -Onone to produce much faster (e.g. 5x-10x faster) executables in debug builds without impacting the compile time. In fact, the compile-time is even improved, because IRGen has less work to do. The feature can be considered a light-weight version of the -Odebug, because pre-specialization is limited in scope, but does not have a potentially negative compile-time impact compared to -Odebug. It is planned to enable it by default in the future.

This feature is disabled by default for the time being. It can be enabled by using a hidden flag: -Xllvm -use-prespecialized.

The implementation consists of two logical steps:
- When the standard library is being built, we force a creation of specializations for the most popular generic types from the stdlib, e.g. Arrays of integer and floating point types, Range<Int>, etc. The list of specializations is not fixed and can be easily altered by editing the Prespecialized.swift file, which is responsible for forcing the specialization of generic types (this is simple solution for now, until we have a proper annotation to indicate which specializations of a given generic type or function we want to generate by means of the pre-specialization). These specializations are then optimized and preserved in the stdlib dylib and in the Swift SIL module. The size increase of the stdlib due to creation of pre-specializations is currently about 3%-7%.

- When a user-code is being compiled with -Onone, the compiler would run a generic specializer over the user-code. If there are calls of generic functions from the standard library, the specializer would check if there is an existing specialization matching these invocations. If such a specialization is found, the original call is replaced by the call of this more efficient specialized version.

Swift SVN r30309
2015-07-17 06:52:07 +00:00
Dmitri Hrybenko
85262ffeae stdlib: restore the doc comment on AnyObject
rdar://21496254

Swift SVN r30298
2015-07-17 03:11:09 +00:00
Dave Abrahams
6d3119e2a3 strip _prext_ from inside doc comments
Swift SVN r30279
2015-07-16 22:55:28 +00:00
David Farler
241de1a1c3 Add popFirst/popLast implementations for some collections
Add the following non-customizable implementations:

- popFirst/popLast for Collections whose SubSequence == Self.
- Array.popLast
- ContiguousArray.popLast
- Set.popFirst
- Dictionary.popFirst

Swift SVN r30278
2015-07-16 22:52:05 +00:00
Dave Abrahams
205ba195d5 [stdlib] Revamp doc comments for new LazySequence
Swift SVN r30277
2015-07-16 22:41:14 +00:00
Dmitri Hrybenko
e5e4335fad stdlib: Slice: trap on out-of-bounds indices
rdar://21822657

Swift SVN r30269
2015-07-16 18:22:40 +00:00
Arnold Schwaighofer
c772380f2c stdlib: Rename IsOrderedBefore to EscapingBinaryPredicate
Swift SVN r30267
2015-07-16 16:35:45 +00:00
Arnold Schwaighofer
4c2dd3ee97 Remove redundant typealias
Swift SVN r30263
2015-07-16 14:20:36 +00:00
David Farler
6099e156eb Add RangeReplaceableCollectionType.removeFirst
Add requirements and default implementations for removeFirst() and
removeFirst(n: Int).

rdar://problem/21844880

Swift SVN r30256
2015-07-16 07:47:06 +00:00