Commit Graph

985 Commits

Author SHA1 Message Date
Doug Gregor
048c67350b Move the diagnostic about a missing initializer body into Sema.
We did this for func declarations a long time ago; do it for
initializers as well.


Swift SVN r14318
2014-02-24 22:22:29 +00:00
Dave Abrahams
32c5122c92 Fix diagnostic: s/container/Sequence/
Swift SVN r14313
2014-02-24 21:08:04 +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
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
Chris Lattner
602da91d1c switch diagnostics from let -> val.
Swift SVN r13990
2014-02-17 16:22:39 +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
Dave Zarzycki
ee01278616 Revert "Diagnostics: 'let' is spelled 'val' now"
Never mind. 'let' is still accepted. We shouldn't fix this until we're
ready to commit to 'val'.

Swift SVN r13873
2014-02-13 20:55:47 +00:00
Dave Zarzycki
2d1de37c1d Diagnostics: 'let' is spelled 'val' now
Swift SVN r13870
2014-02-13 20:28:43 +00:00
Chris Lattner
0695fcea12 improve diagnostic about missing ) in parameter list to use the phrase
"parameter list" instead of "tuple argument".  Fix a potential crash I 
introduced by making an assumption about default initialized implied name
parameters being the only thing in parens.


Swift SVN r13813
2014-02-12 05:46:46 +00:00
Doug Gregor
560e7584d3 Allow a closure after each selector piece name.
a.foo(i) bar(d) closure { return "hello" } onError { println("error") }



Swift SVN r13808
2014-02-12 03:57:18 +00:00
Doug Gregor
32ca12e39c Revert r4994 "Remove the least liked of the message-send syntaxes".
In other words, provide basic parsing support for selector arguments
on a single line, i.e.,

  a.foo(1) bar(2.5) wibble("hello")



Swift SVN r13806
2014-02-12 03:35:03 +00:00
Joe Groff
1bcf0ce630 SIL: Fix up the parsing of generic apply insts.
Now that SILFunctionTypes are decontextualized, we have a prayer of parsing SIL that uses generic functions. Fix up the parsing code for ApplyInst and PartialApplyInst so that it consumes the closing '>' after a substitution list and properly computes the substituted function type before resolving the types of the instruction operands.

Swift SVN r13777
2014-02-11 04:52:25 +00:00
Jordan Rose
c24a6a7b46 [driver] Disallow "swift" as a module name unless -parse-stdlib is passed.
I didn't bother duplicating this check in -frontend mode. I think that's
acceptable.

<rdar://problem/15083796>

Swift SVN r13759
2014-02-10 22:40:44 +00:00
Chris Lattner
f9a83fdc33 Implement the first half of <rdar://problem/15922884> support non-member didset/willset properties
Observing properties now work fine as globals.  Local variables still need some work though.



Swift SVN r13736
2014-02-10 05:43:04 +00:00
Dave Zarzycki
5556d24f3a Parser: Remove "too many '.'s" error
This only made sense when '...' was reserved. In other words, if we
allow '..' and '...' as formal operators, then why not '....'?

Swift SVN r13673
2014-02-08 02:15:17 +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
49f7290288 Add specific diagnostics for sil-only attributes.
Treat inout as a SIL-only attribute, but produce a better diagnostic for it
if someone uses it accidentally (which I expect to be common over the next
few weeks).  inout is done.


Swift SVN r13567
2014-02-06 06:52:28 +00:00
Chris Lattner
ee0986fa9e introduce a new TypeRepr to represent "inout" in the argument list to a
function.  Parse inout as a contextual keyword there, shoving it into the
TypedPattern (instead of introducing a new kind of Pattern).  This enables
us to parse, sema, and irgen the new '@-less' syntax for inout.


Swift SVN r13559
2014-02-06 04:31:13 +00:00
Chris Lattner
fa58183545 Teach the parser to accept "mutating func f()" as an alias for
"@mutating func f()".   I'm keeping the @mutating version around
so we can determine what to do with @!mutating.

Also, improve the QoI of mutating related diagnostics.


Swift SVN r13480
2014-02-05 07:09:11 +00:00
Chris Lattner
f2ae570414 reject things like "var x : Int {}" in the parser, instead of parsing it as a stored decl.
Before my changes from a few days ago, we parsed it as having an empty getter (which
was rejected by sil diagnostics), but my restructuring broke that.  Make sure to reject it,
now with a more specific error.


Swift SVN r13403
2014-02-04 01:56:10 +00:00
Chris Lattner
63adafc7c6 Move my parser-time check for variable initializer requirements to Sema.
Swift SVN r13402
2014-02-04 01:43:12 +00:00
Manman Ren
a98ad8919e SILParser: parse 3 more witness entry types.
method type was handled earlier. This commit handles associated_type,
associated_type_protocol and base_protocol. We still need to parse
SpecializedProtocolConformance and InheritedProtocolConformance.

rdar://15722175


Swift SVN r13399
2014-02-04 01:09:11 +00:00
Chris Lattner
72073014da fix <rdar://problem/15626843> Stored global and static properties should require an initializer
Swift SVN r13360
2014-02-03 17:30:28 +00:00
Joe Groff
9fe1ab427a Implement 'if let' and 'while let' statements.
Allow IfStmts and WhileStmts to have as their condition either an expression, as usual, or a pattern binding introduced by 'var' or 'let', which will conditionally bind to the value inside an optional. Unlike normal pattern bindings, these bindings require an in-line initializer, which will be required to be Optional type. Parse variable bindings in this position, and type-check them by requiring an Optional on the right-hand side and unwrapping it to form the pattern type. Extend SILGen's lowering of if and while statements to handle conditionally binding variables.

Swift SVN r13146
2014-01-30 10:37:39 +00:00
Chris Lattner
9f437f79b3 we don't support non-member didset/willset properties yet. Produce an error instead
of crashing.


Swift SVN r13057
2014-01-28 06:47:34 +00:00
Chris Lattner
827e168b40 refactor all the get/set parsing logic to merge the cases together into
one function.  Add to it logic to parse didset/willset.

Sema doesn't exist yet, so these aren't too useful yet.


Swift SVN r13019
2014-01-28 00:09:12 +00:00
Chris Lattner
bea19a3605 Push the AST representation of properties in protocols forward,
mostly to get the brokenness inherent in their current representation out
of my way.

The biggest part of this is that properties in protocols are now always
represented as Computed VarDecls.  If you write "var x : Int" in a protocol,
you get an getter FuncDecl.  If you write "var x : Int { get}" you get the same
thing.  If you write "var x : Int { get set }" then you get a getter and setter
prototype associated with the vardecl.

This then readjusts the various hacks that sort of pass through such things
in SILGen and IRGen, so that we have the same level of hacky support for properties
in protocols.

From the functionality perspective, this enables the { get set } syntax described
in rdar://15827219, and means that "var x : Int" is uniformly treated as read-only
(it was treated as mutable in some cases before).  Properties in protocols are
still quite broken though.



Swift SVN r12981
2014-01-27 05:56:57 +00:00
John McCall
fcf1c14924 When deciding whether we can support a type property,
ignore whether it's in an extension vs. the primary declaration,
and permit non-stored properties in any context except a protocol.

Swift SVN r12943
2014-01-24 22:46:22 +00:00
Manman Ren
729d30fb54 SILParser: first step towards parsing sil_witness_table.
Only one entry kind out of four is supported right now.


Swift SVN r12936
2014-01-24 21:58:45 +00:00
Chris Lattner
a0f0c28868 Two related but (theoretically at least) seperable changes:
1. Implement parser and sema support for our subscript syntax proposal in
   protocols.  Now you have to use subscript(..) { get } or  {get set} to 
   indicate what you want.  I suspect that the syntax will evolve, but at
   least we can express what we need now.
2. Change the representation of SubscriptDecls in protocols to make 
   (empty) funcdecls for the getter and setter.  This guarantees that 
   every subscript has at least a getter.



Swift SVN r12555
2014-01-19 01:35:13 +00:00
Jordan Rose
5bbdb23910 Fix up "invalid UTF-8" error, and add a test case.
Swift SVN r12447
2014-01-17 01:08:32 +00:00
Jordan Rose
923a5392fe Fix r12422; change the text of the diagnostic about UTF-16, not bad UTF-8.
Swift SVN r12445
2014-01-17 00:50:11 +00:00
Jordan Rose
11008f0ed1 Split diagnostics out into separate files.
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.

No functionality change, but should speed up compile times!

Swift SVN r12438
2014-01-17 00:15:12 +00:00