Commit Graph

275 Commits

Author SHA1 Message Date
John McCall
8cae5ba1d0 Generalize 'isDirectPropertyAccess' to allow for
direct (i.e. non-polymorphic) access to accessor
functions, and use this in materializeForSet for
computed properties.

Swift SVN r22059
2014-09-18 05:51:32 +00:00
John McCall
75050f8166 Generate an implicit 'materializeForSet' accessor
along with getters and setters.

Just generate it for now.

Swift SVN r22011
2014-09-17 08:08:03 +00:00
Doug Gregor
d93eaed9f7 Switch BooleanLiteralConvertible over to an initializer requirement.
Conforming to BooleanLiteralConvertible now requires

  init(booleanLiteral: Bool)

rather than

  static func convertFromBooleanLiteral(value: Bool) -> Self

This posed a problem for NSNumber's conformance to
BooleanLiteralConvertible. A class needs a required initializer to
satisfy an initializer requirement, but one cannot add a required
initializer via an extension. To that end, we hack the Clang importer
to import NSNumber's initWithBool with the name

  init(booleanLiteral:)

and add back the expected init(bool:) initializer in the
overlay. These tricks make NSNumber even harder to subclass, but we
don't really care: it's nearly impossible to do well anyway, and is
generally a Bad Idea.

Part of rdar://problem/18154091.

Swift SVN r21961
2014-09-15 23:59:30 +00:00
Dmitri Hrybenko
9325c5ac16 Sema: pattern binding for derived 'hashValue' property is not
conditional.  Found by inspection.

Swift SVN r20303
2014-07-22 11:31:55 +00:00
Chris Lattner
48687380b7 now that DeclAttributes is a single word, there is no reason to deal with
it indirectly through another pointer from Decl, just embed DeclAttributes
directly into Decl and get rid of the "getMutableAttrs" nonsense.



Swift SVN r20216
2014-07-20 04:09:42 +00:00
Chris Lattner
a3c17dc166 move the @infix/@postfix/@prefix attributes onto the modern attribute infrastructure, NFC.
Swift SVN r19927
2014-07-14 14:30:26 +00:00
Doug Gregor
2f3f6acf21 Make "true" and "false" Boolean literal constants for the BooleanLiteralConvertible protocol.
Introduce the new BooleanLiteralConvertible protocol for Boolean
literals. Take "true" and "false" as real keywords (which is most of the
reason for the testsuite churn). Make Bool BooleanLiteralConvertible
and the default Boolean literal type, and ObjCBool
BooleanLiteralConvertible. Fixes <rdar://problem/17405310> and the
recent regression that made ObjCBool not work with true/false.


Swift SVN r19728
2014-07-09 16:57:35 +00:00
Jordan Rose
6cca3529eb Compute accessibility for all ValueDecls, and serialize it properly.
No validation is done yet on whether the user-specified access control makes
sense in context, but all ValueDecls should at least /have/ accessibility now.

/Still/ no tests yet. They will be much easier to write once we're actually
enforcing access control and/or printing access control.

Swift SVN r19143
2014-06-24 21:32:13 +00:00
Doug Gregor
3d3ff6811a Add a pile of missing #includes exposed by pruning includes in top-of-tree LLVM.
Swift SVN r17157
2014-05-01 14:26:34 +00:00
Doug Gregor
9cfb1b5ca4 Keep track of the locations of the element names in a TupleExpr.
As part of this, use tail allocation to reduce the memory footprint of
TupleExprs. Use factory methods to make it easier to construct.

I'll be using this information in a follow-on patch. SourceKit
probably wants it as well.


Swift SVN r17129
2014-05-01 00:16:36 +00:00
Joe Groff
20b7736bd6 stdlib/AST: Make 'Hashable.hashValue' into a property.
As a step on the way to harmony with Cocoa, change Hashable's hashValue into a property requirement, and update the derived conformance generation to produce a computed property instead of a standalone function.

This is mostly Ted's patch, with some help from Dmitri to clean up the IDE aspects.

Swift SVN r16864
2014-04-26 01:29:24 +00:00
Chris Lattner
0e7489c9d5 implement AST support for labels on loops & switch statements. This also
improves location information to track the label location in the AST.  We
don't currently track the location of the colon, but that would be trivial
to drop in if it is interesting.


Swift SVN r16608
2014-04-21 04:56:55 +00:00
Doug Gregor
40b2c9f7a4 Create ParamDecls for function parameters in more places.
Swift SVN r16584
2014-04-20 05:57:34 +00:00
Doug Gregor
6b3ef547ec Replace "Members" arrays with an intrusive linked list.
The use of ASTContext-allocated arrays to store the members of nominal
type declarations and the extensions thereof is an
abomination. Instead, introduce the notion of an "iterable"
declaration context, which keeps track of the declarations within that
context (stored as a singly-linked list) and allows iteration over
them. When a member is added, it will also make sure that the member
goes into the lookup table for its context immediately.

This eliminates a ton of wasted memory when we have to reallocate the
members arrays for types and extensions, and moves us toward a much
more sane model. The only functionality change here is that the Clang
importer no longer puts subscript declarations into the wrong class,
nor does it nested a C struct within another C struct.



Swift SVN r16572
2014-04-19 23:37:06 +00:00
Doug Gregor
8e597cc695 Eliminate argument parameter patterns.
Swift SVN r16444
2014-04-17 05:20:14 +00:00
Doug Gregor
db439c1a4a Start introducing declaration names for more function declarations.
Swift SVN r16396
2014-04-16 04:52:07 +00:00
Jordan Rose
fc6b20369f Only generate derived conformance bodies for decls in the primary source file.
...and for decls imported from Clang, because those don't have home locations.

Fixes <rdar://problem/15936403>

Swift SVN r15831
2014-04-02 21:00:49 +00:00
Jordan Rose
63c1ef7ae4 Use delayed bodies for derived Equatable and Hashable conformances as well.
Still no functionality change.

Swift SVN r15829
2014-04-02 21:00:47 +00:00
Chris Lattner
1f275532a6 now that nothing uses the PatternBindingDecl::HasStorage bit, there is no
reason to compute it, store it, serialize it, etc.  Remove the associated
logic.



Swift SVN r15302
2014-03-20 22:49:43 +00:00
Dmitri Hrybenko
11fea869c1 Change 'switch' not to fall through between empty cases and always require at
least one statement per case

rdar://16301313


Swift SVN r15266
2014-03-20 11:44:59 +00:00
Doug Gregor
8cf018a1d2 Give Pattern::clone() an OptionSet rather than a bool; it's going to get more interesting.
Swift SVN r15061
2014-03-14 18:31:21 +00:00
Chris Lattner
18886e9a44 use the TupleExpr empty-tuple convenience ctor in a few obvious places.
Swift SVN r15021
2014-03-14 00:41:53 +00:00
Joe Groff
8e2521e8c2 SILGen: Emit derived '==' operators from Clang modules with shared linkage.
In Sema, give derived '==' definitions the module's DerivedFileUnit as their decl context instead of the more general Module, and give it a backreference to the nominal type for which it was derived. 
In SILGen, visit the derived global decls associated with Clang-imported enums, and give them shared linkage. Part of fixing <rdar://problem/16264703>.

Swift SVN r14875
2014-03-10 20:33:54 +00:00
Chris Lattner
2593a52b99 implement <rdar://problem/16191398> add an 'oldValue' to didSet so you can implement "didChange" properties
This names the implicit argument "oldValue".  Whether we keep implicit arguments or not
is a subject of debate, tracked by rdar://16268361.



Swift SVN r14819
2014-03-08 02:15:01 +00:00
Joe Groff
8e6b353542 Derive conformances of Equatable and Hashable for simple enums.
If an enum has no cases with payloads, make it implicitly Equatable and Hashable, and derive default implementations of '==' and 'hashValue'. Insert the derived '==' into module context wrapped in a new DerivedFileUnit kind, and arrange for it to be codegenned with the deriving EnumDecl by adding a 'DerivedOperatorDecls' array to NominalTypeDecls that gets visited at SILGen time.

Swift SVN r14471
2014-02-27 20:28:38 +00:00