Commit Graph

2038 Commits

Author SHA1 Message Date
Dmitri Hrybenko
46fbf21e59 Remove trailing whitespace
Swift SVN r15454
2014-03-25 14:48:12 +00:00
Chris Lattner
0bec9700e8 Add a hack to the ASTPrinter, when printing PatternBindingDecls to print
immutable variables with a let prefix instead of a 'var' prefix.  This allows
us to AST print this as 'let' instead of 'var', which isn't totally awesome,
but is better than misleading people with var.

func f() {
  let x : Int  = 42
}

Also, fix the SILPrinter to explode pattern binding decls, so that it doesn't
fall into the booby traps inherent in PatternBindingDecl printing.


Swift SVN r15393
2014-03-23 16:37:51 +00:00
Chris Lattner
4b0808f47e revert r15378. It turns out that PatternBindingDecls are the ones that are botching
the immutability issue.


Swift SVN r15392
2014-03-23 16:17:55 +00:00
Chris Lattner
00e546adda fix the AST printer to print "let" for let variables.
Swift SVN r15378
2014-03-23 05:24:53 +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
John McCall
c40a2e54b2 Extract a method to print a CheckedCastKind and dump
it on CheckedCastExprs.

Swift SVN r15245
2014-03-19 20:25:09 +00:00
Doug Gregor
39da9742b1 AST printing for functions where the first parameter has a separate name.
Swift SVN r15141
2014-03-17 16:36:06 +00:00
Joe Groff
34400bd64b Add 'print' and 'dump' methods to GenericSignature.
Swift SVN r14944
2014-03-12 00:50:41 +00:00
Joe Groff
b08f06f191 Revert "Accept (and prefer) "import type" as a scoped import for any non-protocol type."
This reverts commit r14488, since we're demoting 'type' back to a plain old identifier.

We could consider reallowing 'type' as a contextual keyword here, but from talking to Jordan he was OK with just reverting this functionality.

Swift SVN r14931
2014-03-11 23:18:30 +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
Chris Lattner
11bedff2f3 the swift.Slice type got removed a long time ago, being replaced with
what is now Swift.Array.  Update various internal stuff to refer to
Array instead of Slice.  NFC.


Swift SVN r14567
2014-03-02 06:21:37 +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
Jordan Rose
1fe8630bcd Accept (and prefer) "import type" as a scoped import for any non-protocol type.
Previously this was spelled "import typealias", and that spelling will
continue to be allowed (since someone may specifically be importing a
typealias and want that to match), but now that 'type' is a keyword,
"import type" is the right way to spell the generic "import any type"
scoped import.

Swift SVN r14488
2014-02-27 23:46:06 +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
Doug Gregor
1e8f02a45d Start diagnosing "deinit () { }".
Now that we do this, update the standard library, tests, other documents, etc.

Swift SVN r14423
2014-02-26 23:01:25 +00:00
Dmitri Hrybenko
ae535f34f0 AST Printer: fix printing of willSet/didSet
Swift SVN r14391
2014-02-26 12:15:54 +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
Doug Gregor
0bde325327 Collapse 'DynamicSelf' into 'Self'.
Swift SVN r14377
2014-02-26 05:04:05 +00:00
Joe Groff
98d6fecc99 '.metatype' -> '.Type'
Also, reserve 'type' as a keyword for ensuing syntax changes.

Swift SVN r14375
2014-02-26 04:23:21 +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
Dmitri Hrybenko
38ca644b77 Fix prining of 'inout' in types
This completes the fix for rdar://15999689


Swift SVN r14303
2014-02-24 15:48:43 +00:00
Dmitri Hrybenko
71f818b77f Fix prining of 'inout' in declarations
Partially addresses rdar://15999689


Swift SVN r14302
2014-02-24 15:25:00 +00:00
Dmitri Hrybenko
94eb4f986a Module interface printing: don't print { get set } when it is the default
rdar://16070050


Swift SVN r14286
2014-02-23 15:14:28 +00:00
Dmitri Hrybenko
3da05e347d Change property accessor syntax to include braces
See release notes update for details.

rdar://15966905


Swift SVN r14271
2014-02-22 21:00:56 +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
Dmitri Hrybenko
0fe2b682bd Fix spaces in AST printer results for { get set }
Swift SVN r14143
2014-02-20 11:50:32 +00:00
Doug Gregor
a1673d7c8f Add an Objective-C metatype representation spelled with @objc_metatype.
This representation is just a placeholder at the moment.


Swift SVN r14076
2014-02-19 07:21:38 +00:00
Doug Gregor
c54f98fbc9 Convert thick/thin metatype bool to an enumeration. NFC
Swift SVN r14075
2014-02-19 06:05:48 +00:00
Chris Lattner
ecbbb4a42c rework our representations of subscripts to not curry the indexes
separately from the get/set value.  There is no exposed way in the
source language to use this, and this causes shorter term annoyance.

I chose to flatten the value and indices so the value comes first.
In principle, this allows us to completely eliminate our ObjC importer
thunks.  I haven't removed them though, because they might be useful
for something else.


Swift SVN r14049
2014-02-18 21:34:33 +00:00
Doug Gregor
9d41af15b6 Make SIL output for open_existential actually parseable.
Swift SVN r13939
2014-02-15 05:52:19 +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
a6640a1b12 Rework has .sil files handle computed vardecls and subscripts.
Previously, we would just parse vars and subscripts with no definitions,
then let getters and setters be referenced arbitrarily later.  This was
problematic for a number of reasons, not least of which, the .sil file
might be invalid.

Instead, change sil to require that a protocol style definition indicate
whether a vardecl/subscript is computed or not, and whether it is both 
get-able and set-able, e.g. like "var x : Int { get }".  Change the 
sil printer to print decls in this form, and change the SILParser to 
make SILDeclRef::Func values instead of ::Getter/Setter values.

One thing that this exposed is that we weren't correctly serializing the
accessor state in modules, so accessors would get detatched from their
AbstractStorageDecls when deserialized (and in fact, their ASD never got
deserialized at all in some cases).  Fix this in the serialization of
the accessors.

NFC, other than the SIL printer and parser.



Swift SVN r13884
2014-02-14 00:57:04 +00:00
Dmitri Hrybenko
5fa3e49b91 AST printer: don't print module qualification on declarations from 'ObjectiveC'
module

rdar://16015774


Swift SVN r13838
2014-02-12 20:53:36 +00:00
Joe Groff
fb2ebf59f7 SIL: Parse and print SILFunction's context generic params.
- Alter parseSILType to take an optional GenericParamList out param to take the parsed GenericParamList, and use this to set the GenericParamList of parsed SILFunctions independent of their lowered type.
- Add a ContextGenericParams field to PrintOptions which, when set, provides a set of archetypes to print in place of the dependent types in an interface type.
- Use this to print the type of SILFunctions using their context generic params.

Swift SVN r13774
2014-02-11 04:03:59 +00:00
Doug Gregor
474016398f Model references to DynamicSelf methods on existentials by opening the existential.
Introduce a new expression kind, OpenExistentialExpr, that "opens" up
an existential value into a value of a fresh archetype type that
represents the dynamic type of the existential. That value can be
referenced (via an OpaqueValueExpr) within the within the
subexpression of OpenExistentialExpr. For example, a call to a
DynamicSelf method on an existential looks something like this:

        (open_existential_expr implicit type='P'
          (opaque_value_expr implicit type='opened P' @ 0x7fd95207c290
          unique)
          (load_expr implicit type='P'
            (declref_expr type='@lvalue P' decl=t.(file).func
          decl.p@t.swift:5:37 specialized=no))
          (erasure_expr implicit type='P'
            (call_expr type='opened P'
              (archetype_member_ref_expr type='() -> opened P'
          decl=t.(file).P.f@t.swift:2:8 [with Self=opened P]
                (opaque_value_expr implicit type='opened P' @
          0x7fd95207c290 unique))
              (tuple_expr type='()')))))

Note that we're using archetype_member_ref_expr rather than
existential_member_ref_expr, because the call is operating on the
opaque_value_expr of archetype type. The outer erasure turns the
archetype value back into an existential value.

The SILGen side of this is somewhat incomplete; we're using
project_existential[_ref] to open the existential, which is almost
correct: it gives us access to the value as an archetype, but IRGen
doesn't know to treat the archetype type as a fresh archetype whose
conformances come from the existential. Additionally, the output of
the opened type is not properly parsable. I'll fix this in follow-on
commits.

Finally, the type checker very narrowly introduces support for
OpenExistentialExpr as it pertains to DynamicSelf. However, this can
generalize to support all accesses into existentials, eliminating the
need for ExistentialMemberRef and ExistentialSubscript in the AST and
protocol_method in SIL, as well as enabling more advanced existential
features should we want them later.



Swift SVN r13740
2014-02-10 06:44:44 +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
Chris Lattner
79cbda7f88 convert a heck of a lot of tests to use the new inout syntax (yay for regex's),
and implement code completion and ast-printer support for the new syntax.



Swift SVN r13562
2014-02-06 05:35:36 +00:00
Chris Lattner
63dc900f91 Pattern processing cleanups, NFC:
Introduce a new Pattern::forEachVariable that takes a lambda and iterates
over all the variables encompassed by the pattern (the ones found by
collectVariables) and runs the lambda on it.

Use this to implement collectVariables, so we only have one copy of the code.

Convert several places to use this, removing a bunch of duplicated code for
walking the pattern structure and extracting decls.

Convert a few uses of collectVariables to forEachVariable, leading to more
clear code without a temporary smallvector.

Remove simplifyPatternTypes in CSApply.cpp, which is dead.



Swift SVN r13545
2014-02-06 01:52:35 +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
Chris Lattner
3e08673772 Introduce patterns for self arguments to ctors and dtors, making them uniform
with FuncDecls.  This allows us to eliminate special case code for handling
self in various parts of the compiler.

This also improves loc info (debug info and AST info) because 'self' now
has a location instead of being invalid.

I also took the opportunity to factor a bunch of places creating self decls
to use similar patterns and less copy and paste code.



Swift SVN r13196
2014-01-31 02:17:22 +00:00
Doug Gregor
030770a8c2 Make DynamicSelf into its own special type node.
Making DynamicSelf its own special type node makes it easier to opt-in
to the behavior we want rather than opting out of the behavior we
don't want. Some things already work better with this representation,
such as mangling and overriding; others are more broken, such as the
handling of DynamicSelf within generic classes and the lookup of the
DynamicSelf type.


Swift SVN r13141
2014-01-30 05:36:20 +00:00
Chris Lattner
e668e86cc3 With many prerequisites out of the way, lets start actually working on didset/willset
properties.  This step provides AST support to model them.


Swift SVN r13011
2014-01-27 22:11:16 +00:00
Chris Lattner
929ad99f08 Clean up and generalize the code pertaining to how a FuncDecl accessor
knows about the AbstractStorageDecl it works on.  NFC.



Swift SVN r12994
2014-01-27 17:57:38 +00:00
Chris Lattner
f5b85341a1 Expand out the "isComputed" property in AbstractStorageDecl to be an enum
with two kinds, and some more specific predicates that clients can use.

The notion of 'computed or not' isn't specific enough for how properties
are accessed.  We already have problems with ObjC properties that are 
stored but usually accessed through getters and setters, and a bool here
isn't helping matters.

NFC.



Swift SVN r12593
2014-01-20 18:16:30 +00:00
Joe Groff
0776c4b6b8 SIL: Reorient function type lowering toward interface types.
Lower types for SILDeclRefs from the interface types of their referents, dragging the old type along for the ride so we can still offer the context to clients that haven't been weaned off of it. Make SILFunctionType's interface types and generic signature independent arguments of its  Derive the context types of SILFunctionType from the interface types, instead of the other way around. Do a bunch of annoying inseparable work in the AST and IRGen to accommodate the switchover.

Swift SVN r12536
2014-01-18 19:42:02 +00:00
John McCall
1bc1c669a2 Add the '@unchecked T?' syntactic sugar for UncheckedOptional<T>.
Swift SVN r12128
2014-01-10 19:13:51 +00:00
Manman Ren
ce642b89f7 Move printing of DeclAttributes from PrintAST::printAttributes to
DeclAttributes::print.

Also add printing of mutating to the print functions.
In serializer, print out the unhandled attributes.


Swift SVN r12073
2014-01-08 23:44:05 +00:00
Doug Gregor
9412c07dea Switch 'static' to 'type' in tests.
Switch some diagnostic text from 'static' over to 'type' to make
things easier, and fix up some parsing issues with selector-style
declarations found by doing this. NFC


Swift SVN r12030
2014-01-08 01:37:32 +00:00