Commit Graph

22435 Commits

Author SHA1 Message Date
Eli Friedman
2a78055566 Second attempt at <rdar://problem/11228914>.
Swift SVN r1820
2012-05-12 00:49:12 +00:00
Doug Gregor
a49d6c88c8 Introduce a conversion-to-supertype expression to capture conversions
from a protocol to a protocol it inherits. This is a far simpler
operation that the general type-erasure expression, so generate this
AST when we can.


Swift SVN r1813
2012-05-11 17:25:14 +00:00
Doug Gregor
b1627a40b0 Disable fixed-length arrays in the parser. They'll get implemented eventually.
Swift SVN r1811
2012-05-11 15:29:50 +00:00
Eli Friedman
01a18f6c7a Use VarDecls to represent struct members, and MemberRefExprs to represent member access in structs. Eliminate the horrible hack which was LookThroughOneOfExpr.
Swift SVN r1808
2012-05-11 03:08:15 +00:00
Doug Gregor
755f789aa0 Diagnose attempts to inherit from a non-protocol type.
Swift SVN r1806
2012-05-11 00:31:26 +00:00
Doug Gregor
09ef9525fa Only create erasure expressions in two places: one for lvalues and one
for rvalues.


Swift SVN r1805
2012-05-11 00:24:23 +00:00
Doug Gregor
70bfc235b8 Implement protocol inheritance, e.g.,
protocol Document { var title : String }
  protocol Versioning { func bumpVersion() }
  protocol VersionedDocument : Document, Versioning { }

This commit covers the basic functionality of protocol inheritance, including:
  - Parsing & AST representation
  - Conforming to a protocol also requires conforming to its inherited
  protocols
  - Member lookup into a protocol also looks into its inherited
  protocols (results are aggregated; there is no name hiding)
  - Teach ErasureExpr to maintain lvalueness, so we don't end up
  performing a silly load/erase/materialize dance when accessing
  members from an inherited protocol.




Swift SVN r1804
2012-05-11 00:00:50 +00:00
Eli Friedman
05fe3c907f Propagate a DeclContext through NameBinding for IdentifierTypes.
Swift SVN r1803
2012-05-10 23:34:01 +00:00
Doug Gregor
3d6a57f1c1 Note why we're using std::shared_ptr for something with unique ownership
Swift SVN r1798
2012-05-10 18:56:56 +00:00
Doug Gregor
3e7b52d025 Implement support for coercing a value of a given type T to a protocol
P, so long as T conforms to the protocol P.



Swift SVN r1797
2012-05-10 18:55:30 +00:00
Doug Gregor
88b214d020 Revert r1792; it's missing a file :(
Swift SVN r1795
2012-05-10 17:13:44 +00:00
Doug Gregor
f4f2f9f570 Implement support for coercing a value of a given type T to a protocol
P, so long as T conforms to the protocol P.


Swift SVN r1794
2012-05-10 16:15:34 +00:00
Eli Friedman
7cf73fb29b Comment tweaks.
Swift SVN r1787
2012-05-09 19:30:05 +00:00
Doug Gregor
169dd225bf Switch Parser::parseProtocolBody() over to use parseDecl(), with a
giant list of "you can't do that" restrictions. Update grammar
accordingly, killing off decl-var-simple.



Swift SVN r1781
2012-05-09 00:35:53 +00:00
Eli Friedman
77fa49ec2b Introduce StructDecl and StructType; use them for structs instead of OneOfDecl/OneOfType. To keep this patch small, I'm leaving in LookThroughOneOf etc. for the moment, but that's next on the agenda.
Swift SVN r1780
2012-05-09 00:27:44 +00:00
Doug Gregor
a581941440 Tighten up protocol parsing a bit.
Swift SVN r1779
2012-05-08 23:49:20 +00:00
Doug Gregor
5f2344afe0 Introduce ProtocolDecl, which describes (*gasp*) a protocol. Move the
guts of ProtocolType over to ProtocolDecl.


Swift SVN r1778
2012-05-08 23:28:55 +00:00
Eli Friedman
22ef9b45c7 Avoid using TypeBase* directly in a case where it isn't necessary.
Swift SVN r1775
2012-05-08 21:12:28 +00:00
Eli Friedman
4ca443d0f5 Add OneOfDecl; use it as a DeclContext for OneOfElementDecls instead of OneOfType, and get rid of the implicit TypeAliasDecl. Add TypeDecl as a base class for OneOfDecl and TypeAliasDecl (and StructDecl, once we have it). Adjust a whole bunch of stuff to this new scheme.
Swift SVN r1774
2012-05-08 21:09:42 +00:00
Chris Lattner
ca3732e2a2 rework the parsing logic for \() in string literals to just parse them as normal paren-exprs (tuples or parens).
Swift SVN r1769
2012-05-08 05:57:55 +00:00
Doug Gregor
302de6632d Switch the for-each loop informal protocol from getFirst()/dropFirst()
to the more input-iterator-centric getFirstAndAdvance(). Fixes
<rdar://problem/11401273>.


Swift SVN r1766
2012-05-08 00:37:01 +00:00
Chris Lattner
22300ed57f improve diagnostic for a " in the middle of an interpolated string, including a range:
t.swift:4:19: error: unexpected '"' character in string interpolation
"Hello \(x+1 world"
        ~~~~~~~~~~^



Swift SVN r1759
2012-05-05 23:12:07 +00:00
Chris Lattner
2d99b7cca0 switch LiteralExpr::classof to a range-based check, as suggested by Doug.
Swift SVN r1756
2012-05-05 22:43:21 +00:00
Eli Friedman
f75e305a20 Add ScalarToTupleExpr to represent an implicit conversion from a scalar to a tuple, with or without default arguments. Make Sema and IRGen work with them.
I'm not completely sure this is the representation we want, but it isn't much code to rip out if we decide to represent it some other way.

While I'm in the area, also fix a case where tuple->tuple conversion wasn't working.



Swift SVN r1748
2012-05-05 00:50:06 +00:00
Eli Friedman
a143422c98 Teach name binding to look into default values for tuple types.
Swift SVN r1747
2012-05-04 23:09:55 +00:00
Eli Friedman
fd62cbac65 Refactor extension parsing so it's centralized, and so we parse the body of the extension in the correct DeclContext.
Swift SVN r1745
2012-05-04 20:59:50 +00:00
Chris Lattner
2f44c0038c Initial stab at implementing string literal interpolation for simple expressions,
e.g. "foo is \(i+j)".  This implements rdar://11223686

Doug implemented all the hard parts of this.  I ripped out support for nested string
literals (i.e. string literals within an interpolated string), which simplified the
approach and defined away some problems with his patch in progress.  I plan a few refinements
on top of this basic patch.



Swift SVN r1738
2012-05-04 05:53:50 +00:00
Chris Lattner
774a557e5c Merge NamedDecl into ValueDecl, rdar://11379147.
Swift SVN r1737
2012-05-04 04:50:53 +00:00
Eli Friedman
255c5c0b14 Fix some obvious issues in DeclNodes.def found by inspection.
Swift SVN r1735
2012-05-04 00:51:03 +00:00
Eli Friedman
e6177f35a9 Get rid of the outdated notion of type lookup in Module. <rdar://problem/11026489>.
Swift SVN r1734
2012-05-04 00:41:54 +00:00
Eli Friedman
3dbb44e8e8 '\0' is not an operator character. Make sure Identifier::isOperatorChar knows that.
Swift SVN r1723
2012-05-03 20:33:17 +00:00
Chris Lattner
1ab9a54775 fix a comment typo
Swift SVN r1722
2012-05-03 05:37:42 +00:00
Eli Friedman
ff2bef9d62 Extend variable declaration grammar to allow "var a, b : Int, c, d : Double". <rdar://problem/11349535>.
I've tried to be pretty strict about exactly which cases we accept here, to avoid any confusing cases.



Swift SVN r1721
2012-05-03 00:49:16 +00:00
Chris Lattner
46c94377f1 Add support for var decls in the initializer of a c-style for loop,
implementing rdar://11360347 / 11349750.  C-style for loops could be
further enhanced by allowing a comma-separated list of statements in
the increment, but this isn't something I plan to do in the short term.


Swift SVN r1713
2012-05-02 05:44:58 +00:00
Chris Lattner
8c478d1cb7 remove the foreach keyword, switching foreach loops to use 'for' instead.
This uses one-token lookahead to distinguish between the two forms.


Swift SVN r1710
2012-05-02 01:06:06 +00:00
Chris Lattner
e205e1d2da change the subset of for statements we support: instead of *requiring* parens,
now we *do not allow* them.  This is progress towards unifying for and foreach.


Swift SVN r1709
2012-05-02 00:43:24 +00:00
Eli Friedman
a684be9af7 Per John's comments on r1696, use IGM.getPointerSize(), and add a bit to CapturingExpr for whether the function is captured.
Swift SVN r1700
2012-05-01 02:43:12 +00:00
Eli Friedman
48c1cbbe6b Make the type of VarDecls match the declared type of the variable/parameter/etc. <rdar://problem/11125010>.
Swift SVN r1680
2012-04-28 01:26:19 +00:00
Eli Friedman
1bfefd363a A couple trivial fixes: fix wording in a diagnostic, add a missing newline.
Swift SVN r1679
2012-04-27 23:43:59 +00:00
Eli Friedman
f41253e299 Add a couple of missing semantic checks for default values in tuples. Add a bit more clarifying wording to LangRef.
Swift SVN r1678
2012-04-27 23:40:43 +00:00
Chris Lattner
615ca4a360 implement the rest of character literal support, and enhance Char to be character literal
compatible.  This wraps up rdar://11305635, though some cleanup of the testsuite can now be done.


Swift SVN r1672
2012-04-27 06:18:30 +00:00
Chris Lattner
c7e68a4a8b langref and lexer support for character literals.
Swift SVN r1671
2012-04-27 05:51:30 +00:00
Doug Gregor
86cf79a746 Add a range subscript operation for SliceInt64 that produces a slice, e.g.,
a[5..9]

will return a 4-element slice of the array a. Addresses
<rdar://problem/11329415>.


Swift SVN r1665
2012-04-27 00:07:52 +00:00
Chris Lattner
20663a8aff introduce a new abstract LiteralExpr base class shared among the literals,
simplifying some code that previously enumerated all of them.


Swift SVN r1664
2012-04-26 23:04:24 +00:00
John McCall
5e31e0df7f When parsing a multi-dimensional array declarator in an expr-new,
update the element type with the computed type.

Swift SVN r1652
2012-04-26 08:07:31 +00:00
Eli Friedman
e33b1aac24 Don't try to synthesize an expression for a return statement which doesn't have one. <rdar://problem/11315114>.
Swift SVN r1639
2012-04-25 22:58:06 +00:00
Eli Friedman
81776635c5 Add an asmname attribute which overrides the default mangling for a swift function. This is a complete hack, and we intend to remove it (along with function declarations which don't include a definition) once we can properly import C modules. <rdar://problem/11306201>.
Swift SVN r1617
2012-04-25 01:53:38 +00:00
Eli Friedman
c055f6293f Initial implementation of global redeclaration checking. <rdar://problem/11294839>.
Swift SVN r1613
2012-04-24 23:10:03 +00:00
Doug Gregor
a04776044e Teach the import mechanism that it's rude to parse the same library
multiple times, as well as teaching the name lookup mechanism that
it's similarly rude to report ambiguous results because it searched
the same import twice. Fixes <rdar://problem/11287213>.

Yes, this is a bit of an ugly hack.


Swift SVN r1610
2012-04-24 22:36:17 +00:00
Doug Gregor
27483ce4e1 s/empty/isEmpty/g for the foreach loop informal protocol, because
function names should start with verbs.


Swift SVN r1607
2012-04-24 21:50:12 +00:00