Commit Graph

21434 Commits

Author SHA1 Message Date
Dave Abrahams
4c98b501a6 [stdlib] Expose NSString.stringWithContentsOfFile on String
Along the way created bridging utilities for ObjectiveC functions that
take "out" arguments and added an fmap for operating on Optionals

Swift SVN r11123
2013-12-11 07:24:05 +00:00
Doug Gregor
a5167f6bac Remove the type-checker performance workaround in <rdar://problem/14925518>
Swift SVN r11118
2013-12-11 03:40:22 +00:00
Dmitri Hrybenko
b55f943d0d stdlib/FixedPoint: fix indentation
Swift SVN r11089
2013-12-10 20:44:03 +00:00
Joe Groff
ab95d6cd11 stdlib: Add a BitwiseOperations protocol.
Collect the bitwise logical operators under a protocol. Add an 'allZeros' static method to produce the 'zero' identity value for the type when used with bitwise operations.

Swift SVN r11068
2013-12-10 04:03:20 +00:00
Jordan Rose
b4fe56eb1c Actually fix the Makefile build for multi-file Swift libraries.
The hack to get the LLVM build system to do what we want is to define a
custom build rule for "XYZ.o" and then add "XYZ" as a dummy source file
to the SOURCES variable, which the LLVM Makefile system uses. To make it
clear that something unusual is going on here, I've changed all existing
instances of this to use "XYZ.o" in SOURCES, rather than having that name
be derived from "XYZ.swift" or whatever.

The actual Swift source files go in SWIFT_SOURCES for the time being
(and possibly forever, since Swift sources will always be built together).

Swift SVN r11058
2013-12-10 00:23:43 +00:00
Dave Abrahams
2293ac8d2e Fix the Makefile build
Since our build system isn't really set up to cope with
multi-sourcefile-modules, dump all Foundation support directly into
Foundation.swift

Swift SVN r11049
2013-12-09 23:17:29 +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
Anna Zaks
b75cb37cf8 Reapply r10534 in a more convenient form.
Swift SVN r10944
2013-12-06 22:10:52 +00:00
Dave Abrahams
983438948f [stdlib] Rip out mistakenly committed test code
Swift SVN r10920
2013-12-06 06:02:25 +00:00
Dave Abrahams
01b2a39029 [stdlib] Add a length property to NewString
Swift SVN r10919
2013-12-06 06:02:24 +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
Doug Gregor
95ebc6b596 Eliminate the use of the T(x) syntax as type coercion.
Long ago we decided to eliminate the use of this syntax for type
coercion, but we didn't have a good replacement (now we do: x as T)
and the type checker used this ability to handle string
interpolation. Switch string interpolation over to disjunction
constraints.


Swift SVN r10789
2013-12-04 21:11:57 +00:00
Dave Zarzycki
d08712cb35 15242776 stdlib: merge "Array" and "Slice" into Array.swift
The "HArray" name is temporary.

Swift SVN r10708
2013-12-01 08:16:43 +00:00
Dave Abrahams
b3955c6d7a [stdlib] NewString.swift: work in progress
Swift SVN r10680
2013-11-28 16:45:21 +00:00
Dave Abrahams
88b0edaf82 [stdlib] NewString: conversion from string literals
Swift SVN r10651
2013-11-22 00:40:08 +00:00
John McCall
b1bbbac19b Correct the mangling of SIL results to include the
ownership convention.

Swift SVN r10598
2013-11-20 18:05:05 +00:00
Doug Gregor
ba6362af8f Update VOID mangling for block shims.
Unbreaks the "Name That Tune" build.


Swift SVN r10593
2013-11-20 16:35:50 +00:00
John McCall
20e58dcf93 Change the type of function values in SIL to SILFunctionType.
Perform major abstraction remappings in SILGen.  Introduce
thunking functions as necessary to map between abstraction
patterns.

Swift SVN r10562
2013-11-19 22:55:09 +00:00
Dave Zarzycki
18fc62f4eb 15489271 Adopt @transparent on min/max static var min/max decls of the integer types
Swift SVN r10534
2013-11-17 23:16:41 +00:00
Dave Zarzycki
2c24ee6a29 Switch integer min/max static funcs to static vars
Swift SVN r10533
2013-11-17 22:42:54 +00:00
Dave Zarzycki
accb1652c8 15484346 Disable crashtracer for applications
Swift SVN r10532
2013-11-17 20:50:53 +00:00
Dave Zarzycki
f22377c3ef Fix a concurrency leak
Swift SVN r10531
2013-11-17 20:50:47 +00:00
Dave Zarzycki
727a0e4c69 Fix make build system
Swift SVN r10530
2013-11-17 20:50:41 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Joe Groff
562e2bfff6 Runtime: Add swift_once function.
For now, just shim over dispatch_once.

Swift SVN r10514
2013-11-16 03:11:17 +00:00
Anna Zaks
3e8fa762ec Dynamically and statically dianose a conversion of a negative integer to an unsigned int.
Swift SVN r10513
2013-11-16 01:26:54 +00:00
Anna Zaks
0f390c9c54 Add dynamic checking for sign errors(overflows) during signed <-> unsigned conversions for integers of the same type.
Add unsafe alternatives to allow unsafe conversions:
 - asUnsigned()
 - asSigned()

Swift SVN r10476
2013-11-15 00:16:18 +00:00
Dave Zarzycki
16f2b951e6 15466633 _getBuiltinArrayBoundValue should be @transparent
Swift SVN r10459
2013-11-14 08:11:40 +00:00
Chris Lattner
3f0976677f secondary cleanups now that bool is a struct: we can directly access .value
to convert a Bool to i1 and can use the Bool ctor to convert i1 to Bool.



Swift SVN r10437
2013-11-13 23:39:26 +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
Joe Groff
7de9706403 IRGen/Runtime: Expose extra inhabitants of class protocol types.
This gives 'id?' and other optional class protocol types optimal representation consistent with class types.

Swift SVN r10346
2013-11-11 22:52:23 +00:00
Anna Zaks
084bdfd05f Change the signature of the trunc builtins to return a tuple containing teh overflow bit as well as the result.
This is a first step in generalizing the builtin to handle non-constant int to int truncations.

Swift SVN r10341
2013-11-11 21:20:04 +00:00
Dmitri Hrybenko
e36ebb217c Remove empty files
Swift SVN r10074
2013-11-09 08:01:08 +00:00
Joe Groff
554abf2d7a IRGen/Runtime: Expose extra inhabitants of class types.
Start using null-page values as extra inhabitants when laying out single-payload enums that contain class pointers as their payload type. Don't use inhabitants that set the lowest bit, to avoid trampling potential ObjC tagged pointer representations. This means that 'T?' for class type T now has a null pointer representation. Enums with multiple empty cases, as well as nested enums like 'T??', should now have optimal representations for class type T as well.

Note that we don't yet expose extra inhabitants for aggregates that contain heap object references, such as structs with class fields, Swift function types, or class-bounded existentials (even when the existential has no witness tables).

Swift SVN r10061
2013-11-09 00:43:40 +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
Howard Hinnant
ec70f480a6 Set Dictionary up to use only power-of-2 bucket counts. Introduce countLeadingZeros helper to accomplish this. It would be really nice if we could figure out how to inline countLeadingZeros.
Swift SVN r9967
2013-11-05 18:52:44 +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
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Dave Abrahams
21d196a9ef [stdlib] Implement basic transcoding of UTF8 and UTF16
Swift SVN r9896
2013-11-02 01:32:49 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +00:00
Joe Groff
bbddf41693 IRGen: Instantiate existential metadata through the runtime.
When we need a reference to protocol or protocol composition type metadata, ask for it through the runtime, instead of referencing statically-emitted protocol metadata.

Swift SVN r9871
2013-11-01 17:13:49 +00:00
Greg Parker
beaa56d8e9 Add Builtin.Word and use it to implement swift.Word.
Swift SVN r9864
2013-11-01 00:11:22 +00:00
Joe Groff
fe7ecec60c Runtime: Provide value witness implementations for class existentials.
Same deal as for opaque existentials--pre-instantiate a static witness table for one-witness-table types (the zero-witness-tables case is nicely handled by Builtin.ObjCPointer's value witness), and generate a vwtable using dynamic witness implementations for each different-sized container on demand as necessary.

Swift SVN r9850
2013-10-31 18:38:54 +00:00
Greg Parker
b342f68392 Fix Float80 suppression.
Swift SVN r9838
2013-10-31 01:47:27 +00:00
Joe Groff
c38ad6458e Runtime: Expose assignExistentialWithCopy entry points.
The assign-with-copy operation on existentials is complex enough to be emitted as a function call, which is currently generated on-demand by IRGen for every existential layout. We can instead use the implementation out of the runtime. Provide entry points for zero, one, and any number of witness tables.

Swift SVN r9815
2013-10-30 21:58:36 +00:00
Dmitri Hrybenko
c216a848b9 stdlib/FloatingPoint: port floating point implementation to gyb
No changes in functionality intended.


Swift SVN r9799
2013-10-30 17:14:12 +00:00
Joe Groff
922358797d Runtime: Provide a specialization for zero-witness-table existential container layout.
So compilers don't complain about nonstandard use of zero-sized arrays.

Swift SVN r9797
2013-10-30 17:07:04 +00:00
Dmitri Hrybenko
462bc95c6a stdlib/FixedPoint: use camel case names in generator script
Swift SVN r9796
2013-10-30 17:06:55 +00:00