Commit Graph

208 Commits

Author SHA1 Message Date
David Ungar
7bc8129321 First cut new Guard scheme 2019-06-05 10:24:11 -07:00
David Ungar
73279c99fb Upto findLookupParentForUse 2019-06-05 09:04:38 -07:00
David Ungar
dd5d4ab492 Rm unused 2019-06-05 08:33:03 -07:00
David Ungar
1c0da7511c Renaming 2019-06-05 08:31:00 -07:00
David Ungar
50e599b036 Renaming 2019-06-05 08:00:49 -07:00
David Ungar
e42ee8116d Fix assertion 2019-06-04 21:04:36 -07:00
David Ungar
606ce7b8cb pattern fixes 2019-06-04 20:50:59 -07:00
David Ungar
94bd4a801a fmt 2019-06-04 18:11:35 -07:00
David Ungar
8ff4309580 WIP, unfmt 2019-06-04 17:14:32 -07:00
David Ungar
3f3f51c7b9 new pattern code 2019-06-04 14:36:52 -07:00
David Ungar
ad77af1b87 Catch top-level dependency for use under pattern.
var x = 3
_ = x
2019-06-03 21:13:25 -07:00
David Ungar
d914ec2640 Reverse closure scope args in prep for dup detection 2019-06-02 11:59:40 -07:00
David Ungar
23bddf12b4 Format 2019-05-31 21:03:05 -07:00
David Ungar
005e259247 compiles, unfmt 2019-05-31 21:02:19 -07:00
David Ungar
e6012a4809 fixes 2019-05-31 13:56:29 -07:00
David Ungar
2ad2bacec3 Format 2019-05-31 13:37:09 -07:00
David Ungar
11a9ee72b2 finished creation 2019-05-31 13:34:34 -07:00
David Ungar
9035ab85f5 WIP unfmt 2019-05-31 10:12:24 -07:00
David Ungar
40b0080c4c WIP createSubtree 2019-05-31 07:53:01 -07:00
David Ungar
2e7756c5c9 WP Redoing 2019-05-30 21:59:07 -07:00
David Ungar
8814390225 ifndef NDEBUG nify 2019-05-28 14:40:10 -07:00
David Ungar
2b9480dd35 Format 2019-05-28 12:38:30 -07:00
David Ungar
36234c3cc8 function_ref 2019-05-28 12:37:49 -07:00
David Ungar
741a0bfcd7 Typo fix. 2019-05-28 11:24:55 -07:00
David Ungar
3f820c374e Some review tweaks. 2019-05-28 11:12:12 -07:00
David Ungar
663760e3b7 ASTOOScope ontology 2019-05-28 10:48:22 -07:00
John McCall
584146f3f8 Allow a closure-parent ASTScope to be formed from any number of exprs. NFC.
Yield statements will allow an arbitrary number of operands --- like
calls, except we're going to skip over the tuple mistake. :)
2018-07-05 02:48:41 -04:00
Rintaro Ishizaki
a375267e5c [ASTScope] Remove ForStmt support. 2017-08-04 23:27:22 +09:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
practicalswift
6b1b2bad8a [gardening] "an unary" → "a unary", "an parameter" → "a parameter", "an struct" → "a struct" (#4768) 2016-09-14 21:25:15 -07:00
Doug Gregor
67fb8cc841 [Scope map] Model top-level code as a continuation of the source file.
Once top-level code is introduced into a source file, turn the source
file itself into a continuation, so that subsequent declarations have
proper scope information. This means we get proper scope information
for, e.g., pattern bindings and guard statements in top-level code, so
that a 'guard' at top level is a parent of all subsequent code,
including (e.g.) function declarations that might capture variables
introduced by the guard.

Continuations are now handled by more explicitly passing them down
from parent nodes to the child nodes that can accept them, and the
source file itself is modeled as a continuation as soon as the first
top-level code declaration is encountered.
2016-09-12 11:35:57 -07:00
Doug Gregor
909de5bd16 [Scope map] Type and abstract function declaration scopes can be continuations.
Rather than trying to specifically model local declarations of
functions and types with a "local declaration" scope, which we
introduced when we saw one of these entities with a local DeclContext,
use a more consistency scheme where:

  1) we always describe a type declaration with a TypeDecl scope and an
  (abstract) function declaration with an AbstractFunctionDecl scope,
  and
  2) either of those scopes can steal the continuation from their
  parent;

This modeling is another step toward supporting top-level code.
2016-09-12 11:35:57 -07:00
Doug Gregor
768f06826b [Scope maps] Reimplement continuation scopes with a more principled approach.
Record the active continuation scope for each scope. When we expand a
child node that introduces name that would be visible in a
continuation, we "steal" the continuation from the parent, so the
child takes over the responsibility of handling the continuation.

A continuation is initially introduced by expanding a brace statement,
where the continuation is itself. The eliminates a DRY violation
between the initial expansion of BraceStmts and
enumerateContinuationScopes() that's been nagging at me.

At present, this should be NFC, but it should make modeling top-level
code more reasonable.
2016-09-09 17:08:42 -07:00
Doug Gregor
2ad6629b49 [Scope map] Temporarily remove the caching of source ranges.
Source range caching needs to account for the fact that the 'end'
location of various scope nodes needs to track the end of the source
file, which can grow when we're working with the REPL. Until we have
that notion, don't cache.
2016-09-09 17:08:41 -07:00
Doug Gregor
abf9bfe9d5 [Scope map] Provide scopes for the generic parameters of protocols and extensions. 2016-09-07 16:44:36 -07:00
Doug Gregor
ead78e046f [Scope map] Explicitly model the scope of a function body.
For methods/initializers/deinitializers, modeling the scope of a
function body allows us to correctly introduce instance member lookup
relative to 'self'. Do so so that we can resolve unqualified name
lookup within methods based on the implicit 'self'.
2016-09-06 22:58:18 -07:00
Doug Gregor
311fc55bdb [Scope map] Query the declarations introduced by a given AST scope.
Introduce an operation that produces the set of local declarations
that are newly introduced by a given AST scope. This is a building
block of unqualified name lookup, which walks upward in the tree
(e.g., from children to parents) looking for declarations that have
been made visible at each step.
2016-09-06 09:05:10 -07:00
Doug Gregor
f47fc34a98 [Scope map] Document the ASTScope class. 2016-09-02 17:13:05 -07:00
Doug Gregor
c612f4feda [Scope map] Add support for querying the immediate and nearest enclosing DeclContexts of a scope. 2016-09-02 17:13:05 -07:00
Doug Gregor
8e39f3e0cd [Scope map] Model the scopes of default arguments. 2016-09-02 17:13:05 -07:00
Doug Gregor
ed173d2fbc [Scope map] Explicitly model pattern bindings and their initializers.
Consistently model all pattern bindings in the scope map, as well as
having specific nodes for their initializers. This provides us with
more consistency (the declarations are represented) as well as giving
us a scope we can use to extract the DeclContext for a non-local
initializer.
2016-09-02 17:13:05 -07:00
Doug Gregor
84b043365c [Scope map] Add a scope node for top-level code declarations. 2016-09-02 17:13:05 -07:00
Doug Gregor
35888ee0c2 [Scope map] Always introduce a node for AbstractFunctionDecls.
Part of making the scope map subsume the DeclContext change, so we can
identify the nearest enclosing DeclContext.
2016-09-02 17:13:05 -07:00
Doug Gregor
65c1bd2112 [Scope map] Cache the source range for a scope node, once computed.
Source ranges are non-trivial to compute, small to store, and used often. Cache 'em.
2016-09-02 17:13:05 -07:00
Doug Gregor
412d1d5e1e [Scope map] Introduce an operation to find the innermost scope based on a given source location.
Given a source location, we can find the innermost enclosing scope
that describes that source location. Introduce this operation into the
scope map, then add a testing mode where we probe the scope map at
specifi locations to see what we find. Test for:

1) Finding the right innermost enclosing scope, and
2) That we're only expanding the part of the scope map that is needed
to identify that scope.
2016-09-02 17:13:05 -07:00
Doug Gregor
4d9a92d898 Split guard statement into three non-overlapping children:
* A child to evaluate the conditions, which covers expressions in the conditions
  * A child for the 'else' body, which does not have access to the names in the conditions
  * A child for the continuation, which re-introduces the names in the conditions for the rest of the body

Now we can assert that the only out-of-order case is for accessors.
2016-09-02 17:13:05 -07:00
Doug Gregor
9a21677663 Add support for closures 2016-09-02 17:13:05 -07:00
Doug Gregor
9ea2fab6b9 Add support for getters/setters. 2016-09-02 17:13:05 -07:00