Commit Graph

28382 Commits

Author SHA1 Message Date
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
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
0a23de0d75 fix rdar://11385385 - When forming the implicit string constructor, use the start of the embedded
range, not the "loc" which is somewhat random.


Swift SVN r1755
2012-05-05 22:41:12 +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
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
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
John McCall
3f3cfe051a Don't die if the outermost bound of a new[] expression is
dependently-typed.

Swift SVN r1716
2012-05-02 06:05:11 +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
Eli Friedman
6d10ff6250 Add handling for foreach loops to capture analysis.
Swift SVN r1694
2012-04-30 19:42:24 +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
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
Doug Gregor
e81331a81a If an error occurs while type-checking a declaration in the REPL,
don't look at the declaration again. Fixes <rdar://problem/11331724> /
<rdar://problem/11332314>. 


Swift SVN r1670
2012-04-27 05:11:58 +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
John McCall
61b6661392 Support for subscript l-values.
Swift SVN r1630
2012-04-25 08:36:35 +00:00
Eli Friedman
2f3ff69d41 Some tweaks to module import to get the demo flow working.
Swift SVN r1625
2012-04-25 07:29:31 +00:00
Eli Friedman
babedb9c94 Fix a crash related to nested types in name lookup. (This is enough to get value lookup working for typealiases in extensions, but not type lookup.)
Swift SVN r1616
2012-04-25 00:48:37 +00:00
Doug Gregor
953ca36f94 When type-checking a statement, keep track of whether it is top-level
code. If so, use that DeclContext for foreach's synthesized
variable. Because it's kinda nice to be able to use 'foreach' twice in
a REPL session.


Swift SVN r1614
2012-04-25 00:26:09 +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
Doug Gregor
6d5f67c790 Implement IR generation for the 'foreach' loop and convert our fractal
examples over to using the 'foreach' loop. Addresses
<rdar://problem/11259997>.


Swift SVN r1606
2012-04-24 21:37:55 +00:00
Doug Gregor
e1b8daa717 Rework 'foreach' AST to reflect how IRgen actually wants it to look,
rather than how I felt like generating it.


Swift SVN r1599
2012-04-24 20:42:17 +00:00
Doug Gregor
ac188c7d59 Implement type checking for the foreach loop and extend the AST to
hold all of the various expressions and declarations we'll need to
understand its semantics.


Swift SVN r1596
2012-04-24 20:22:36 +00:00
Doug Gregor
f997a781bf Parsing and basic AST representation for 'foreach' statement.
Swift SVN r1594
2012-04-24 18:12:44 +00:00
John McCall
96d7931f8d Teach capture analysis to look through MemberRefExprs.
Swift SVN r1591
2012-04-24 09:36:54 +00:00
John McCall
becacee265 MemberRefExpr can only refer to a VarDecl for now.
Swift SVN r1588
2012-04-24 08:16:46 +00:00
Eli Friedman
1780f0f1e8 Minor bulletproofing for Sema code for REPL.
Swift SVN r1581
2012-04-24 02:34:35 +00:00
Eli Friedman
36472404b2 Parse swift.swift upfront in the REPL. This has two benefits: one, we error immediately if swift.swift can't be found, or something is wrong with it. Two, it lets us JIT swift.swift upfront, which makes the REPL prompt feel more responsive. <rdar://problem/11305258>.
Swift SVN r1575
2012-04-24 00:55:19 +00:00
Doug Gregor
9fe42c0055 Merge infix precedence/associativity for binary operators, rather than
forcing one to declare, e.g., [infix_left=NNN] on every
declaration. The precedence/associativity will be merged from any
similarly-named operator in translation unit scope or in an imported
module. Fixes <rdar://problem/11261874> very, very narrowly for the
demo.

This implementation is hacky and slow; we'll replace it later with
<rdar://problem/11304699>.



Swift SVN r1570
2012-04-23 23:40:56 +00:00
Eli Friedman
a4de7ddba2 Try a different variant of expression printing. <rdar://problem/11296811>.
Swift SVN r1569
2012-04-23 23:19:25 +00:00
Eli Friedman
86d6ad7b6f Implement Chris's tweaks for expression printing in the REPL. <rdar://problem/11296811>.
Swift SVN r1567
2012-04-23 22:33:42 +00:00
Eli Friedman
4d42b6652a REPL printing for VarDecls. <rdar://problem/11287158>.
Swift SVN r1539
2012-04-21 01:30:12 +00:00
Eli Friedman
1d58c4739a Fix type-checking to handle some cases with tuples which contain lvalues. <rdar://problem/11287167>.
Swift SVN r1538
2012-04-20 21:38:16 +00:00
Doug Gregor
95cdc20902 Member expressions (which refer to properties) require their bases to
be lvalues (materializing them if necessary), as we do with subscript
expressions. Introduce a verifier for member expressions to make sure
this property holds.

Note that there is a slight regression in semantic analysis for
assignments to properties, because we no longer detect some cases of
writing into a property that should not be set. The general solution
to the problem is covered by <rdar://problem/11259972>.



Swift SVN r1530
2012-04-20 15:48:39 +00:00
Doug Gregor
b0616a72bb Clean up the AST for subscript expressions in a few ways:
- Ensure that the base is always an lvalue, materializing it if necessary
  - Give appropriate lvalue qualifiers to the subscript expression
  - Make sure to write the converted indices back into the AST

Finally, introduce a verifier for subscript expressions.


Swift SVN r1528
2012-04-20 15:33:46 +00:00
Doug Gregor
3d2e00d4e7 Remove stale FIXME
Swift SVN r1527
2012-04-20 14:42:03 +00:00
Doug Gregor
458549e043 If the right-hand side of an assignment is not dependent, but the
left-hand side is dependent, coerce the left-hand side to an lvalue of
the right-hand side's object type. This allows us to assign into
lvalues that may be overloaded on the underlying value type, e.g.,
subscripting values and overloaded variables. Fixes <rdar://problem/11285171>.


Swift SVN r1526
2012-04-20 14:39:37 +00:00
Eli Friedman
a2c6150c13 Error recovery for the REPL. Seems to be working reasonably well. <rdar://problem/11269380>.
Swift SVN r1523
2012-04-20 01:14:39 +00:00
Eli Friedman
be602fcd05 Get rid of the implicit BraceStmt for the TranslationUnit; instead, have the TranslationUnit directly store a list of decls.
Swift SVN r1521
2012-04-20 00:17:13 +00:00
Doug Gregor
6122a9f5e3 Introduce an overloaded subscript expression type, to cope with cases
where overloading based on the indices is insufficient to select an
overload candidate. Implement type coercion for overloaded subscript
expressions, so that the context can help push overload resolution
along.


Swift SVN r1516
2012-04-19 23:43:44 +00:00