Commit Graph

3245 Commits

Author SHA1 Message Date
Dave Abrahams
c4f798e246 [stdlib] Make our BidirectionalIndexTypes Comparable
This will allow more error checking, resilient slicing, and occasionally
other useful capabilities.

Step 1 of <rdar://problem/11940897>

Swift SVN r20036
2014-07-16 20:43:42 +00:00
Dmitri Hrybenko
d125ac1e24 stdlib/runtime: stdlib casts to existentials: correctly project the buffer as
required

rdar://17628745


Swift SVN r20024
2014-07-16 15:17:46 +00:00
Greg Parker
b09a3a3963 [test] Disable enforcement of a buggy Range<Int> bounds check in 32-bit.
Swift SVN r19965
2014-07-14 23:21:31 +00:00
Dave Abrahams
166ebb2996 [stdlib] Add Range pattern matching
But it doesn't work yet, pending rdar://17668465

Swift SVN r19946
2014-07-14 21:02:30 +00:00
Joe Pamer
cae36c9c9d Broaden the "favored constraint" binop optimization to work with simplified expression types, and not just default literal tyvars.
This addresses or improves several existing TC perf bugs (rdar://problem/15933674, rdar://problem/17110608, rdar://problem/17240816, rdar://problem/17244974), and seems to speed up our unit test runs by ~5%. (On my MacBook Pro, total average execution time is reduced from 557.28s to 531.89s.)

Swift SVN r19939
2014-07-14 19:20:49 +00:00
Dave Abrahams
fa991ca164 [stdlib] deep debugDescription for Interval/Range
debugDescription on a type that represents its subparts should use
toDebugString() for their representations.

Swift SVN r19937
2014-07-14 17:53:25 +00:00
Chris Lattner
57cd2506ff Change "operator infix" to "infix operator" for consistency with the rest of the declaration
modifiers and with the func implementations of the operators.  This resolves the rest of:
<rdar://problem/17527000> change operator declarations from "operator prefix" to "prefix operator" & make operator a keyword




Swift SVN r19931
2014-07-14 16:39:10 +00:00
Chris Lattner
8991456ff2 Switch infix/postfix/prefix to be declaration modifiers instead of attributes,
eliminating the @'s from them when used on func's.  This is progress towards
<rdar://problem/17527000> change operator declarations from "operator prefix" to "prefix operator" & make operator a keyword

This also consolidates rejection of custom operator definitions into one
place and makes it consistent, and adds postfix "?" to the list of rejected
operators.

This also changes the demangler to demangle weak/inout/postfix and related things
without the @.



Swift SVN r19929
2014-07-14 15:51:49 +00:00
Dave Abrahams
cced061ee9 [stdlib] Printable conformance for Range
Swift SVN r19906
2014-07-13 21:21:32 +00:00
Dave Abrahams
8b41540d8d [stdlib] Fix a typo Dmitri found
Thanks, Dmitri!

Swift SVN r19904
2014-07-13 20:54:52 +00:00
Dave Abrahams
be37cd904b [stdlib] Trap invalid Ranges of Comparable Indexes
When the Index type of a Range is Comparable, we can reject invalid
ranges at their formation.

It might be worth injecting some checkability concept into ForwardIndex
so that even in generic contexts where Comparability is unknown, we can
do this same check in the Range constructor.

Also, remove pattern matching support for Ranges of RandomAccessIndex,
as that is covered by Interval.

Fixes <rdar://problem/16254937> (#Seed 4: Ranges with negative strides
are broken) to the extent possible (it's still possible to form an
invalid Range of indices that are not Comparable)

Fixes <rdar://problem/17164391> (Swift: Using ranges in for in for
counting down, causes the loop to go inifinely)

Fixes <rdar://problem/17580871> (Swift: Closed range with negative
endpoint excludes that endpoint)

Swift SVN r19903
2014-07-13 19:58:21 +00:00
Dave Abrahams
61c954b799 [stdlib] Rename a test consistently with others
Swift SVN r19902
2014-07-13 19:43:21 +00:00
Dave Abrahams
d85a7f5d0c [stdlib] Pointer types are not BooleanType's
Fixes <rdar://problem/17597917>.  Someone still needs to do this for the
Optional types.

Swift SVN r19901
2014-07-13 19:21:54 +00:00
Dave Abrahams
cb050eee52 [stdlib] Add Interval support
This allows 0.0..<10.3 and 0.1...4.4 to work properly in pattern
matching.

Fixes <rdar://problem/12016900> (#Seed 4: add a "contains" method to the
range types) by making "contains" available on Interval

Addresses <rdar://problem/16254937> (#Seed 4: Ranges with negative
strides are broken) by making the formation of an invalid Interval a
runtime error.

Fixes <rdar://problem/16304317> (Range<T> has limited awesomeness: it is
restricted to types that conform to ForwardIndex)

Fixes <rdar://problem/16736924> (#Seed 4: Enable range inclusion pattern
matching for all types that conform to Equatable and Comparable)

Addresses <rdar://problem/16846325> (#Seed 4: Introduce index range) by
distinguishing Range (which operates on indices) from Interval

Fixes <rdar://problem/17051263> (Pattern-matching a Double range with an
infinite endpoint triggers an assertion failure)

Fixes <rdar://problem/17051271> (#Seed 4: Pattern-matching Double ranges
excludes fractional values)

Addresses <rdar://problem/17171420> (Separate types for closed and
half-open ranges)

Swift SVN r19900
2014-07-13 18:49:36 +00:00
Doug Gregor
a5c079af59 Replace the class_protocol attribute with a "class" requirement.
This only tackles the protocol case (<rdar://problem/17510790>); it
does not yet generalize to an arbitrary "class" requirement on either
existentials or generics.

Swift SVN r19896
2014-07-13 06:57:48 +00:00
Dave Abrahams
cbcf9aba21 s/LogicValueType/BooleanType/
We're moving toward using that protocol for straight-up Bool types

Swift SVN r19884
2014-07-12 18:58:18 +00:00
Dave Abrahams
6d1095f44e Protocol names end in "Type," "ible," or "able"
Mechanically add "Type" to the end of any protocol names that don't end
in "Type," "ible," or "able."  Also, drop "Type" from the end of any
associated type names, except for those of the *LiteralConvertible
protocols.

There are obvious improvements to make in some of these names, which can
be handled with separate commits.

Fixes <rdar://problem/17165920> Protocols `Integer` etc should get
uglier names.

Swift SVN r19883
2014-07-12 17:29:57 +00:00
Dmitri Hrybenko
dff53defae Dictionary and Array bridging tests: remove incorrect FIXME comments: if the
Dictionary or Array has native storage, there is no reason to expect any bridge
operations


Swift SVN r19882
2014-07-12 17:11:34 +00:00
Dmitri Hrybenko
355316a49b stdlib/Dictionary: when bridging from Objective-C, recognize bridged
native Dictionary storage and adopt it if KeyType and ValueType match
exactly

This was the last missing piece to allow Dictionary to round-trip
thorough objc entrypoints of Swift methods in O(1).

Fixes rdar://17556319, partially fixes rdar://17010353

Swift SVN r19873
2014-07-12 01:17:13 +00:00
Dmitri Hrybenko
ee06efdd2c stdlib/Dictionary: when bridging Dictionary of non-verbatim-bridged
types to NSDictionary, perform bridging operation in O(1), and defer
bridging of the contents until the NSDictionary is accessed

There is no cache for bridged keys and values; the Swift NSDictionary
will return values with different pointer values when a given key is
repeatedly accessed.

Part of rdar://17556319

Does not fix the O(N) performance of objc thunks, because Dictionary is
not recognizing its own native storage when bridging from Objective-C.
This tracked by rdar://17010353

Swift SVN r19853
2014-07-11 17:24:06 +00:00
Enrico Granata
3dfff3a34d Fix tests that were broken by my last changes.
Swift SVN r19818
2014-07-10 19:15:38 +00:00
Enrico Granata
2cd27ad3d2 Tweaks to get PlaygroundLogger to build and work in a world of accessibility-enforced rules
1) Add an ObjCObject disposition that tells us this Mirror is reflecting upon an ObjC-imported type
2) Change the default summary of _ClassMirror and _StructMirror to be the mangled typename, with no children count



Swift SVN r19817
2014-07-10 18:54:25 +00:00
Dmitri Hrybenko
86f58123f9 stdlib/Array: hide some Array implementation details:
ArrayBuffer
ArrayBufferType
ContiguousArrayBuffer
ContiguousArrayStorage
IndirectArrayBuffer
SliceBuffer

Unfortunately, can not remove 'public' from them since they are used by
Foundation overlay in bridging code.


Swift SVN r19810
2014-07-10 14:30:54 +00:00
Dmitri Hrybenko
0e59dcac1f stdlib/Dictionary bridging: don't wrap NSDictionary in Dictionary<K, V> when
either K or V is bridged non-verbatim

rdar://17325454


Swift SVN r19807
2014-07-10 12:02:22 +00:00
Dmitri Hrybenko
4c5d6b07bb Fix warnings in the Dictionary test
Swift SVN r19805
2014-07-10 09:55:14 +00:00
Dmitri Hrybenko
febc98d5a4 stdlib/Dictionary: change internal bridging interfaces so that wrong code (that
does not copy NSDictionary) looks wrong


Swift SVN r19804
2014-07-10 09:45:42 +00:00
Dave Abrahams
cf6842efdb [stdlib] Drop the "by" method on Range<T>
That functionality is now covered by the stride() functions for
Range<T:RandomAccessIndex>, and probably shouldn't be used for ranges of
lesser Index protocols anyway.

Swift SVN r19803
2014-07-10 09:29:03 +00:00
Dave Abrahams
0cbd541a16 [stdlib] Floating point types are Strideable...
...but not RandomAccessIndex'en

Swift SVN r19802
2014-07-10 09:19:28 +00:00
Dave Abrahams
4c31d819ec [stdlib] Striding over closed ranges
Swift SVN r19801
2014-07-10 09:10:02 +00:00
Dave Abrahams
34374354cd [stdlib] Striding over half-open ranges
Swift SVN r19800
2014-07-10 08:44:31 +00:00
Dave Abrahams
ac4703dec6 LLVM headers and Emacs mode annotations
Swift SVN r19799
2014-07-10 08:44:30 +00:00
Dave Abrahams
3e3f4a6e52 Revert "infix + and - for RandomAccessIndex"
This commit was premature; we're having trouble with protocols that needs to be
resolved first.

This reverts r19778

Swift SVN r19780
2014-07-10 04:47:12 +00:00
Dave Abrahams
64c6d32a99 [stdlib] infix + and - for RandomAccessIndex
A step towards implementing generalized striding

Swift SVN r19778
2014-07-10 04:16:53 +00:00
Greg Parker
bde0d301fc Fix fmod() covers. Add CGFloat to the math.h tests.
<rdar://problem/17275152> Can't call C fmodf() from stdlib


Swift SVN r19777
2014-07-10 03:54:27 +00:00
Dave Abrahams
b56c3a84d3 [stdlib] Drop Sliceable conformance for Range<T>
Sliceable is a totally non-critical protocol and Range slicing wasn't
even being tested.  Along with r19771, fixes <rdar://problem/16363898>

Swift SVN r19775
2014-07-10 02:08:46 +00:00
Dave Abrahams
b84a3377f0 [stdlib] Drop ReverseRange
Swift SVN r19773
2014-07-10 01:20:58 +00:00
Dave Abrahams
e261dda22b [stdlib] Give reverse() the eager/lazy treatments
Swift SVN r19772
2014-07-10 01:20:57 +00:00
Dave Abrahams
58f94698c3 [stdlib] Disallow indexing integer ranges with Int
This horrible hack prevents the user from indexing Range<I>, for all
integer types I, outside of a generic context.  This seems to be the
best we can do to prevent confusion given the current language.

Addresses <rdar://problem/16363898>

Unfortunately, I can't make this work for slicing ranges yet.

Swift SVN r19771
2014-07-10 01:20:57 +00:00
Dave Abrahams
9918145209 [stdlib] Drop RandomAccessRange
It won't be needed in the new Range plan after all

Swift SVN r19770
2014-07-10 01:20:56 +00:00
Doug Gregor
d95272ed9e Remove unnecessary uses of __conversion in the test suite.
I've left the uses that are specifically testing this functionality.

Swift SVN r19729
2014-07-09 17:35:32 +00:00
Dmitri Hrybenko
435a8ddf0c stdlib/Dictionary: copy the NSDictionary before wrapping it, so that
NSMutableDictionary and other mutable NSDictionary subclasses don't break
Dictionary's value semantics

rdar://17442261


Swift SVN r19726
2014-07-09 15:13:17 +00:00
Dmitri Hrybenko
0523fea01b stdlib/Dictionary: rewrite iteration over wrapped NSDictionary not to
rely on NSDictionary.allKeys, it leaves the array of keys on the
autorelease pool.  Not very bad, but it is better if we can avoid it.

rdar://17604820

Swift SVN r19724
2014-07-09 14:49:49 +00:00
Dmitri Hrybenko
96b7819cbd stdlib/Dictionary: remove workaround that is not needed anymore
Swift SVN r19722
2014-07-09 10:57:03 +00:00
Ben Langmuir
8b7cc4f619 Make -i compatible with shebangs and forward arguments correctly
The driver option -i now requires an input file as argument, and any
options after the input file will be treated as arguments to the
interpretted file.

This also renames the frontend option to -interpret, since it is parsed
as a flag, unlike -i. We could support -interpret in the driver if we
wanted, which would allow us to use --, but wouldn't work with shebang
scripts. For now, it's frontend-only.

Swift SVN r19718
2014-07-09 02:37:42 +00:00
Greg Parker
d31fe2e1b5 [test] Add explicit CFString->String conversions to test stdlib/Unicode.swift.
Swift SVN r19696
2014-07-08 21:12:40 +00:00
Dmitri Hrybenko
977d901643 stdlib: hide quickSort and insertionSort
Finishes rdar://17315534


Swift SVN r19682
2014-07-08 10:33:23 +00:00
Jordan Rose
ac90133b8c Update tests for accessibility modifiers becoming context-sensitive keywords.
Swift SVN r19673
2014-07-08 02:17:49 +00:00
Jordan Rose
f0fc440785 One last cleanup for access control.
Swift SVN r19662
2014-07-08 00:59:07 +00:00
Enrico Granata
4fd20e7064 Use The Mirror Generator to simplify the CoreGraphics mirrors - a little bit of magic, but much less boilerplate
Oh, and add a test case for those Mirrors, since none was there



Swift SVN r19653
2014-07-08 00:17:06 +00:00
Doug Gregor
0c31ff5681 Move bridging conversions into the type checker.
Previously, bridged value types and their corresponding Objective-C
classes allow inter-conversion via a number of user-defined conversion
functions in the Foundation module. Instead, make this a general
feature of the type checker so we can reason about it more
directly. Fixes <rdar://problem/16956098> and
<rdar://problem/17134986>, and eliminates 11 (half) of the
__conversion functions from the standard library and overlays.

A few notes:
  - The XCTest changes are because a String can no longer directly
  conform to CVarArg: this is a Good Thing (TM), because it should be
  ambiguous: did you mean to pass it as an NSString or a C string?
  - The Objective-C representations for the bridged collections are
  hard-coded in the type checker. This is unfortunate and can be
  remedied by adding another associated type to the
  _BridgedToObjectiveC protocol.

Swift SVN r19618
2014-07-07 18:04:18 +00:00