Commit Graph

3502 Commits

Author SHA1 Message Date
John McCall
69855ba446 Extract a method to generate the all-archetypes list
of a set of generic parameters, and use it to verify
that the stored list matches what we expect.

Swift SVN r14693
2014-03-05 22:41:25 +00:00
Chris Lattner
7bbd9b05a5 Rename DynamicLookup -> AnyObject in a few more comments. This leaves
the DynamicLookupExpr expression and the DeclVisibilityKind::DynamicLookup
enum.  These seem right to me, more descriptive than renaming them AnyObject.
With this, I consider 13327098 to be done.



Swift SVN r14654
2014-03-04 22:17:38 +00:00
Chris Lattner
d758e0dfe3 Eliminate more "DynamicLookup" in favor of "AnyObject", this is the
bulk of finishing rdar://13327098.


Swift SVN r14653
2014-03-04 22:15:46 +00:00
Doug Gregor
15be2159a2 Rename "abstract initializers" to "required initializers".
It's better than what we have.

Swift SVN r14620
2014-03-03 23:12:40 +00:00
Doug Gregor
2c26523201 Require chaining to the superclass initializer to refer to a subobject initializer.
Swift SVN r14601
2014-03-03 18:47:09 +00:00
Doug Gregor
a77d08f5a1 Use inherited initializers rather than cloning for Objective-C classes.
Make Objective-C initializers inherited according to the inheritance
rules we've specified. Prevent the Clang importer from manually
copying all of the initializers from every superclass into each
class. 

This eliminates a ton of extra allocating constructors generated when
importing Objective-C init methods. Now we only generate allocating
constructors for the init methods that are actually declared.

Note that initializer inheritance only actually works for
Objective-C-defined classes. More to come.



Swift SVN r14563
2014-03-02 01:59:54 +00:00
Doug Gregor
8f64658fc1 Misc. cleanups related to SuperRefExpr queries.
Swift SVN r14558
2014-03-01 18:54:34 +00:00
Joe Groff
179b101e6f Serialization: Serialize compound names of FuncDecls.
Store the name components as a BCArray, and push the asmname BCBlob into an optional trailing record layout.

Swift SVN r14556
2014-03-01 04:10:33 +00:00
Joe Groff
3226bae79b Add missing early return, and simplify initialization loop using uninitialized_copy.
Thanks Jordan!

Swift SVN r14555
2014-03-01 04:10:29 +00:00
Doug Gregor
d92f1a3158 Inherit complete object initializers when a class supports it.
Teach name lookup to find complete object initializers in its
superclass when the current class overrides all of the subobject
initializers of its direct superclass.

Clean up the implicit declaration of constructors, so we don't rely on
callers in the type checker doing the right thing.

When we refer to a constructor within the type checker, always use the
type through which the constructor was found as the result of
construction, so that we can type-check uses of inherited complete
object initializers. Fixed a problem with the creation of
OpenExistentialExprs when the base object is a metatype.

The changes to the code completion tests are an improvement: we're
generating ExprSpecific completion results when referring to the
superclass initializer with the same signature as the initializer
we're in after "super.".

Swift SVN r14551
2014-03-01 00:51:21 +00:00
Doug Gregor
571ae697d5 Parsing and AST support for complete object initializers.
Enforce that complete object initializers always be delegating.

Swift SVN r14549
2014-03-01 00:51:18 +00:00
Joe Groff
f12f7d3b54 AST: "ValueName" -> "DeclName", and pack it in a single word.
Swift SVN r14541
2014-02-28 23:44:18 +00:00
Joe Groff
ca1b524740 AST: Relax the signature of FuncDecl factories to allow them to be constructed with compound names.
These are the only kinds of decl that will actually have compound names in practice in the short term. Initializers can have selector pieces too, but cannot be referenced outside of a constructor call, so their AST names don't matter.

Swift SVN r14540
2014-02-28 23:44:17 +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
Dmitri Hrybenko
54a39dfeb8 Allow type checking qualified references to generic nominals with free type
variables

This change allows the type checker to create member references to generic
nominals with free type variables -- see tests.  This is important for code
completion, for example, swift.Dictionary.#^A^#

Fixes rdar://15980316


Swift SVN r14461
2014-02-27 14:40:28 +00:00
Chris Lattner
1344319677 Rename the internal compiler lexicon from val -> let.
Swift SVN r14408
2014-02-26 21:21:18 +00:00
Doug Gregor
981f8f6509 Rename "destructor" -> "deinit" (as a keyword) and -> "deinitializer" (in diagnostics).
Swift SVN r14380
2014-02-26 05:51:45 +00:00
Chris Lattner
b2b15d2d88 Fix <rdar://problem/16151899> init method shouldn't directly access superclasses ivars
Swift SVN r14336
2014-02-25 07:08:54 +00:00
Chris Lattner
7f4c0b981c rename the StoredObjC storage class to StoredWithTrivialAccessors since
we'll be using it for more general things soon.  NFC.


Swift SVN r14329
2014-02-25 01:08:27 +00:00
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00
Doug Gregor
b5af687b6d Emit and use vtable entries for abstract initializers.
Emit vtable entries for abstract initializers. When we're constructing
an object using an abstract initializer based on a metatype value that
is not statically derivable, use the vtable entry to call the
subclass's allocating constructor.

Most of the IRGen work here is hacking around the lossy SILDeclRef ->
(Code|Function)Ref -> SILDeclRef conversion. I'd feel bad about this
if John hadn't already agreed to clean this up at some point.



Swift SVN r14238
2014-02-21 23:15:46 +00:00
Doug Gregor
0da11a8b0b Implement semantic analysis for abstract initializers.
Swift SVN r14221
2014-02-21 19:41:14 +00:00
Argyrios Kyrtzidis
eeb9589d2c [AST] Introduce "hasName()" convenience methods and replace "getName().empty()" callers.
Swift SVN r14206
2014-02-21 15:00:38 +00:00
Jordan Rose
0b2541b58f Rename the standard library to "Swift" (instead of "swift")
This is more in line with all other modules currently on our system.
If/when we get our final name for the language, we're at least now set
up to rename the library without /too/ much trouble. (This is mostly just
a lot of searching for "import swift", "swift.", "'swift'", and '"swift"'.
The compiler itself is pretty much just using STDLIB_NAME consistently now,
per r13758.)

<rdar://problem/15972383>

Swift SVN r14001
2014-02-17 19:30:47 +00:00
Chris Lattner
28903887e7 Rename the internal compiler lexicon from let -> val.
Swift SVN r13992
2014-02-17 16:48:21 +00:00
Dmitri Hrybenko
571c9b3c5e Split 'type' keyword into 'static' and 'class'
rdar://15911697


Swift SVN r13908
2014-02-14 14:50:32 +00:00
Chris Lattner
9ee7d99a46 switch a few things off of argument patterns, onto body patterns.
Swift SVN r13891
2014-02-14 01:33:14 +00:00
Chris Lattner
3f7d3877a4 Re-commit r13836 with more correctness this time:
Sink the getObjCGetterSelector/Setter methods from VarDecl/SubscriptDecl down to
AbstractStorageDecl.  NFC.



Swift SVN r13842
2014-02-12 22:49:47 +00:00
Mark Lacey
525c9323cc Revert "since the getObjCGetterSelector/Setter methods from VarDecl/SubscriptDecl down"
This reverts commit r13836, since it broke the build.

Swift SVN r13839
2014-02-12 20:59:24 +00:00
Joe Groff
5c9470b9ca AST: Shun empty GenericSignatures, and remove the ASTContext argument from GenericSignature factories.
GenericSignatures with no params or requirements are a bug, so verify that they don't happen by making GenericSignature::get return null and GenericFunctionType assert that it has a nonnull signature. Hack Sema not to try to produce nongeneric GenericFunctionTypes when a function in a local type in a generic function context is type-checked; there's a deeper modeling issue that needs to be fixed here, but that's beyond the scope of 1.0. Now that GenericSignature always has at least one subtype, its factories no longer need an independent ASTContext argument.

Swift SVN r13837
2014-02-12 19:17:27 +00:00
Chris Lattner
c23185d9ba since the getObjCGetterSelector/Setter methods from VarDecl/SubscriptDecl down
to AbstractStorageDecl, NFC.


Swift SVN r13836
2014-02-12 19:16:40 +00:00
Joe Groff
e880da0b71 AST: Add canonical generic signatures.
For better type safety in SILFunctionTypes, which always want canonical types, and to provide a unique place to hang information common to all equivalent generic signatures, give GenericSignatures a concept of being "canonical".

Swift SVN r13794
2014-02-12 00:32:02 +00:00
Chris Lattner
ba0f502a02 Implement <rdar://problem/16034296> observing properties should not be mutable in their willset method
Swift SVN r13783
2014-02-11 07:09:08 +00:00
Chris Lattner
b56d46b8c9 Teach sema that uses of local observing properties are direct when in
the accessors.  This completes:
<rdar://problem/15922884> support non-member observing properties



Swift SVN r13782
2014-02-11 06:57:41 +00:00
Chris Lattner
70d547c1da remove a bunch of code that is manually monkeying around with DeclContexts,
now that they are implicitly updated.  This exposes two things:
1) we're unncessarily serializing selfdecls in ctors and dtors.
2) The index pattern of a SubscriptDecl has no sensible DeclContext that 
   owns variables in it.

I'll deal with the first tomorrow, I'm not sure what to do with
the second one.


Swift SVN r13703
2014-02-09 07:36:18 +00:00
Chris Lattner
ce9d97c2b9 similar to the previous patch, have all NominalTypeDecls auto-reparent
all of their generic parameters.  This simplifies logic creating them,
allowing us to eliminate all setDeclContext() calls from the parser.

While we're at it, change Parser::addVarsToScope to be a static 
function in ParseStmt.cpp and dramatically cut it down since none of
its remaining clients are using most of its capabilities.  It needs
to be simplified even further.


Swift SVN r13702
2014-02-09 07:20:03 +00:00
Chris Lattner
40316dc769 Change FuncDecl/CtorDecl/DTorDecl/ClosureExpr constructors to
automatically reparent VarDecls in their arg/body patterns and
GenericParameters to themselves.  These all have to be created
before the actual context decl is created and then reparented,
so we might as well have the reparenting be done by the decl
itself.  This lets us take out some setDeclContext reparenting
loops from around the parser.  

I'm sure that there are a lot more places they can be removed
from as well.

NFC.


Swift SVN r13701
2014-02-09 07:02:33 +00:00
Joe Groff
05daca8e79 IRGen: Use interface types to implement the PolymorphicConvention.
Refactor the base PolymorphicConvention implementation to work using generic signatures and dependent types instead of GenericParamLists and archetypes, using an ArchetypeBuilder to produce representative archetypes as a convenience when we need to consider all of the requirements attached to a dependent type. In EmitPolymorphicParameters, map the dependent types into context to resolve the archetypes that should be bound in the body of the function.

Swift SVN r13685
2014-02-08 21:04:15 +00:00
Doug Gregor
a47917246c Import Objective-C properties with custom getter/setter methods.
Retrieve the getter/setter selector from the underlying Clang node,
when there is one. This allows using and overriding Objective-C
properties that have custom getters and setters (i.e., for Boolean
properties where the getter is named isPropName), which narrowly
addresses <rdar://problem/15877160>.

One cannot declare a property in Swift and give it a different
selector. That would require a more general attribute such as
<rdar://problem/16019773>.



Swift SVN r13680
2014-02-08 17:04:31 +00:00
Joe Groff
06b7ca2855 AST: Include "Self" and associated archetypes in AllArchetypes of a GenericParamList.
The need to hide Self from AllArchetypes of a GenericParamList is (almost) defined away by @cc(witness_method); IRGen now knows how to do the right thing for witnesses regardless of their generic signature. Eliminating this special case from the AST allows us to clear up a bunch of ugly hacks that piled up elsewhere to try to accommodate that special case, and makes the prospect of moving IRGen's PolymorphicConvention to interface types more manageable.

We do need an unfortunate hack to suppress emitting associated archetypes of Self when considering an archetype as the polymorphic source for a witness, since we can't actually pass those through the witness CC without breaking ABI compatibility between generic signatures.

Swift SVN r13663
2014-02-07 23:24:51 +00:00
Jordan Rose
532a6e0bd3 [swift2objc] Handle properties.
All properties are considered nonatomic. If a property comes from Objective-C,
the accessor names may be customized, so always print them out in that case.

Swift SVN r13644
2014-02-07 19:31:26 +00:00
Chris Lattner
a2579527e9 rearrange how the get/set decls are synthesized for observing properties. Now the
parser creates the get/set decls, and sema fills them in, instead of having sema 
do all the work.  This makes it easier to update DeclContexts in all cases.


Swift SVN r13597
2014-02-06 21:36:01 +00:00
Chris Lattner
595817bd89 Rename data structures relating to WillSetDidSet properties to call them "Observing"
properties internally to the compiler.  NFC.


Swift SVN r13587
2014-02-06 17:51:45 +00:00
Chris Lattner
827acad533 Various inout improvements:
- purge @inout from comments in the compiler except for places talking about
   the SIL argument convention.
 - change diagnostics to not refer to @inout
 - Change the astprinter to print InoutType without the @, so it doesn't show
   up in diagnostics or in closure argument types in code completion.
 - Implement type parsing support for the new inout syntax (before we just 
   handled patterns).
 - Switch the last couple of uses in the stdlib (in types) to inout.
 - Various testcase updates (more to come).



Swift SVN r13564
2014-02-06 06:22:27 +00:00
Joe Pamer
e06f98cabd Protect against upstream errors when resolving the 'self' type of an initializer method.
When type checking constructors, ensure that any upstream errors in the resolution of the self type are accounted for (rather than assuming that the self type is always well-formed).  Not doing so can be especially problematic within the context of a type extension, since there may not even be a self type to resolve to.

Swift SVN r13506
2014-02-05 21:06:35 +00:00
Sonny Falk
35f7bdff0f Rename local variable startLoc to StartLoc. NFC.
Swift SVN r13438
2014-02-04 18:31:20 +00:00
Sonny Falk
3715f632cf Update the source range for FuncDecl to include the proper start location for type functions, using getStartLoc().
This addresses <rdar://problem/15969165>.

Swift SVN r13435
2014-02-04 18:11:32 +00:00
Chris Lattner
9f32d521a2 now that ctors and dtors have self patterns, we can unify and simplify the
implementation of AbstractFuncDecl::getImplicitSelfDecl() and eliminate
the ImplicitSelfDeclAndIsCached ivar.


Swift SVN r13351
2014-02-03 15:17:21 +00:00
Doug Gregor
995d8732f3 The self type behind a DynamicSelf for a protocol is 'Self', not the protocol.
We can now emit witness tables for conformances to protocols
containing DynamicSelf methods.

This temporarily "breaks" uses of DynamicSelf methods on
existentials. We'll come back to that.


Swift SVN r13310
2014-02-02 02:23:40 +00:00
Argyrios Kyrtzidis
48023490de [AST] Move AccessorKind enum to top-level so it can be forward declared.
No functionality change.

Swift SVN r13299
2014-02-01 08:50:15 +00:00