Commit Graph

21665 Commits

Author SHA1 Message Date
Manman Ren
e3517e8792 [stdlib] add two-operand version of min.
This corresponds to the change on max at r18767.


Swift SVN r18769
2014-06-10 00:57:08 +00:00
Manman Ren
4c284e48bd [stdlib] add two-operand version of max.
This helps array append's performance by ~ 2x. The generic max with a variadic
argument takes at least 3 arguments, it creates a temporary array then iterates
over the array.

This is an updated version of r18764.
rdar://17140639 rdar://17073827


Swift SVN r18767
2014-06-10 00:33:46 +00:00
Greg Parker
dc5f3c2090 <rdar://16878510> Add definitions of stdin/stdout/stderr to the Darwin overlay.
Swift SVN r18766
2014-06-10 00:33:02 +00:00
Manman Ren
aec78d0693 [stdlib] revert r18764.
Swift SVN r18765
2014-06-10 00:13:41 +00:00
Manman Ren
cc90c81239 [stdlib] add two-operand version of max and use max2 in stdlib when appropriate.
This helps array append's performance by ~ 2x. The generic max with a variadic
argument creates a temporary array then iterates over the array.

rdar://17140639 rdar://17073827


Swift SVN r18764
2014-06-09 23:56:40 +00:00
Joe Groff
cf20524271 Fix typo.
Swift SVN r18761
2014-06-09 22:19:12 +00:00
John McCall
1f5fa04724 Move the rest of the dynamic-cast code over to Casting.cpp.
Swift SVN r18759
2014-06-09 21:42:30 +00:00
John McCall
fd9778165b Split the dynamic-cast code out into its own file.
Swift SVN r18756
2014-06-09 21:16:09 +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
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
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
eca9bd244c stdlib/runtime: don't leak filenames of users' code through calls to runtime
trap function for unimplemented initializers.

rdar://17054604


Swift SVN r18658
2014-05-28 22:42:15 +00:00
Dmitri Hrybenko
473ad2e1eb stdlib: don't use assert() in stdlib implementation
Swift SVN r18653
2014-05-28 20:43:56 +00:00
Argyrios Kyrtzidis
5718e5fe3d [stdlib] Re-expose 'nil' as a public symbol.
rdar://17053045

Swift SVN r18652
2014-05-28 17:57:41 +00:00
Enrico Granata
c44731ac31 B&I updated the builders to a new iOS SDK - the new SDK means that the Unmanaged<> is unwrapped automatically on our behalf
This patch is required to unbreak the build



Swift SVN r18651
2014-05-27 23:53:26 +00:00
Nadav Rotem
1dc6de3785 Add a comment that explains how we disable inlining. NFC.
Swift SVN r18646
2014-05-27 00:32:20 +00:00
Dmitri Hrybenko
470fee7838 stdlib: correct a comment to be more explicit that this is a hack
Swift SVN r18644
2014-05-26 23:49:50 +00:00
Enrico Granata
30341ed401 The B&I-sanctioned iOS SDK does not have the right annotations for this to be automatically unwrapped. The Graphics Context comes back to us as Unamanged<> and we need to manually extract the value out of it. Do so for now
Swift SVN r18643
2014-05-26 23:22:59 +00:00
Enrico Granata
3e1ed25aa7 Add a mirror for UIView
There are a couple caveats to this Mirror, discussed in detail in the radar

Fixes rdar://17029335



Swift SVN r18642
2014-05-26 20:26:57 +00:00
Nadav Rotem
dd4d9f5820 Make sure we don't inline the cold path by wrapping it with a closure.
Swift SVN r18641
2014-05-26 20:24:05 +00:00
Dave Zarzycki
b25eeec435 Runtime: automatically enable crash reporting after the announcement
We should have thought about this option earlier. This fixes:
<rdar://problem/16902160> Beta GM TASK: Enable crash tracing for WWDC (revert r10532)

Swift SVN r18639
2014-05-26 19:58:40 +00:00
Nadav Rotem
04b17cc63f Add comments. NFC.
Swift SVN r18637
2014-05-26 19:52:01 +00:00
Dmitri Hrybenko
f179e4cbc0 stdlib/Foundation overlay: hide NSSimpleCString
rdar://17024122


Swift SVN r18636
2014-05-26 18:39: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
Enrico Granata
2122984ad9 This adds NSString to the list of quicklookable types in playgrounds
This patch allows people to define a func quickLookObject() that returns an NSString, and have the playgrounds pick that up for the sidebar

Fixes rdar://16730829 (or at least gets us through WWDC)



Swift SVN r18629
2014-05-25 23:16:04 +00:00
Argyrios Kyrtzidis
b1914701e9 [stdlib] In ContiguousArrayBuffer<T>, vars 'storage' and 'base' where under the 'private' section
so I took the liberty to 'privatize' them with a leading underscore.

This also completely removes '_ArrayBody' from the public interface.
Should be NFC, apart from the public interface change.

Swift SVN r18625
2014-05-25 04:31:13 +00:00
Argyrios Kyrtzidis
95bd9e1d28 [AST/IDE] Centralize the logic to determine if a symbols is a 'private' stdlib one and hide them more extensively.
-Hide vars that have a private type.
-Hide functions that have a parameter with private type or a parameter name with leading underscore.
-Minor change in StringUTF16.swift to avoid printing "func generate() -> IndexingGenerator<_StringCore>".

rdar://17027294

Swift SVN r18623
2014-05-25 03:49:02 +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
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
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
Chris Hanson
3298bebb2c Make XCTestCase.className demangle its result.
XCTest needs a way to get the demangled name of a test case class,
so provide one by overriding NSObject.className.

Addresses <rdar://problem/17010812>.

Swift SVN r18606
2014-05-23 22:07:29 +00:00
Dave Abrahams
a79a06fee4 [stdlib] Improve efficiency of Array literals
Before this change, the dispatching hacks sent convertFromArrayLiteral
through the "Sequence" path, wherein we could not assume the ability to
non-destructively measure the length of the Sequence before beginning to
add the elements, which resulted in buffer reallocations as elements
were added.  Now we the sequence is measured and storage is
pre-allocated.

Swift SVN r18603
2014-05-23 20:27:55 +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
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
04dae74cd6 stdlib: correct comment
Swift SVN r18592
2014-05-23 13:07:46 +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
bd0c7f4651 stdlib/Dictionary: rename variables to match the new semantics. No public API
changes.


Swift SVN r18588
2014-05-23 09:09:51 +00:00
Dave Zarzycki
d713c55268 Heap: Sniff out *any* Malloc knobs and fall back on the system malloc
Swift SVN r18574
2014-05-22 21:40:10 +00:00
Doug Gregor
f305cd7946 Look through bridgeFromObjectiveC calls to find forced casts within optional injections.
Fixes <rdar://problem/17003302>.


Swift SVN r18563
2014-05-22 15:47:13 +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 Zarzycki
631e89d205 Heap: enable some runtime asserts that double check the compiler
This double checks:
<rdar://problem/16979846> Array backing store is leaking
<rdar://problem/16989632> Array backing store sizing is still buggy

Swift SVN r18554
2014-05-22 05:00:58 +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 Zarzycki
842e288377 Heap: pre-compute pthread layout details
This function is hot enough that this is worth it.

Swift SVN r18521
2014-05-21 21:14:03 +00:00
Dave Zarzycki
74f29d5138 Heap: cache dlsym() result
This fixes: <rdar://problem/16991267>

Swift SVN r18520
2014-05-21 20:59:26 +00:00
Dave Abrahams
2339bd5b59 [stdlib] String API Review: hide contiguousUTF8
Swift SVN r18517
2014-05-21 20:38:35 +00:00