Commit Graph

1316 Commits

Author SHA1 Message Date
Joe Pamer
1e5b9116d4 More array casting work:
- Continue adding support for checked downcasts of array types (rdar://problem/16535104)
- Fix non-bridged array conversions post-r17868
- Fix rdar://problem/16773693
- Add tests for NSArray coercions to and from Array<T>

Swift SVN r17957
2014-05-12 20:49:42 +00:00
Chris Lattner
24f06eb0e4 Rework my handling of @lazy in struct init() synthesization: the underlying
storage can be explicitly specified with a memberwise constructor (this already
worked) and the presence of the property shouldn't block synth of the default
ctor since it is default initialized to nil.

Unrelatedly, print the lazy attribute in the AST dumper.



Swift SVN r17925
2014-05-12 03:54:46 +00:00
Chris Lattner
24aa50069d Adjust diagnostics now that weak/unowned aren't attributes
Swift SVN r17800
2014-05-09 21:11:28 +00:00
Chris Lattner
a698fda0b3 teach the AST walker to walk into the capture list of closure exprs, teach the
type checker to type check them, tweak the ast dumper to dump out something nicer.



Swift SVN r17790
2014-05-09 18:36:35 +00:00
Chris Lattner
2426134853 improve hte AST representation of capture lists to build VarDecls and
PatternBindingDecls, and inject the vardecls into the name resolution
scope while parsing the body of the closure.  This allows references
from the body of the closure to be resolved to the capture list,
e.g. in cases like the testcase.


Swift SVN r17760
2014-05-09 05:39:28 +00:00
Joe Pamer
2eedc06d66 Begin adding plumbing for the type checker to accept "forward" bridged array conversions. (rdar://problem/16540403)
Swift SVN r17640
2014-05-07 19:45:37 +00:00
Joe Pamer
edb4946f66 Begin updating type checking of array upcasts to conform with the new spec.
Also, call through DaveA's new entry point for upcasts on Array<T>.

Swift SVN r17564
2014-05-06 21:32:22 +00:00
Chris Lattner
d230228cdd store the capture list of a ClosureExpr in the AST and print it out
in the AST dumper.


Swift SVN r17451
2014-05-05 16:25:33 +00:00
Chris Lattner
29aca1c851 Various minor TypeExpr improvements:
- Change astdumper to print the typerepr in the more canonical syntax.
 - Remove bogus logic from CSApply that was preventing us from rewriting
   TypeExprs properly
 - Teach CSGen to handle unbound generics correctly (thanks to Doug for the help on this)



Swift SVN r17007
2014-04-29 02:58:43 +00:00
Chris Lattner
eeaf7a657d have the ast dumper print TypeExprs a bit nicer.
Swift SVN r16953
2014-04-27 23:38:36 +00:00
Chris Lattner
0c390777ba Implement <rdar://problem/16204675> Need #elseif
This restructures IfConfigDecl/Stmt to be a list of clauses controlled
by a condition.  This makes it straight-forward to drop in #elseif support.

While I'm in here, this patch moves checking for extraneous stuff at the
end of the #if line from the lexer to the parser.  This means that you can
now put a comment on the same line as a #if/#else/#elseif/#endif.



Swift SVN r16912
2014-04-27 04:51:36 +00:00
Joe Pamer
86b79d6bd3 Some code cleanup for array upcast conversions. (Part 2 of the fix for rdar://problem/16540403)
Swift SVN r16837
2014-04-25 19:52:06 +00:00
Joe Pamer
066f5e6da5 Allow for simple upcast conversions between array types. (Part 1 of the fix for rdar://problem/16540403)
Swift SVN r16836
2014-04-25 19:52:05 +00:00
Joe Groff
8f51b0e738 Revert "wip"
This reverts commit r16662. Fat fingers.

Swift SVN r16663
2014-04-22 21:50:52 +00:00
Joe Groff
4a81e48ef8 wip
Swift SVN r16662
2014-04-22 21:46:36 +00:00
Chris Lattner
78e8d3f0a9 rename the MetatypeExpr AST node to DynamicTypeExpr now that it is only
used by the "foo.dynamicType" syntax.


Swift SVN r16658
2014-04-22 20:10:11 +00:00
Chris Lattner
7de9c0802a Peel off almost all of the uses of MetaTypeExpr, replacing
them with uses of TypeExpr instead.  The remaining uses of 
MetaTypeExpr (which will be renamed soon) are places where we
are applying the ".dynamicType" virtual property to an expression.

Unadorned uses of types in code, e.g. the Int in "Int.self" are
now represented with TypeExpr.

One unfortunate travesty that doing this work revealed is that we
are extremely sloppy and terrible about maintaining location information
in implicitly generated decls, and our invariants vary quite a bit.  This
is really horrible, but I'm not sure whether I'll go fix the hacks or not.

This patch perpetuates the existing crimes, but makes them more visible.

NFC!




Swift SVN r16646
2014-04-22 05:15:44 +00:00
Chris Lattner
7f3d88632d Introduce a new AST node, named TypeExpr, which will be formed by sema
when resolving identifiers into types.  This will eventually allow us to
solve annoying issues like rdar://15295763&15588967 by better modeling
what we already have.


Swift SVN r16620
2014-04-21 16:10:11 +00:00
Doug Gregor
09797f7f99 Introduce a new declaration node, ParamDecl, for function parameters.
Use this node to capture the argument name and its source location in
the AST. We're only building these in one place at the moment; the
rest will be updated soon.


Swift SVN r16581
2014-04-20 05:23:35 +00:00
Nadav Rotem
001533d1eb Fix the build by adding the '==' operator to Substitution.
Swift SVN r16565
2014-04-19 05:47:00 +00:00
Doug Gregor
812dc091eb Introduce the notion of factory initializers.
Factory initializers express an initializer that produces an object of
the given type, but is not inherited and not designated. Although they
have a syntactic form for presentation purposes (-> ClassName), there
is no way to specify or implement them within Swift. Rather, factory
initializers are created when importing an Objective-C factory method
that returns the class type rather than instancetype.

Swift SVN r16528
2014-04-18 16:04:48 +00:00
Doug Gregor
d80b689c51 Introduce "convenience factory" initializers.
Convenience factory initializers are convenience initializers produced
by importing an Objective-C factory method as a convenience
initializer. The distinction is currently only used to eliminate the
awful layering violation I recently introduced in name lookup, which
was consulting Clang AST nodes directly. It will also be useful in
SILGen.

Swift SVN r16527
2014-04-18 15:34:26 +00:00
Doug Gregor
8bc2ea4ea1 Use designated/convenience initializer terminology throughout. NFC
Introduce CtorInitializerKind to describe the kind of an enum, rather
than a bool, to make way for more initializer kinds in the future.

Swift SVN r16525
2014-04-18 15:10:13 +00:00
John McCall
9000278dcd Introduce MetatypeErasureExpr for erasing metatype
values into existential metatypes.  Erase thin metatypes
correctly in SILGen.

rdar://16610078

Swift SVN r16477
2014-04-17 22:31:47 +00:00
Doug Gregor
129aa191a6 Remove the use of ArgParamPatterns in the AST printer and dumper.
Swift SVN r16436
2014-04-17 03:33:46 +00:00
Doug Gregor
86ecc725c9 Start building compound names for functions parsed with the new signature style.
Swift SVN r16394
2014-04-16 03:55:05 +00:00
Joe Groff
3bad92b342 AST: Remove the stopgap BridgeToBlockExpr and handle block <-> non-block conversions freely as function conversions.
Teach SILGen to handle function representation changes as part of function conversion instead of needing to be spoonfed a special expr for the purpose. Handle representation changes in both directions to and from blocks using the same logic as the bridging conversions.

Swift SVN r16318
2014-04-14 15:00:34 +00:00
Doug Gregor
d023035103 Allow associated types to have superclasses.
Fixes <rdar://problem/16413389>.


Swift SVN r16219
2014-04-11 17:07:56 +00:00
Doug Gregor
5b8dab7c19 AST dumper: dump the full name of a function.
Swift SVN r15980
2014-04-05 05:45:51 +00:00
Chris Lattner
3528e70aa9 change -ast-dump to print the final attribute, change the serialization
support to serialize and deserialize it (also bump the version #),
@final is still a WIP.



Swift SVN r15898
2014-04-03 22:45:36 +00:00
Jordan Rose
0324b9e027 Don't walk into an as-of-yet-unsynthesized function body.
...and don't dump it, and don't force it just to see if an accessor is present.

Swift SVN r15830
2014-04-02 21:00:48 +00:00
Joe Groff
8f1c2d1e79 Sema: Implement type-checking for inout writeback conversion.
Add a third branch to the constraint system for '&x' expressions that allows conversion from an lvalue to a type via an additional writeback step:

- Add an LValueConversionExpr node that converts from @lvalue T to @lvalue U, given a pair of functions that convert T -> U and U -> T, to represent the writeback temporary.
- Allow conversion in an inout expression from @lvalue T to a type U that has the following members:

  static func __writeback_conversion(Builtin.RawPointer, T.Type) -> U
  static func __writeback_conversion_get(T) -> V
  static func __writeback_conversion_set(V) -> T

which builds a solution that produces an LValueConversion from the get/set pair before passing the pointer to the writeback temporary off to the conversion function.

Swift SVN r15764
2014-04-02 00:17:51 +00:00
Joe Groff
46f77c6181 Sema: Build the AST for inout address conversions.
Add two new AST node types:

- InOutConversionExpr, which represents an '&x' expression that involves inout conversion. This will be a signal to SILGen not to introduce a writeback scope for the nested conversion call.

- LValueToPointerExpr, which represents the primitive '@lvalue T' to 'RawPointer' conversion that produces the argument to the inout conversion.

Build an InOutConversionExpr AST when an inout expression is resolved by a conversion to an BuiltinInOutAddressConvertible type.

Swift SVN r15594
2014-03-29 02:50:25 +00:00
Joe Groff
45eadd1d9b Rename AddressOfExpr to InOutExpr.
The "address" is an implementation detail; formally, it turns an lvalue into an inout parameter.

Swift SVN r15458
2014-03-25 16:28:28 +00:00
Argyrios Kyrtzidis
4f1bdd42a6 [ASTDumper] Dump an IfConfigDecl.
Swift SVN r15442
2014-03-25 03:55:27 +00:00
Joe Groff
4fdc20f739 Allow '<pattern> as T' checked patterns with subpattern bindings.
Allow a form of 'case is T' that matches the cast result to a subpattern, 'case <pattern> as T'. This exposes an issue in switch destructuring with casting into complex class hierarchies <rdar://problem/16401831> but works for common cases.

Swift SVN r15396
2014-03-24 00:02:44 +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
John McCall
486463a398 Track the depth of a BindOptionalExpr.
Swift SVN r15210
2014-03-18 22:57:34 +00:00
Chris Lattner
f504357eb3 fix a *critical* bug where -ast-dump of destructor_decls printed an extra blank line.
Swift SVN r15143
2014-03-17 16:55:19 +00:00
Chris Lattner
a3c337b872 print the canonical version of an interface type, otherwise it isn't
greek!


Swift SVN r14952
2014-03-12 05:50:04 +00:00
Chris Lattner
58652881ea Two changes to the ASTDumper:
1. Do not call getInterfaceType() on a decl if it isn't already set, since
   this will cause it to be lazily computed, and it would be nice for the
   ASTDumper to not side-effect our AST.

2. Print the interface type of a decl if present, even if the type is not.
   Surprisingly to me, we compute the interface type a lot sooner than the type
   for a decl in some cases.



Swift SVN r14951
2014-03-12 05:48:41 +00:00
Joe Groff
1585b625f9 Sema: Wire up compound name lookup to UnresolvedSelectorExpr.
Resolve selector references using compound name lookup, pushing DeclNames a bit deeper through the type-checker and diagnostics as necessary.

Swift SVN r14791
2014-03-07 20:52:30 +00:00
Joe Groff
9e5bc637ae Add __FUNCTION__ as a magic literal identifier.
Add __FUNCTION__ to the repertoire of magic source-location-identifying tokens. Inside a function, it gives the function name; inside a property accessor, it gives the property name; inside special members like 'init', 'subscript', and 'deinit', it gives the keyword name, and at top level, it gives the module name. As a bit of future-proofing, stringify the full DeclName, even though we only ever give declarations simple names currently.

Swift SVN r14710
2014-03-06 01:06:06 +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
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
363a324984 Parse: Start parsing selector member references.
Parse 'x.y:z:' for at least two selector pieces as an UnresolvedSelectorExpr, and declare it unimplemented in Sema.

Swift SVN r14492
2014-02-28 01:47:32 +00:00
Chris Lattner
1344319677 Rename the internal compiler lexicon from val -> let.
Swift SVN r14408
2014-02-26 21:21:18 +00:00
Joe Groff
c0d8ae7c13 Parse 'x.self' as an identity expression.
Factor an IdentityExpr base class out of ParenExpr, and migrate most of the logic to see through ParenExprs to see through IdentityExprs instead. Add DotSelfExpr as a new subclass of IdentityExpr, produced by parsing 'x.self'.

Swift SVN r14381
2014-02-26 06:23:55 +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