Commit Graph

3053 Commits

Author SHA1 Message Date
Dave Abrahams
155e862317 [stdlib] Range: allow range to be offset by DistanceType
Swift SVN r14690
2014-03-05 20:12:06 +00:00
Joe Groff
f6d4485a3c stdlib/runtime: Create an _ObjCBridgeable protocol and 'bridgeAny' runtime function.
For container bridging, implement a '_bridge<T>' function that converts a Swift value to AnyObject using a runtime check for its _ObjCBridgeable conformance, crashing if one doesn't exist.

Swift SVN r14645
2014-03-04 16:50:11 +00:00
Greg Parker
d63772a7e7 [test] Move arch-specific string appending test to NewStringAppending.swift.
NewString.swift may now be asan-safe too, but I didn't try it.


Swift SVN r14385
2014-02-26 07:28:15 +00:00
Greg Parker
6f0ada02e8 [stdlib] Add conversion of nil to COpaquePointer. Test some nil uses.
Swift SVN r14195
2014-02-21 01:21:46 +00:00
Dave Abrahams
1bdf9d915d [stdlib] Make unique reference checking work
Think the scenarios through more carefully, create more reliable tests.
Fixes <rdar://problem/16105759> Too many retains for COW optimization

Swift SVN r14140
2014-02-20 11:14:09 +00:00
Joe Groff
73e564428f stdlib/runtime: Stub out a mechanism for introspecting value structure.
Define a "Mirror" protocol with methods for querying the number of children a structured value has, getting the name and mirror for each of those children, and a string and "IDE representation" of the value, as needed by playgrounds and by our planned generic printing facility.

In the runtime, define a "reflect" function that can provide a Mirror for any object, either using a "Reflectable" protocol conformance if available, or falling back to a magic implementation in the runtime that grovels the type metadata. Stub out a bare minimum default implementation.

Swift SVN r14139
2014-02-20 08:26:27 +00:00
Dave Abrahams
67734b1835 [stdlib] CollectionOfOne<T>
A simple collection of one element

Swift SVN r13976
2014-02-17 04:56:11 +00:00
Dave Abrahams
ea242f2238 [stdlib] Add Bit type
Will serve as an IndexType for CollectionOfOne<T>

Open Question: should this become a full-fledged Int1 type, generated by
FixedPoint.gyb?

Swift SVN r13974
2014-02-17 04:23:51 +00:00
Joe Groff
3fded63cac stdlib: Proof-of-concept 'print' implementation for an arbitrary Array.
Mock up a naive Printable protocol, and do some dirty tricks in the runtime to implement a 'printAny' function that uses swift_conformsToProtocol to look up a conformance to Printable if the type has one, or falls back to a dumb opaque printing if it doesn't. Use this to make Array<T> Printable in some way or another for all T.

Swift SVN r13902
2014-02-14 05:15:33 +00:00
John McCall
0224e93a2b Only look through UncheckedOptional<T> on explicit accesses.
Add .Some and .None members.

Swift SVN r12951
2014-01-25 03:07:30 +00:00
Jordan Rose
02e2018197 Fix many extra trailing underscores in block shim symbols.
...which would of course prevent them from being used. Sadly, this includes
the one I just added, since I didn't actually test it against the original
project until now.

Add a regression test that all block shims have valid manglings without
any unmangled suffixes.

Swift SVN r12672
2014-01-21 23:45:06 +00:00
Dave Abrahams
fb70778e35 [stdlib] Remove Obsolete CodePoints type
CodePoints was built upon StringByteData, a UTF-8 String
representation.  Its replacement is UTF16Scalars.

Swift SVN r12111
2014-01-10 01:24:25 +00:00
Dave Abrahams
bf3ca81ee7 [stdlib] File renames associated with protocol name changes
Swift SVN r12063
2014-01-08 20:06:29 +00:00
Dave Zarzycki
6e7bb68279 15763917 stdlib/POSIX should probably be removed
Foundation vends wrappers for most of this stuff anyway. We should
duplicate or "innovate" here.

Swift SVN r12002
2014-01-07 19:10:42 +00:00
Dave Abrahams
afbbbd1287 [stdlib] Add a facility for calling "C" functions that take va_list arguments
This code has only been tested on x86_64, but is designed to work on
the other platforms supported by Apple.

Swift SVN r11561
2013-12-22 02:37:33 +00:00
Dave Abrahams
549b2f1368 [stdlib] Turn the String append speed test into a reallocation test
Swift SVN r11056
2013-12-10 00:18:26 +00:00
Dave Abrahams
00e4a84b74 [stdlib] Begin exposing the NSString API directly on String
Because we're using a "brute-force" combination of conversion to
NSString and forwarding, this code will continue to work when String
is replaced by NewString.  It may not be fast yet, but at least it
will flesh out the experience for Cocoa programmers

Swift SVN r11034
2013-12-09 18:44:58 +00:00
Dmitri Hrybenko
f08ee12841 stdlib/FloatingPoint: add APIs to handle special floating point values
See IEEEFloatingPointNumber protocol for a full list of new APIs and
documentation.


Swift SVN r10826
2013-12-05 01:36:15 +00:00
Anna Zaks
b687c3ce9c Add runtime integer truncation checking to the conversion constructors
Add new builtins(by generalizing, renaming, and extending the builtins used for compile time integer literal checking). These new builtins truncate integers and check for overflow/truncation errors at runtime. Use these for FixedPoint conversion constructors.

Fix a routine in stdlib's String implementation and a test that relied on bitwise behavior of the constructors (and triggered overflows).

TODO:
- Teach CCP about these to get static checking.
- Add special builtins for same size signed <-> unsigned conversions.

Swift SVN r10432
2013-11-13 21:54:34 +00:00
Dave Abrahams
38b9e6808f [stdlib] CharacterEncoding.swift => Unicode.swift
Also enshrine the tests in the test suite

Swift SVN r10057
2013-11-08 22:17:50 +00:00
Dave Abrahams
645ce0b664 [stdlib] Add support for bound protocols
Protocols with associated types can't currently be used as existential
types.  Combined with the inability to create type constraints on
generic functions nested in generic types based on the outer type and
the inability to create closures of generic type and the inability to
create protocol constraints that require generic functions and the
inability to create protocols with init() requirements... and this is
what we get.

Swift SVN r10034
2013-11-08 06:29:29 +00:00
Howard Hinnant
46f26de87b Inlined countLeadingZeros per Dmitri's suggestion.
Swift SVN r9970
2013-11-05 20:20:19 +00:00
Chris Lattner
50054458e7 remove SIMD vector support from the stdlib. I think we all really want this,
but we don't have time right now to make it great.  This shrinks the stdlib
by 9000 lines :-)


Swift SVN r9902
2013-11-03 16:10:57 +00:00
Dave Abrahams
f7b6fbb10a [stdlib] NewString.swift: integrate into the stdlib and testing framework
Swift SVN r9741
2013-10-28 23:03:52 +00:00
Dmitri Hrybenko
70329a2efb Add a test that I wrote a while ago, but forgot to 'svn add'
Swift SVN r9478
2013-10-18 03:54:49 +00:00
Howard Hinnant
b78fefdf0b Vector is dead. Long live Array.
Swift SVN r9432
2013-10-16 23:57:29 +00:00
Dave Abrahams
b5842cb6b4 [stdlib] Initial implementation of Character
This type can't do much but store an arbitrary very short string right now, but it works

Swift SVN r8850
2013-10-02 18:56:19 +00:00
Dave Abrahams
4bb2b89d67 [stdlib] Make && and || work on LogicValue, rather than just Bool
Swift SVN r8681
2013-09-26 00:27:54 +00:00
Dmitri Hrybenko
6a403387e8 Move some interpreter-based tests that test stdlib from test/ to test/stdlib/
Swift SVN r7705
2013-08-29 00:13:23 +00:00
John McCall
68d5fbc5e1 Don't drop .o files from tests.
Swift SVN r6800
2013-08-01 01:31:34 +00:00
John McCall
b6d49ea46d Give some dynamic behavior to TypeLowering and lay out
some groundwork for more customization.

Swift SVN r6799
2013-08-01 01:28:39 +00:00
Chris Lattner
fa49d75eb4 Add bool, int8, and float vectors of size 2 definitions and some supported operations.
Swift SVN r6768
2013-07-30 23:54:18 +00:00
Joe Groff
6e00dbf9b9 Remove the Swift version of the demangler.
This creates a regression in REPL printing for class instances, which now will print the mangled class name of the instance, since Object.className was using the Swift demangler to demangle the type name. REPL printing is getting an overhaul so I think this is OK for now.

Swift SVN r6704
2013-07-29 20:50:06 +00:00
Doug Gregor
5240e9a442 Remove Vec4b/Vec4f. They can be added back when someone gives them more thought.
Swift SVN r6026
2013-07-05 22:57:08 +00:00
Dmitri Hrybenko
16d8ddc093 Revert wrong changes, did not intend to commit all that
Swift SVN r6010
2013-07-05 17:13:07 +00:00
Dmitri Hrybenko
b1b1c63be5 Add a comment for r6001
Swift SVN r6009
2013-07-05 17:11:38 +00:00
Dmitri Hrybenko
4277cfa89e Add tests for assertion routines
Also use Console.write() to print the assertion message because it uses
write(2) without buffering.


Swift SVN r5943
2013-07-01 19:58:07 +00:00
Dmitri Hrybenko
8b7b85f769 stdlib/POSIX: add getopt() bindings
Swift SVN r5891
2013-06-28 23:54:18 +00:00
Dave Abrahams
5ffcdaea98 [stdlib] Replace String storage with a reference-counted buffer with capacity
Allows us to use a copy-on-write strategy to efficiently grow Strings.
This should obviate the need for a StringBuffer class anytime soon and
make comfortable formatting efficient.

If we backslide and the COW/capacity functionality of String is no
longer doing its job, the test added here will appear to hang and
hopefully someone will be annoyed enough to fix it.  We can't do
better right now because performance measurements vary based on the
test platform.

Swift SVN r5845
2013-06-27 20:47:21 +00:00
Dave Abrahams
2e0ff6e8ca [stdlib] Add HeapBuffer: a reference-counted buffer of dynamic size
This will be useful in implementing Copy-On-Write value types

Swift SVN r5844
2013-06-27 20:47:18 +00:00
Doug Gregor
9a5c96a8c1 Introduce basic support for LLVM vectors as builtins.
This adds builtin types Builtin.VecNxT, where N is a natural number
and T is a builtin type, which map down to the LLVM type <N x T>. 

Update varous builtins to support vector arguments, e.g., binary
operations, comparisons, negation. Add InsertElement and
ExtractElement builtins for vectors.

On top of these builtins, add Vec4f and Vec4b structs to the standard
library, which provide 4xFloat and 4xBool vectors, respectively, with
basic support for arithmetic. These are mostly straw men, to be burned
down at our leisure.

Some issues as yet unresolved:
  - Comparisons of Vec4f'ss are producing bogus Vec4b's, which I
  haven't tracked down yet.
  - We still don't support the shuffle builtin, although it should be
  easy
  - More testing!



Swift SVN r5820
2013-06-26 21:16:36 +00:00
Chris Lattner
4aa4f66314 rename this test so we can generalize it.
Swift SVN r5712
2013-06-20 16:55:34 +00:00
Dmitri Hrybenko
255f0277b0 stdlib: Char: simplify implementation, expose the value as UInt32 instead of
Builtin.Int32, add tests


Swift SVN r5635
2013-06-18 00:11:05 +00:00
Doug Gregor
dd5626a154 Actually initialize the resulting dictionary when converting from a literal.
Fixes <rdar://problem/14167035>.


Swift SVN r5603
2013-06-15 22:44:24 +00:00
Dave Abrahams
b7b3e0b9cd [stdlib] Add policies for Callable things as a workaround for <rdar://problem/13251236>
(remapping bound function type not implemented yet)

Swift SVN r5454
2013-06-03 20:09:34 +00:00
Dave Abrahams
c5da3b6888 [stdlib] Add Indexable protocol and adapters
Swift SVN r5444
2013-06-03 20:09:24 +00:00
Dave Abrahams
6dbab32a4b [stdlib] Implement (and test) Vector<T>.takeArray()
Swift SVN r5299
2013-05-24 16:39:21 +00:00
Dave Abrahams
b2b4bf9f32 [stdlib] Incorporate CodePoints; split tests out accordingly
Swift SVN r5273
2013-05-22 21:05:47 +00:00
Dave Abrahams
24af18987b [stdlib] Generators and Adaptors
Allows us to write in terms of the "ideal" traversal protocol while
maintaining compatibilty with the existing one

Swift SVN r5101
2013-05-08 21:39:12 +00:00
Dave Abrahams
78cb2016e6 Add Zip2, which zips two Enumerables
Swift SVN r5077
2013-05-07 02:14:24 +00:00