Commit Graph

541 Commits

Author SHA1 Message Date
Doug Gregor
b06e65c3b3 Add the DynamicLookup protocol for lookup across all classes and protocols.
When performing member lookup into an existential that involves the
DynamicLookup protocol, look into all classes and protocols for that
member. References to anything found via this lookup mechanism are
returned as instances of Optional.

This introduces the basic lookup mechanics into the type
checker. There are still numerous issues to work through:
  - Subscripting isn't supported yet
  - There's no SILGen or IRGen support
  - The ASTs probably aren't good enough for the above anyway
  - References to generics will be broken
  - Ambiguity resolution or non-resolution

Thanks to Jordan for the patch wiring up DynamicLookup.


Swift SVN r7689
2013-08-28 21:38:50 +00:00
Dmitri Hrybenko
53e0921e75 Make 'self' and 'Self' keywords
Add a test for recovery after misplaced 'self' and 'Self'.  We don't diagnose
many cases of invalid usage, and in some cases diagnostics are bad.  This will
be fixed separately.


Swift SVN r7661
2013-08-28 03:42:04 +00:00
Dmitri Hrybenko
d9035426ed Rename RebindThisInConstructorExpr -> RebindSelfInConstructorExpr
Swift SVN r7658
2013-08-28 03:02:30 +00:00
Dmitri Hrybenko
69cfa73640 More 'this' -> 'self' replacements
Swift SVN r7657
2013-08-28 02:57:21 +00:00
Dmitri Hrybenko
dd1c2f7477 Parser: consume tok::code_complete where it is handled
We did not consume it before because parseBraceItems() relied on seeing it to
do delayed parsing.


Swift SVN r7648
2013-08-27 23:48:54 +00:00
Ted Kremenek
8f5b8ccb02 Rename "This" to "Self" and "this" to "self".
This was not likely an error-free change.  Where you see problems
please correct them.  This went through a fairly tedious audit
before committing, but comments might have been changed incorrectly,
not changed at all, etc.

Swift SVN r7631
2013-08-27 21:58:27 +00:00
Dmitri Hrybenko
14f6b67797 Correctly propagate code completion bits from parseExprPostfix() during the
first parsing pass.  This allows us to remove a workaround in parseBraceItems()
that directly looks at the current token.


Swift SVN r7616
2013-08-27 01:06:48 +00:00
Dmitri Hrybenko
c6f0dd106d parseStmtReturn(): use ParserResult
This caught a bug in parseExprPostfix(): it did not return a code completion
status.


Swift SVN r7603
2013-08-26 23:18:51 +00:00
Dmitri Hrybenko
adaea00254 Actually propagate the code completion bit
No tests because code completion bits from parseExpr*() don't do anything
yet -- parseDecl() just ignores them.


Swift SVN r7441
2013-08-22 00:33:41 +00:00
Dmitri Hrybenko
caeddfdaf0 parseExprList(): use ParserResult
Swift SVN r7440
2013-08-22 00:27:43 +00:00
Dmitri Hrybenko
421b107091 parseExprCollection, parseExprArray, parseExprDictionary: use ParserResult
Swift SVN r7439
2013-08-21 23:47:07 +00:00
Dmitri Hrybenko
2bf010151b parseExprSequence(): use ParserResult
Swift SVN r7438
2013-08-21 23:30:47 +00:00
Dmitri Hrybenko
4957bca697 parseExprUnary(): use ParserResult
Swift SVN r7437
2013-08-21 23:20:23 +00:00
Dmitri Hrybenko
f9a24073a5 parseExprPostfix(): use ParserResult
Swift SVN r7430
2013-08-21 21:53:52 +00:00
Dmitri Hrybenko
04bcc5553e parseExprNew(): use ParserResult
Swift SVN r7429
2013-08-21 21:32:21 +00:00
Dmitri Hrybenko
2e3d313d6b parseExprSuper(): use ParserResult
Swift SVN r7427
2013-08-21 21:26:09 +00:00
Dmitri Hrybenko
faff10f310 Parser: use ParserResult in 'is' and 'as' expression parsing
Swift SVN r7426
2013-08-21 21:15:43 +00:00
Dmitri Hrybenko
ec7b2eb3db Parser: use ParserResult in the interface of parseExpr()
But the implementation of expression parsing still does not propagate the code
completion bits because it uses NullablePtr for results.


Swift SVN r7425
2013-08-21 21:10:09 +00:00
Dmitri Hrybenko
354c5f4a18 Parser: replace diagnose(Tok.getLoc(), ...) -> diagnose(Tok, ...)
We already had the Parser::diagnose(Token, ...) overload, but it was not used
in all these cases.


Swift SVN r7395
2013-08-21 00:26:30 +00:00
Dmitri Hrybenko
c3954987d6 Parser: use ParserResult in parseTypeSimple() and everything that uses it/
is used in it


Swift SVN r7355
2013-08-20 02:12:31 +00:00
Dmitri Hrybenko
b0dd877454 Use ParserResult in type parsing
Swift SVN r7353
2013-08-20 01:19:31 +00:00
Dmitri Hrybenko
c098cd1476 Parser: convert some pattern parsing functions to ParserResult
Swift SVN r7336
2013-08-19 22:38:34 +00:00
Dmitri Hrybenko
66a447adb8 Code completion: code completion on a different line that the expr-postfix:
use the Tok.isAtStartOfLine() check instead of comparing line numbers


Swift SVN r7192
2013-08-13 03:17:54 +00:00
Dmitri Hrybenko
8a7628d795 Code completion: fix a bug where code completing in a function body on the next
line after a var decl with initializer would complete based on the initializer
expression.

These are technically valid completions, but confusing.  Now this suggests
unqualified completions.


Swift SVN r7188
2013-08-13 02:25:00 +00:00
Dmitri Hrybenko
70f2b64ad9 Add CharSourceRange -- a half-open character range, which will be used in IDE
integration

Motivation: libIDE clients should be simple, and they should not have to
translate token-based SourceRanges to character locations.

This also allows us to remove the dependency of DiagnosticConsumer on the
Lexer.  Now the DiagnosticEngine translates the diagnostics to CharSourceRanges
and passes character-based ranges to the DiagnosticConsumer.


Swift SVN r7173
2013-08-12 20:15:51 +00:00
Chris Lattner
1896177dfd Fix rdar://14705150, a crash on invalid I ran into.
Swift SVN r7129
2013-08-10 18:08:41 +00:00
Dmitri Hrybenko
dc655eb1cb Remove more abuse of SourceLoc::Value::getPointer()
Swift SVN r7109
2013-08-09 22:35:33 +00:00
Jordan Rose
0a84ed0c03 Parse: Allow type-simple in expr-new, and make "T?" part of type-simple.
These constructs are now legal:
  Int?.metatype
  new Int?[4]
  new NSWindow.metatype[4]
  new (Int -> Int)[4]

Swift SVN r7103
2013-08-09 21:33:59 +00:00
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +00:00
Dmitri Hrybenko
02cf73dc30 Lexer: remove redundant parameters from the sublexer constructor
Swift SVN r7073
2013-08-09 00:15:01 +00:00
Argyrios Kyrtzidis
d6b048dfe0 [Lexer] Refactor lexing of interpolated strings.
Decouple splitting an interpolated string to segments, from encoding the string segments.
This allows us to tokenize or re-lex a string literal without having to allocate memory for
encoding the string segments when we don't need them encoded.

Swift SVN r6940
2013-08-06 14:59:01 +00:00
Argyrios Kyrtzidis
cda7a109bd [Lexer] Remove the special hack in the Lexer that handles lexing an expression in an interpolated string.
-Parse the expression using a begin/end state sub-Lexer instead of a general StringRef Lexer
-Introduce a Lexer constructor accepting a BufferID and a range inside the buffer, and use it for swift::tokenize.

Swift SVN r6938
2013-08-06 14:58:59 +00:00
Dmitri Hrybenko
38652f514c Simplify code with the new Token::isKeyword() function
Swift SVN r6757
2013-07-30 22:41:51 +00:00
Jordan Rose
736c6d2db6 Don't crash on "var x = { x() }".
We should probably accept this, or at least some variation of it, but
erroring out is still a strict improvement over crashing. However, this
does cause a regression for some properly typed recursive closures, like
'fib' in expressions.swift.

<rdar://problem/14583952> tracks the correct solution.

Swift SVN r6730
2013-07-30 00:17:35 +00:00
Jordan Rose
3ca6768be3 Using a variable within its own initializer is an error.
Currently, this includes cases where a variable of the same name is
available in an outer scope. We can change this later if desired.

<rdar://problem/14566648>

Swift SVN r6729
2013-07-30 00:17:28 +00:00
Dmitri Hrybenko
5186d82cdc Move the comment to the beginning of the logic that does what is explained
in the comment.


Swift SVN r6728
2013-07-30 00:07:01 +00:00
Dmitri Hrybenko
8f83ca67e3 Parsing postfix exprs: if we have '.<keyword><code_complete>', try to recover
by creating an identifier with the same spelling as the keyword.

Fixes code completion for cases like 'foo.is#^A^#'.


Swift SVN r6727
2013-07-29 23:56:21 +00:00
Joe Groff
69d3392191 Accept underscore separators in numeric literals.
This makes long literals like 1_000_000_000 or 0x7FFF_FFFF_FFFF_FFFF much easier to read, and has precedent in Perl, OCaml, Python, Ruby, Rust, ... Fixes <rdar://problem/14247571>.

Swift SVN r6681
2013-07-28 18:56:30 +00:00
Dmitri Hrybenko
497ec93ec9 Code completion: generate a tok::code_complete token during the first pass of
parsing

No functionality change, this will be used by next commits.


Swift SVN r6637
2013-07-26 01:40:47 +00:00
Argyrios Kyrtzidis
de4a2dbd8b [Parser] Abstract a bit access to Parser's ScopeInfo.
This will be more useful later on.

Swift SVN r6578
2013-07-25 01:40:13 +00:00
Doug Gregor
9339eb4780 Ban "2.0.0", which is pretty silly.
Swift SVN r6458
2013-07-22 18:00:31 +00:00
Argyrios Kyrtzidis
015c1a892b Refactor Parser methods to return TypeReprs directly, instead of modifying TypeLocs.
Swift SVN r6328
2013-07-17 14:57:40 +00:00
Dmitri Hrybenko
e650f2f8fc Implement basic code completion at the beginning of the expr-postfix
We produce only names that are found by name lookup, no keywords or types yet.


Swift SVN r6276
2013-07-16 00:49:08 +00:00
Dmitri Hrybenko
98aaf3bb45 Add code completion for expr-super: 'super#^A^#' and 'super.#^A^#'
Swift SVN r6264
2013-07-15 18:11:48 +00:00
Dmitri Hrybenko
d2be2b463c Use nullptr instead of '0'.
Swift SVN r6237
2013-07-13 00:45:41 +00:00
Dmitri Hrybenko
a93280536d Remove a random include inside ParseExpr.cpp
Swift SVN r6210
2013-07-12 20:28:04 +00:00
Dmitri Hrybenko
02084efab7 Implement code completion for some function calls and member variable accesses
in expr-dot and expr-postfix that can be typechecked without typechecking the
beginning of the function body.


Swift SVN r6198
2013-07-12 02:00:41 +00:00
Dmitri Hrybenko
b537d4e73b Fix grammar: remove a reference to the non-existent expr-func
Swift SVN r6141
2013-07-11 00:12:34 +00:00
Dmitri Hrybenko
c0924c2c58 Correct the grammar for magic literals
Swift SVN r6140
2013-07-11 00:02:33 +00:00
Doug Gregor
a40fdbfd8d Make 'in' a real keyword.
Swift SVN r6129
2013-07-10 21:37:50 +00:00