Commit Graph

4650 Commits

Author SHA1 Message Date
Dave Zarzycki
c550e75954 stdlib: consolidate compiler protocols into a dedicated file
Annotating each protocol with "NOTE: ..." doesn't scale.

Swift SVN r11758
2013-12-31 02:08:59 +00:00
Dave Zarzycki
669ca06213 stdlib: mark SignedNumber methods as @transparent
Swift SVN r11757
2013-12-31 01:54:11 +00:00
Dave Zarzycki
9bfa643933 stdlib: abs() should use Builtin.*fabs* on floats
Swift SVN r11745
2013-12-30 21:42:22 +00:00
Doug Gregor
8383a25989 Remove the __less__ hack; use < instead.
Note that we have to work around <rdar://problem/14432081> a bit.

Swift SVN r11726
2013-12-29 21:05:16 +00:00
Doug Gregor
d1054b9e86 Eliminate the __equal__ protocol requirement; use == directly.
This is DaveA's patch, slightly tweaked, which works properly now that
<rdar://problem/15715996> is fixed.

Swift SVN r11725
2013-12-29 20:45:25 +00:00
Chris Lattner
4f4c698ed6 Change 'self' to be an rvalue instead of an lvalue in non-@mutating
struct methods.  This does not including properties and subscripts,
but covers the bulk of the change.  The implication of this is that
the compiler now rejects mutations of self in a non-@mutating method,
and rejects attempts to call a @mutating method from a non-@mutating
method.

Along with this:
 - Fix a refcounting bug in SILGenExpr where I emitted multiple releases
   in the rvalue member_ref_expr case, which was exposed by the 
   testsuite now that rvalues are being used a lot more.
 - Change a few native binding things in objc/Foundation to understand
   that String is passed by value now when calling size() and that
   you can't take the address of self in a non-mutating method (this
   should probably pass the components by value instead of passing
   &self, for better performance).  I filed rdar://15726720 to track
   this.
 - Update a ton of testcases.  We now don't materialize nearly as much
   as we used to.
 - Brutalize the test/stdlib/Getopt.swift testcase to work, now that
   the "GetoptLongOptions().noArgument("foo")" builder pattern doesn't
   work anymore (noArgument is a @mutating method, which isn't allowed
   on an rvalue temporary).



Swift SVN r11662
2013-12-26 17:38:03 +00:00
Joe Groff
3e30cbcfef SILGen/IRGen: Don't emit top_level_code for libraries.
If there's no script-mode file in a module, don't produce a top_level_code SILFunction for it, and don't consider emitting an LLVM global_ctor for it. We should never emit static constructors from user code anymore.

Swift SVN r11644
2013-12-26 00:18:29 +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
Joe Groff
3c192269d0 Runtime: Remove debug noise from swift_getExistentialMetadata.
Swift SVN r11524
2013-12-20 23:06:14 +00:00
John McCall
c5aa41ffd1 Change around some manglings to make them carry more
information and be easier to demangle.

Swift SVN r11423
2013-12-18 08:33:52 +00:00
Dave Abrahams
85511c09b1 Remove mistakenly-committed file
Swift SVN r11329
2013-12-15 03:18:08 +00:00
Dave Abrahams
90f13d55b4 [stdlib] NSStringAPI: add a couple of missing .AutoReleased annotations
Swift SVN r11328
2013-12-15 03:13:10 +00:00
Doug Gregor
1ecccd8f47 Remove unused static function.
Swift SVN r11264
2013-12-13 21:19:53 +00:00
Dave Abrahams
eea35fd745 BlockShims: correct a mangled name
Where did the triple underscore come from?  Are the other ones wrong,
too?  We should at least have a trivial test for each of these.

Swift SVN r11255
2013-12-13 16:18:43 +00:00
Dave Abrahams
5c24f790c8 [stdlib] NSStringAPI: create missing block shim
Now we can actually link the implementation of
enumerateLinguisticTagsInRange

Swift SVN r11221
2013-12-12 23:47:07 +00:00
Dave Abrahams
68c47c7121 [stdlib] Remove ObjectPointer.swift; it was not ready for prime-time
Swift SVN r11131
2013-12-11 17:20:06 +00:00
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