Commit Graph

3245 Commits

Author SHA1 Message Date
Doug Gregor
b75093b367 Add SILGen support for dictionary upcasts <rdar://problem/17289296>.
This allows us to perform upcasts (including bridging upcasts) for dictionaries end-to-end.

Swift SVN r18889
2014-06-14 04:34:49 +00:00
Doug Gregor
47748ba9aa Add stub implementations of the dictionary upcast entry points.
This introduces _dictionaryUpCast and _dictionaryBridgeToObjectiveC,
which will be used for upcasting for non-bridged and bridged key/value
types, respectively. _dictionaryUpCast is a horrible copying O(n)
implementation where we should be able to provide an O(1)
implementation, and _dictionaryBridgeToObjectiveC is similarly
awful. Hence, this is not for <rdar://problem/16852016>, but is merely
a stub to let us make progress on upcasting in the frontend
(<rdar://problem/17289296>).

Swift SVN r18867
2014-06-13 16:32:49 +00:00
Jordan Rose
5f4db71fc5 Remove KVOContext from the Foundation overlay.
We're recommending people just go with a global variable.

<rdar://problem/17272837>

Swift SVN r18837
2014-06-12 19:55:45 +00:00
Greg Parker
fc3794d7e9 <rdar://16978397> Overlay most of the rest of math.h.
Swift SVN r18821
2014-06-12 01:48:00 +00:00
Greg Parker
8548760762 <rdar://16978397> Add overlays for most of tgmath.h.
Swift SVN r18808
2014-06-11 21:56:25 +00:00
Manman Ren
9c0a25c4f0 Add testing for min max.
Swift SVN r18804
2014-06-11 17:43:25 +00:00
Dave Zarzycki
152627896e stdlib: more byte swap feedback
Swift SVN r18790
2014-06-10 23:23:56 +00:00
Dave Zarzycki
59368b5711 stdlib: byte swap feedback
We only care about little-endian hosts at it shows. ;-)

Swift SVN r18787
2014-06-10 23:03:56 +00:00
Dave Zarzycki
9bdf3f6f6e stdlib: add .byteSwapped to integer types
This fixes: <rdar://problem/17085624>

Swift SVN r18786
2014-06-10 22:41:27 +00:00
Chris Lattner
4dbff38780 Change NULL/Nil/nil and various other macros to be imported as an unavailable decl,
instead of importing them as _Nil (which will be going away when nil becomes an expr).

You now get an error saying:
error: 'NULL' is unavailable: use 'nil' instead of this imported macro

This is pretty cool all around, except for the GCD macros that need to be fixed, I'll
handle that as a follow-up.


Swift SVN r18747
2014-06-09 17:08:11 +00:00
Doug Gregor
fa71c0d0bb Teach _dynamicCastToExistential to check conformance to Objective-C protocols.
Narrowly address the problem of downcasting an array to an array of
Objective-C existentials by checking conformance for Objective-C
protocols. Addresses <rdar://problem/17165071>, but this area still
needs a lot of work.


Swift SVN r18745
2014-06-09 15:13:58 +00:00
Chris Lattner
615157ed5b disable this test, it is aborting in the legalizer, tracked by rdar://17218018
Swift SVN r18735
2014-06-07 21:17:35 +00:00
Dmitri Hrybenko
5649360b8f stdlib/NSString APIs on String: add more tests
Swift SVN r18682
2014-05-30 23:49:22 +00:00
Dmitri Hrybenko
a69e341aa2 stdlib/NSString APIs on String: fix a bug and add tests for
rangeOfCharacterFromSet(_:options:range:)

The underlying Objective-C API could return an NSRange of NSNotFound.  Swift's
String.Index can not represent that, so change the API to return an optional
Swift Range<Index> instead.


Swift SVN r18679
2014-05-30 23:07:21 +00:00
Dmitri Hrybenko
df71a47fe4 stdlib/NSString APIs on String: fix two bugs and add more tests
stringWithBytes(_:length:encoding:) was passing an array to Objective-C
incorrectly, and a garbage NSString was being constructed as a result.

Unhide the initializer was accidentally hidden.


Swift SVN r18674
2014-05-30 20:30:57 +00:00
Argyrios Kyrtzidis
085c126266 [test] For 'test/stdlib/Reflection.swift' remove unnecessary #if's and code duplication.
Swift SVN r18673
2014-05-30 20:27:07 +00:00
Dmitri Hrybenko
502214a3a1 stdlib/String bridging: make the test for UTF-8 encoding swow path more robust
and add tests non-ASCII strings


Swift SVN r18669
2014-05-30 18:03:24 +00:00
Greg Parker
e1496d3261 [test] Fix String test failure on some platforms.
Two of the String conversion tests want to check the case where none of CF's 
fast-access functions succeed. In one of these tests CF's fast-access functions
will always succeed when CF does not support tagged pointer string objects. 
That breaks the test on platforms that don't support tagged pointer strings. 
The test now does nothing if it does not get an NSTaggedPointerString back.


Swift SVN r18666
2014-05-30 01:09:19 +00:00
Dmitri Hrybenko
ea7758f40d stdlib/String: implement UTF-8 encoding for Strings that wrap NSStrings for
which Foundation can not give us a UTF-8 encoding in O(1)

rdar://17041741


Swift SVN r18660
2014-05-29 00:41:42 +00:00
Dmitri Hrybenko
473ad2e1eb stdlib: don't use assert() in stdlib implementation
Swift SVN r18653
2014-05-28 20:43:56 +00:00
Dmitri Hrybenko
f4a4e1c5dc stdlib/NSString APIs on String: add more tests
Swift SVN r18649
2014-05-27 20:50:05 +00:00
Dmitri Hrybenko
ec22505b2d stdlib/NSString APIs on String: add more tests
Swift SVN r18645
2014-05-26 23:52:26 +00:00
Dmitri Hrybenko
02b977fab9 stdlib/runtime: fix a bug in dynamicCastToExistential1() that prevented print()
of values typed as Any to work

The cast used to return values with Existential metadata.

rdar://17026363


Swift SVN r18634
2014-05-26 17:56:29 +00:00
Joe Groff
1efc2d9fae Reflection: Fall back to using ObjC metadata to get field offsets in ObjC-derived class mirrors.
Our runtime doesn't fix up class field offset vectors for resilient ObjC base classes, causing the offsets to be wrong if the actual size of the base class differs from its compile-time claimed size. Use the ObjC runtime's ivar records instead if the class has ObjC heritage. We can't do this all the time because the ObjC ivar records aren't yet trustworthy for generic classes, but we don't fully support the mix of ObjC heritage and genericity very well anyway yet. Fixes <rdar://problem/17027510> in the short term.

Swift SVN r18622
2014-05-24 23:14:10 +00:00
Argyrios Kyrtzidis
7230c0f031 [test] Remove a "#if os(OSX)" check from test/stdlib/Reflection.swift, that section can apply and pass the test on iOS as well.
Swift SVN r18619
2014-05-24 16:00:52 +00:00
Nadav Rotem
1c3c12fd5e Fix a bug in the partition() method that is used by sort.
The problem was that we were swapping the pivot while partitioning the array.

Thanks Dave!



Swift SVN r18611
2014-05-24 01:24:34 +00:00
Enrico Granata
1e5b65cacb Improve the switch statement in this test case to be more idiomatic
Thanks Joe!



Swift SVN r18610
2014-05-24 01:09:19 +00:00
Enrico Granata
0134c6d197 Allow user-defined Swift classes to implement our API for QuickLooks, and have the result of that API be picked up by the Mirrors
This is our public API for how quicklooks work in the debugger, and the plan is to have this same API work in playgrounds as well

Fixes rdar://17023157


Swift SVN r18609
2014-05-24 01:00:46 +00:00
Enrico Granata
22329b3ac2 Extend the _OpaqueMirror to produce summaries that at least reflect the broad category of value being reflected
The <opaque> output is clearly useless, and annoying to see scattered around playgrounds

We don't have bandwidth right now to produce detailed useful reflection information, but at least show a basic understanding of data

Fixes part of rdar://17018392



Swift SVN r18607
2014-05-23 23:23:43 +00:00
Nadav Rotem
03a59e4286 Add a test for sort()
Swift SVN r18602
2014-05-23 20:15:10 +00:00
Dmitri Hrybenko
c4d0063bba stdlib/NSString APIs on String: add more tests
Swift SVN r18600
2014-05-23 19:18:44 +00:00
Dmitri Hrybenko
fce7a8c4ff stdlib/NSString APIs on String: dataUsingEncoding:allowLossyConversion: can
return nil, change our API and add tests


Swift SVN r18597
2014-05-23 16:38:53 +00:00
Dmitri Hrybenko
94b1957b88 stdlib tests: now CString no longer crashes in these cases, re-enable tests
Swift SVN r18596
2014-05-23 15:58:05 +00:00
Dmitri Hrybenko
ce14332bb6 stdlib: make UnicodeScalar.escape() independent of current locale
Swift SVN r18595
2014-05-23 15:40:47 +00:00
Dmitri Hrybenko
c5f21546db stdlib/CString: fix two issues with CString.persist():
1. it crashed on a null pointer;

2. it crashed on a non-ASCII strings.

rdar://17016284


Swift SVN r18594
2014-05-23 15:18:21 +00:00
Dmitri Hrybenko
f47d3203a2 stdlib/NSString APIs on String: add more tests
Swift SVN r18593
2014-05-23 13:28:36 +00:00
Dmitri Hrybenko
83f7bdc30e stdlib/NSString APIs for String: allow a nil locale to be passed to
capitalizedStringWithLocale(_:)


Swift SVN r18591
2014-05-23 09:51:30 +00:00
Dmitri Hrybenko
8b44b2dd71 Remove the comment that turned out to be not accurate
Swift SVN r18590
2014-05-23 09:12:06 +00:00
Dmitri Hrybenko
3944e61d25 stdlib/NSString APIs on String: add more tests
Swift SVN r18589
2014-05-23 09:10:32 +00:00
Greg Parker
607a5e89e5 [test] Most string encodings don't have names on iOS.
Swift SVN r18577
2014-05-22 23:18:58 +00:00
Dmitri Hrybenko
9515418a69 stdlib/NSString API tests: add a missing file in Inputs
Swift SVN r18569
2014-05-22 20:37:04 +00:00
Joe Groff
464bce4b39 IRGen: Put witness tables into no_dead_strip sections.
Witness tables can't be dead-stripped without breaking the dynamic conformance queries printing now relies on. Fixes <rdar://problem/16993349>.

Swift SVN r18567
2014-05-22 19:30:45 +00:00
Dmitri Hrybenko
c4c0b53e0d stdlib/String: NSString APIs: add a skeleton for tests
rdar://17002128


Swift SVN r18564
2014-05-22 15:49:14 +00:00
Dmitri Hrybenko
47bae74a59 stdlib/Dictionary: fix a bug in deletion
If we were deleting a key in the middle of a collision chain, and the tail of
the collision chain had keys whose ideal bucket was located before the hole
that we just created, we would mistakenly not relocate those keys.

rdar://16984824


Swift SVN r18562
2014-05-22 10:47:22 +00:00
Doug Gregor
67ca1c9ea1 Implement the new casting syntaxes "as" and "as?".
There's a bit of a reshuffle of the ExplicitCastExpr subclasses:
  - The existing ConditionalCheckedCastExpr expression node now represents
"as?". 
  - A new ForcedCheckedCastExpr node represents "as" when it is a
  downcast.
  - CoerceExpr represents "as" when it is a coercion.
  - A new UnresolvedCheckedCastExpr node describes "as" before it has
  been type-checked down to ForcedCheckedCastExpr or CoerceExpr. This
  wasn't a strictly necessary change, but it helps us detangle what's
  going on.

There are a few new diagnostics to help users avoid getting bitten by
as/as? mistakes:
  - Custom errors when a forced downcast (as) is used as the operand
  of postfix '!' or '?', with Fix-Its to remove the '!' or make the
  downcast conditional (with as?), respectively.
  - A warning when a forced downcast is injected into an optional,
  with a suggestion to use a conditional downcast.
  - A new error when the postfix '!' is used for a contextual
  downcast, with a Fix-It to replace it with "as T" with the
  contextual type T.

Lots of test updates, none of which felt like regressions. The new
tests are in test/expr/cast/optionals.swift. 

Addresses <rdar://problem/17000058>


Swift SVN r18556
2014-05-22 06:15:29 +00:00
Dave Abrahams
0f9edadc41 [stdlib] String API Review: NSString API
Many changes in how we're presenting the NSString APIs on String, most
notably that we now traffic in String.Index and Range<String.Index>
rather than Int and NSRange.  Also we present NSString initializers that
can fail only as factory functions, and factory functions that can't
fail only as init functions.

About 25% of the API changes here have been reviewd by the Foundation
guys, and testing is, as it has always been, admittedly spotty.  Dmitri
is going to be writing some more comprehensive tests.

Swift SVN r18553
2014-05-22 04:21:55 +00:00
John McCall
329abe543d Pass an alignment mask during heap array allocation,
not an alignment value.

Assert that various entrypoints get an alignment mask.

Get everything uniformly passing an assertion about
dealloating an object with the correct allocation
size; don't actually enable the assertion yet, though.

rdar://16989632

Swift SVN r18550
2014-05-22 01:58:05 +00:00
Dave Abrahams
f58196f954 [stdlib] String API Review: drop size()
Swift SVN r18515
2014-05-21 20:36:40 +00:00
Dave Abrahams
8445618f1d [stdlib] String API Review: hide "split" and "lines"
Swift SVN r18514
2014-05-21 20:30:23 +00:00
Dave Abrahams
57347d54b5 [stdlib] String API Review: kill asUTF8()
Swift SVN r18512
2014-05-21 20:30:21 +00:00