Commit Graph

1132 Commits

Author SHA1 Message Date
Chris Lattner
42d0fdadcf - Introduce the ability for attributes to be inverted with !.
- Switch @mutable to be a tri-state attribute that is invertable with @!mutable.
- Move the semantic form of 'mutable' to being a bit on FuncDecl instead of
  something in DeclAttrs.  The former is a binary bit, the later is a tristate
  which differentiates between "not present", "present and set" "present and inverted".
- Diagnose some invalid uses of @mutable, e.g. on class methods.
- Make setters default to mutable, and allow them to be switched with @!mutable.



Swift SVN r11439
2013-12-18 21:38:53 +00:00
Doug Gregor
ec4913b0ea Implement default definitions for associated types.
Addresses <rdar://problem/14292873>.


Swift SVN r11422
2013-12-18 06:24:53 +00:00
Chris Lattner
51862b91fd rename the inout decl attribute (not the type attribute) to @mutating.
Swift SVN r11416
2013-12-18 04:44:56 +00:00
Jordan Rose
531b240ca0 [serialization] Rework cross-references to be more general / more robust.
Previously, cross-references just carried a chain of identifiers and a
top-level module, plus a type to validate against, a generic parameter index,
or an operator fixity. However, referencing "the first generic parameter
of the prefix function ++ that takes a ForwardIndex" requires /all three/
of these filters to unambiguously select the right declaration.

Now, cross-references consist of a chain of trailing records, one for each
link in the path. There are (currently) five kinds of links:

Type: a declaration that cannot have overloads
Value: a declaration that can have overloads (filtered by type)
Extension: filter to decls within extensions on another module
Operator:
- as the first path piece, an operator declaration
- as a later path piece, a fixity filter for operator functions
Generic Param: an indexed generic parameter of the previous result

This should allow us to uniquely cross-reference any Swift declaration we
need to.

Swift SVN r11399
2013-12-17 23:03:34 +00:00
Doug Gregor
11b6d19dd3 Add a location to NormalProtocolConformance.
This will be used for diagnostics in an upcoming refactor.


Swift SVN r11348
2013-12-16 17:24:15 +00:00
Doug Gregor
292192efac Record the value-witness-of relationship in the ASTContext as we assign witnesses.
Previously, this was being handled when we set conformances. We want
something lazier.


Swift SVN r11339
2013-12-16 02:49:37 +00:00
Doug Gregor
07c0793e30 Construct the type witnesses of SpecializedProtocolConformance lazily.
A SpecializedProtocolConformance intentionally contains all of the
information we need to synthesize the type witnesses from the
underlying (generic) conformance. Do so lazily rather than eagerly,
because we won't always need all of them.

As a nice side effect, we no longer need to serialize the witnesses of
these specialized protocol conformances, so we can save some space in
the Swift module file.


Swift SVN r11303
2013-12-14 06:20:44 +00:00
Chris Lattner
281cd524b7 recommit @inout attributes, now with serialization support.
Swift SVN r11286
2013-12-14 01:17:35 +00:00
Jordan Rose
65bd8536bc [serialization] Look for underlying conformances in refined protocol adopters.
That is, if we need a type MyIndex<T> to be a valid ForwardIndex, we should
be able to find it in the conformance for BidirectionalIndex, which inherits
from ForwardIndex.

<rdar://problem/15484898>

Swift SVN r11270
2013-12-13 21:42:51 +00:00
Jordan Rose
c2bd6eb2b0 Lazily deserialize members from AST files.
NominalTypeDecls and ExtensionDecls have a list of members. Rather than
eagerly populating that list when the nominal or extension is just referenced,
just include a pointer back to the ModuleFile, so that they can be
deserialized when we actually look into the decl. The design here is
general enough that we could do something similar with imported Clang decls.

Clang is even more lazy here: the on-disk representation is a hash table,
so lookup only forces deserialization of members with the same name. We
probably want that some day, but this might be enough to get by for now.

This is groundwork for loading partial ASTs, where eagerly deserializing
members leads to circular references we're not able to handle.

Swift SVN r11219
2013-12-12 23:31:15 +00:00
Jordan Rose
0fe774838b [serialization] Allocate an array on the ASTContext instead of the stack.
...oops.

Swift SVN r11218
2013-12-12 23:31:14 +00:00
Chris Lattner
698380d6d3 Introduce a new bit in VarDecl, "isLet". Teach Sema that 'isLet' properties
are not settable (like get-only ones).  Set the 'isLet' bit in various 
places, but not the particularly interesting or useful places yet.



Swift SVN r11121
2013-12-11 06:45:40 +00:00
Jordan Rose
fac5659813 [serialization] Sprinkle PrettyStackTrace throughout deserialization code.
Since we don't have soft-failure yet from deserialization, it's helpful to
at least know where to start looking when something crashes. There are some
rough edges here but it should be much better than nothing.

This also pulls the list of record nodes out into a separate file, so that
we can avoid repeating it.

Example crash:
1.	While reading from ./CTypes.swiftmodule
2.	While deserializing 'CBool' (StructDecl)
3.	While deserializing decl #26 (XREF)
4.	Cross-reference to 'LogicValue' in swift
(don't worry, this is an example where I'm tweaking things)

<rdar://problem/14838332>

Swift SVN r11057
2013-12-10 00:23:40 +00:00
Argyrios Kyrtzidis
55e2792f10 Serialize @IBLiveView attribute.
Swift SVN r10959
2013-12-07 00:41:58 +00:00
Argyrios Kyrtzidis
345564380c Rename 'ibaction/iboutlet' attributes to 'IBAction/IBOutlet'.
Swift SVN r10953
2013-12-07 00:14:51 +00:00
Joe Groff
0ff977d407 Add a 'WitnessMethod' enumerator to AbstractCC.
We'll use this to represent the slightly-different polymorphic calling convention used for passing Self into protocol witnesses.

Swift SVN r10898
2013-12-06 01:32:35 +00:00
Jordan Rose
8b8cc8ee62 Turn SerializedModule into SerializedASTFile.
Part of the FileUnit restructuring. A serialized module is now represented as
a TranslationUnit containing a single SerializedASTFile.

As part of this change, the FileUnit interface has been made virtual, rather
than switching on the Kind in every accessor. We think the operations
performed on files are sufficiently high-level that this shouldn't affect us.

A nice side effect of all this is that we now properly model the visibility
of modules imported into source files. Previously, we would always consider
the top-level imports of all files within a target, whether re-exported or
not.

We may still end up wanting to distinguish properties of a complete Swift
module file from a partial AST file, but we can do that within
SerializedModuleLoader.

Swift SVN r10832
2013-12-05 01:51:09 +00:00
Joe Groff
b06afcbf55 Ensure 'isStatic' bit of PatternBindingDecls is always initialized.
And that it gets serialized.

Swift SVN r10382
2013-11-12 23:12:16 +00:00
Joe Groff
4f2adbe7ed AST: Include 'static' bit in VarDecls.
And track the 'static' SourceLoc in the PatternBindingDecl. This lets isInstanceMember return the right thing for static vars.

Swift SVN r10369
2013-11-12 06:16:48 +00:00
Doug Gregor
dcb87f163c (De-)serialize @optional attributes.
Swift SVN r9996
2013-11-06 19:03:25 +00:00
Jordan Rose
63731584b6 [serialization] Introduce ModuleID, with codes for special modules.
ModuleID is compatible with IdentifierID, but uses 0 to mean “the builtin module”
and 1 to mean “the current module”. Anything else is a top-level module name,
as an identifier. As an implementation detail, 1 is now never a valid IdentifierID.
(0 remains “the empty string”.)

Using this, simplify the encoding of the owner of a conformance.

Swift SVN r9944
2013-11-04 23:50:46 +00:00
Manman Ren
c2188c8328 SIL Serializer: vtable can trigger serialiation of a SILFunction declaration.
Also add serialization of resilience attributes: Fragile, InherentlyFragile
and Resilient. Serialize VTables before SILFunctions because it may trigger
serializations of non-transparent SILFunctions.

Update funcOrOffset and vTableOrOffset when a SILFunction or a VTable is
de-serialized.

rdar://15165644


Swift SVN r9926
2013-11-04 18:17:34 +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
Doug Gregor
f342493144 Give every declaration an interface type.
For declarations that aren't generic and aren't in a generic context,
the interface type is the same as the normal type.


Swift SVN r9847
2013-10-31 17:38:42 +00:00
Doug Gregor
6201b72561 Give typealias declarations interface types.
Swift SVN r9781
2013-10-30 04:33:04 +00:00
Doug Gregor
03ebb9e4df Give interface types to subscript declarations.
Swift SVN r9731
2013-10-28 21:33:40 +00:00
Doug Gregor
45c78503b4 Compute interface types for enum elements.
Swift SVN r9710
2013-10-28 17:20:44 +00:00
Doug Gregor
9ea280e822 Assign interface types to instance variables/properties of generic types.
Swift SVN r9688
2013-10-26 03:02:36 +00:00
Jordan Rose
cf31df96c5 Push operator lookup into SourceFile, and simplify the interface.
The operator lookup cache already lived in SourceFile, but we need to be
able to look up operators on a per-SourceFile basis. Different files can
have different imports. The interface previously distinguished between
"no operator found" and "error", but none of the call sites were making
use of this distinction, and indeed some were misusing the return value
(Optional<SomeOperatorDecl *>). Now the lookup functions just return
operator decl pointers, which may be null.

Swift SVN r9668
2013-10-25 17:30:33 +00:00
Doug Gregor
cd0299f85a Push get/setInterfaceType() up to ValueDecl.
No functionality change here.


Swift SVN r9552
2013-10-21 19:05:02 +00:00
Doug Gregor
d7a1d536b4 Introduce value witness markers into the generic set of requirements.
Value witness markers note the location within a generic function
type's list of requirements where the value witness table will be
placed when calling a generic function with that type. It allows one
to get the same effect from walking the requirements of a generic
function that one would get from walking all levels of a
GenericParamList, with all archetypes of each generic parameter list,
along with all of the protocols to which each archetype conforms,
which SILGen and IRGen both do.

AST verification ensures that the property above holds; we're not
making use of it just yet.


Swift SVN r9509
2013-10-19 00:19:01 +00:00
Joe Groff
5721bdda01 Don't pretend we can parse enum case refined types.
There's no way we'll be able to fully implement GADTs anytime soon.

Swift SVN r9477
2013-10-18 01:34:25 +00:00
Jordan Rose
7277b129b5 [serialization] Handle @transparent on constructors and extensions as well.
Thanks for catching this, Dmitri and Joe.

Swift SVN r9354
2013-10-15 18:02:49 +00:00
Chris Lattner
09705dc7cd 1) Redesign DeclAttributes to be based around an array indexed by attribute, instead
of having a ton of ad-hoc bools in it.  This allows us to consolidate a ton of 
   boilerplate, eliminating 250 lines of code:

 17 files changed, 435 insertions(+), 662 deletions(-)

2) This eliminates the special case for weak and unowned attributes, which previously
   didn't show up in Attr.def.

3) While we're at it, keep track of proper source locations for each attribute, and
   use these to emit diagnostics pointing at the attribute in question instead of at
   a funcdecl or the @ sign.

4) Fix axle attributes, which had vertex and fragment swapped.



Swift SVN r9263
2013-10-13 01:25:50 +00:00
John McCall
8fbc790d39 Subsume OwnershipConventions into SILFunctionType.
Swift SVN r9186
2013-10-11 00:50:57 +00:00
John McCall
af706c889a swift::SILFunctionType::ParameterType -> swift::SILParameterInfo
swift::SILFunctionType::ReturnType -> swift::SILReturnInfo

Swift SVN r9116
2013-10-10 00:31:38 +00:00
Doug Gregor
7fee09b41e Axle: Implement Matrix<T, N> and Matrix<T, N, M> syntactic sugar.
This completes the majority of <rdar://problem/15100137>.


Swift SVN r9098
2013-10-09 22:24:21 +00:00
Doug Gregor
fba128e191 Axle: Implement Vec<T, N> syntactic sugar for the VecTxN structs.
Implements the first part of <rdar://problem/15100137>.


Swift SVN r9092
2013-10-09 21:12:19 +00:00
John McCall
a38abec9fe Introduce (but don't yet use) SILFunctionType.
Swift SVN r9088
2013-10-09 20:55:42 +00:00
Doug Gregor
a012f60633 Make protocol methods generic over <Self>.
Pull the implicit 'Self' associated type out of the protocol and into
an implicitly-declared generic parameter list for the protocol. This
makes all of the methods of a protocol polymorphic, e.g., given

  protocol P {
    typealias Assoc
    func getAssoc() -> Assoc
  }

the type of P.getAssoc is:

  <Self : P> (self : @inout P) -> () -> Self.Assoc

This directly expresses the notion that protocol methods are
polymorphic, even though 'Self' is always implicitly bound. It can be
used to simplify IRgen and some parts of the type checker, as well as
laying more of the groundwork for default definitions within
protocols as well as sundry other improvements to the generics
system.

There are a number of moving parts that needed to be updated in tandem
for this. In no particular order:
  - Protocols always get an implicit generic parameter list, with a
  single generic parameter 'Self' that conforms to the protocol itself.
  - The 'Self' archetype type now knows which protocol it is
  associated with (since we can no longer point it at the Self
  associated type declaration).
  - Protocol methods now get interface types (i.e., canonicalizable
  dependent function types).
  - The "all archetypes" list for a polymorphic function type does not
  include the Self archetype nor its nested types, because they are
  handled implicitly. This avoids the need to rework IRGen's handling
  of archetypes for now.
  - When (de-)serializing a XREF for a function type that has an
  interface type, use the canonicalized interface type, which can be
  meaningfully compared during deserialization (unlike the
  PolymorphicFunctionType we'd otherwise be dealing with).
  - Added a SIL-specific type attribute @sil_self, which extracts the
  'Self' archetype of a protocol, because we can no longer refer to
  the associated type "P.Self". 




Swift SVN r9066
2013-10-09 17:27:58 +00:00
Doug Gregor
d33d78acac Compute interface types for constructors.
Swift SVN r8992
2013-10-07 21:51:11 +00:00
Doug Gregor
abeaef8996 Track the generic parameters and requirements of nominal type declarations.
Put generic nominal type declarations through the same dependent-type
validation as generic functions, then capture their generic parameters
and requirements in their generic signature. This allows us to
re-instate the requirements in their dependent forms, before the
archetypes ruin them completely.


Swift SVN r8958
2013-10-07 16:21:25 +00:00
Argyrios Kyrtzidis
963b6f0579 [serialization] Introduce 'FailedImportModule', which is used to track of when a module file failed to load (e.g. because of missing dependencies).
Swift SVN r8934
2013-10-04 21:29:24 +00:00
Doug Gregor
36df570c15 Record the generic type of a generic function as its "interface" type.
We're still not using the interface type for anything, but record it
and serialize/deserialize it.


Swift SVN r8897
2013-10-04 00:14:04 +00:00
Doug Gregor
12e228c0f1 Introduce a new representation of polymorphic function types.
Introduces a new kind of function type, GenericFunctionType, that
represents a polymorphic function type with all of its generic
parameters and requirements stored in a more readily canonicalizable
form. It is meant to eventually replace PolymorphicFunctionType, but
for now we build it up in parallel so we can switch over to it
pieacemeal.

Note: this representation is built and then thrown away. We'll start
recording it soon.


Swift SVN r8881
2013-10-03 17:59:35 +00:00
Doug Gregor
f5d4269f53 Parameterize the resolution of generic type parameter types to archetypes.
When type checking, allow the caller to customize the resolution of generic
type parameter types based on the context, for example, by choosing to
substitute in an archetype (or not) and allowing one to resolve a dependent
member reference via a specific archetype.

No actual functionality change here.


Swift SVN r8797
2013-09-30 23:24:53 +00:00
Argyrios Kyrtzidis
f0773bcba1 Rename '__subscript' -> 'subscript'.
Since 'subscript' is a keyword, it cannot conflict with a function name.

Swift SVN r8787
2013-09-30 19:17:29 +00:00
Dmitri Hrybenko
9ba4347a66 Serialize EnumDecl::RawType in binary modules
Will be tested by printing of deserialized ASTs.


Swift SVN r8715
2013-09-27 01:51:34 +00:00
Dmitri Hrybenko
ba2e4732d0 Remove unused member EnumDecl::isEnum
Swift SVN r8710
2013-09-27 00:22:39 +00:00
Jordan Rose
e05c03d5bc Standardize terminology for "computed", "stored", "variable", and "property".
These are the terms sent out in the proposal last week and described in
StoredAndComputedVariables.rst.

variable
  anything declared with 'var'
member variable
  a variable inside a nominal type (may be an instance variable or not)
property
  another term for "member variable"
computed variable
  a variable with a custom getter or setter
stored variable
  a variable with backing storage; any non-computed variable

These terms pre-exist in SIL and IRGen, so I only attempted to solidify
their definitions. Other than the use of "field" for "tuple element",
none of these should be exposed to users.

field
  a tuple element, or
  the underlying storage for a stored variable in a struct or class
physical
  describes an entity whose value can be accessed directly
logical
  describes an entity whose value must be accessed through some accessor

Swift SVN r8698
2013-09-26 18:50:44 +00:00