Eli Friedman
ae86d64644
Rename Decl::getLocStart() to Decl::getStartLoc(). Add Decl::getLoc(), which is essentially the location which should be used for diagnostics.
...
Swift SVN r2105
2012-05-31 23:56:30 +00:00
Eli Friedman
29a13e9ae0
Move the NameLookup class into the AST library.
...
Swift SVN r2101
2012-05-31 22:35:50 +00:00
Eli Friedman
377972b1ba
Start shuffling around code for name binding on values; with the proposed shadowing rules, we need to delay name binding on values until after some parts of type-checking.
...
Swift SVN r1946
2012-05-23 00:42:53 +00:00
Doug Gregor
9552aa5e10
Implement basic support for refering to a nested type within
...
unqualified lookup, based on context. For example:
struct String {
struct CharRange { /* ... */ }
func getElements() -> CharRange {
return CharRange(value)
}
}
Swift SVN r1939
2012-05-22 21:08:22 +00:00
Doug Gregor
b1f1e1430d
Introduce NominalType as a base class of
...
OneOfType/StructType/ClassType/ProtocolType, an eliminate the
ridiculous chained ifs that used to check for most (or all) of these.
Swift SVN r1923
2012-05-22 00:13:59 +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
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
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
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
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
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
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
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
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
Eli Friedman
acc17d69aa
Initial implementation of the "print" part of the REPL.
...
Swift SVN r1484
2012-04-19 01:13:37 +00:00
Eli Friedman
37de44a35d
Implement changes to parsing/sema/etc so that we can implement a REPL and the main module parses the same way as a REPL.
...
Next step: implement an actual REPL.
Swift SVN r1441
2012-04-16 23:52:01 +00:00
Eli Friedman
9bf8dcf0f1
Delete some dead code.
...
Swift SVN r1412
2012-04-13 01:05:12 +00:00
Eli Friedman
1569d73cb2
Fix a crash involving extensions.
...
Swift SVN r1411
2012-04-13 00:48:53 +00:00
Doug Gregor
ba56d2c0b1
Implement support for lookup of members of the current
...
oneof/struct/protocol within a static method. The lookup is performed
on the metatype (as one would get when using qualified syntax
Type.member). Add tests to verify that this provides proper
overloading behavior.
As a drive-by, actually set the type of the implicit 'this' variable
during name binding for a non-static method.
Swift SVN r1394
2012-04-11 18:22:53 +00:00
Ted Kremenek
352453a53b
Revert "Fix a bunch of "has virtual functions but non-virtual destructor" warnings"
...
Swift SVN r1376
2012-04-11 00:02:16 +00:00
Ted Kremenek
8a61ea1fd0
Fix a bunch of "has virtual functions but non-virtual destructor" warnings
...
Swift SVN r1373
2012-04-10 23:53:46 +00:00
Eli Friedman
bb597c7a37
Minor cleanup.
...
Swift SVN r1354
2012-04-10 01:47:45 +00:00
Doug Gregor
c24d6ec8c4
Factor OverloadSetRefExpr into an abstract base class covering the
...
notion of a reference to a set of declarations. Introduce one derived
class, OverloadedDeclRefExpr, which covers the only case we currently
handle for overload resolution [*]: a direct (unqualified) reference
to an overloaded set of entities. Future subclasses should handle,
e.g., overloaded member references such as a.b or a.b.c.
[*] Ugly hacks for static methods notwithstanding
Swift SVN r1345
2012-04-09 17:16:11 +00:00
Eli Friedman
f477cf588e
Introduce the notion of the "main" module, i.e. the module which defines main(). Disallow top-level statements in modules other than the main module. Fix IRGen to generate a main() function in the main module, and implement top-level statements. Get rid of the main() mangling hack. Part of <rdar://problem/11185451>.
...
I haven't really carefully considered whether existing type-checking etc. is correct for the main module (I think the name-binding rules need to be a bit different?), but it seems to work well enough for the obvious cases.
This is enough to get the one-liner "println(10)" to print "10" in "swift -i" mode, although the path to swift.swift still needs to be explicitly provided with -I.
Swift SVN r1325
2012-04-05 00:35:28 +00:00
Eli Friedman
22b7cd05f5
Some minor incremental improvements for module import. Allow explicitly importing Builtin, and implicitly import swift for any module which doesn't explicitly import Builtin or swift. Fixes <rdar://problem/11185519>.
...
Swift SVN r1323
2012-04-04 21:56:40 +00:00
Chris Lattner
8aafdda9f6
after an epic refactoring fest, finally implement ivar/method lookup in methods, resolving rdar://10682135.
...
There are still problems in the field of name lookup, but this is progress at least.
Swift SVN r1235
2012-03-19 06:08:57 +00:00
Chris Lattner
92f3d6a431
checkpoint, nothing useful here.
...
Swift SVN r1228
2012-03-19 05:15:59 +00:00
Chris Lattner
60d9b2a570
intermediate progress on rdar://10682135, nothing particularly useful so far.
...
Swift SVN r1207
2012-03-11 23:57:09 +00:00
Chris Lattner
0cccfe9299
rename the Walker class to ASTWalker to match ASTVisitor.
...
Swift SVN r1201
2012-03-11 16:28:50 +00:00
Eli Friedman
862646c1dd
Perform conversion to bool in conditionals by repeatedly calling ".getLogicValue()" on the value until we reach Builtin.Int1, instead of using convertToLogicValue(). <rdar://problem/10100856>.
...
Swift SVN r1173
2012-03-10 00:02:36 +00:00
Eli Friedman
ddffb633eb
Fix build errors with clang-421.
...
Swift SVN r1167
2012-03-05 19:31:12 +00:00
John McCall
d0f4d86f3e
Use LValueType everywhere instead of the l-value value kind.
...
Kill off TypeJudgement. Various fixes and improvements.
Swift SVN r1107
2012-02-06 22:47:08 +00:00
John McCall
e66c13cfe7
Change the 'walk' APIs to use virtual function dispatch
...
instead .
1,2d
1i
Change the 'walk' APIs to use virtual dispatch instead of
blocks. This makes it much easier to thread information
through the API, as well to extend the API to handle
recursive visiting of other structures (e.g., Decls
and Patterns).
Swift SVN r1101
2012-01-26 04:31:38 +00:00
Chris Lattner
4ef27b82e4
simplify some code to use a foreach loop.
...
Swift SVN r1089
2012-01-19 06:41:49 +00:00
Chris Lattner
599e4b2528
switch to using the new llvm::MutableArrayRef class, this requires llvm r148463
...
Swift SVN r1088
2012-01-19 06:39:07 +00:00
Chris Lattner
e3298d8b98
rearrange some code to simplify it.
...
Swift SVN r1077
2012-01-18 07:26:47 +00:00
Chris Lattner
23a7fb46c1
now that name binding doesn't have weird "only kill some subtrees" behavior, switch it over to a standard walk.
...
Swift SVN r1076
2012-01-18 07:25:28 +00:00
Chris Lattner
0587519685
remove some bogus code now that name binding doesn't kill subtrees. Spare the forest!
...
Swift SVN r1075
2012-01-18 07:22:22 +00:00
Chris Lattner
ed7062c452
instead of having name binding kill off entire subtrees that contain invalid variable uses, have it turn the ivalid use into an ErrorExpr.
...
Swift SVN r1074
2012-01-18 07:21:25 +00:00
Chris Lattner
584ed537fc
introduce a new ErrorExpr to represent a subexpression that is semantically
...
inconsistent (so it needs to be killed) but that we want to retain source
range information and not kill the entire subtree that contains it.
Swift SVN r1073
2012-01-18 07:18:57 +00:00
Chris Lattner
fa2ea94348
always turn a named reference to a type into an IdentifierType.
...
This preserving source location info and reduces redundancy in the parser.
Swift SVN r1065
2012-01-18 01:57:44 +00:00
Chris Lattner
1c42e8f6a6
rename DottedNameType to IdentifierType. It captures loc information for random uses of type names, among other things.
...
Swift SVN r1064
2012-01-18 01:52:28 +00:00
Chris Lattner
2f7cd03c6b
switch type lookup to use value lookup for everything. Dead code ahoy.
...
Swift SVN r1057
2012-01-17 07:36:16 +00:00
Chris Lattner
51e44891af
rip out now-dead code from NameBinding. It still generally needs to be beaten
...
into sense later, but this gets it closer to reasonable.
Swift SVN r1051
2012-01-17 06:35:34 +00:00
Chris Lattner
c8ca11a199
Drop in the new DottedNameType and wire it up in name binding.
...
This is horribly hack and slash (but enough to pass all tests) for a few reasons:
- I've #if 0'd out the tendrils of the old code
- This handles *just* what was handled before instead of being more general
- We don't have an llvm::MutableArrayRef type, so there is some really gross
const_cast'ing and other struggles to deal with its absence.
Swift SVN r1050
2012-01-17 06:32:00 +00:00