Commit Graph

1316 Commits

Author SHA1 Message Date
Doug Gregor
5639fa888c Remove the initializer for NamedTypeRepr; types don't have default values.
Swift SVN r6163
2013-07-11 18:10:30 +00:00
Argyrios Kyrtzidis
3df3878490 [AST/TypeRepr] Address feedback by Doug.
-Add some FIXMEs
-Rename CompositeTypeRepr -> ProtocolCompositionTypeRepr
-Fix dumping of AttributedTypeRepr

Swift SVN r6150
2013-07-11 17:00:53 +00:00
Argyrios Kyrtzidis
a70eff6609 Introduce TypeRepr and related subclasses, that is a representation of a type as written in source.
This the first part for improving source location fidelity for types,
changes to follow:

-The Parser will not create any types, it will just create TypeReprs.
-The type checker will create the types by going through TypeReprs.
-IdentifierType will be removed.

Swift SVN r6112
2013-07-10 14:58:52 +00:00
Argyrios Kyrtzidis
7d3f33b505 [ASTDumper] Dump patterns as a tree, and more details from them (e.g. any Expr that may contain).
Swift SVN r6096
2013-07-09 22:18:35 +00:00
Jordan Rose
b31e79e571 Sink InfixOperatorDecl's InfixData into Decl's bitfields.
InfixData is still useful, since the type-checker uses it to treat other
operator-like constructs (e.g. 'is') the same way.

Swift SVN r6077
2013-07-08 23:40:58 +00:00
Doug Gregor
09e64a0243 Resolve unbound generic type references within their definitions.
When the name of a generic type is referenced, without any generic
arguments, within the definition of a generic type (or extensions of
that generic type), use the generic arguments provided by that
context. Thus, within the definition of X<T> below, one can simply use
'X' as a shorthand for 'X<T>':

  class X<T> {
    func swap(other : X) { /* ... */ } // same as "func swap(other : X<T>)"
  }

This resolution provides essentially the same behavior as the
injected class name does in C++. Note that this rule overrides any
inference rules, such that (for example) the following is ill-formed
rather than inferring the generic arguments of 'X':

  class X<T> {
    func foo() {
      var xi : X<Int> = X()
    }
  }

Note that name binding has changed slightly: when unqualified lookup
finds a type declaration within a nominal type, it is now treated as
a DeclRefExpr (or overloaded variant thereof) rather than as a member
access with an implicit 'this'.

Fixes <rdar://problem/14078437>.



Swift SVN r6049
2013-07-08 16:17:12 +00:00
Argyrios Kyrtzidis
f478157ab4 Revert "Print source ranges of the AST nodes when dumping the AST."
See if it fixes the buildbot.
This reverts commit 5957.

Swift SVN r5960
2013-07-02 16:45:07 +00:00
Argyrios Kyrtzidis
0a3fc1b195 Print source ranges of the AST nodes when dumping the AST.
Swift SVN r5959
2013-07-02 00:42:01 +00:00
Chris Lattner
2fe98e14e7 implement basic __FILE__, __LINE__, and __COLUMN__ magic identifiers.
Swift SVN r5912
2013-06-30 21:19:32 +00:00
Joe Groff
bec638856d Sema: Resolve tuple patterns.
Preprocess case label patterns with a ResolvePattern pass that pushes pattern-ness down the AST through tuples of patterns.

Swift SVN r5900
2013-06-30 03:56:25 +00:00
Joe Groff
b5d6103bfc AST: Add an UnresolvedPatternExpr to parse patterns in expr position.
Because of '~=' lookahead and precedence parsing, we need to be able to parse pattern productions in expression position and validate them after name binding. Add an unresolved Expr node that can hold a subpattern for this purpose.

Swift SVN r5825
2013-06-27 00:01:14 +00:00
Joe Groff
53221db84c AST: Add 'VarPattern' node.
We decided to go with 'var' as a distributive pattern introducer which applies to bare identifiers within the subpattern. For example, 'var (a, b)' and '(var a, var b)' would be equivalent patterns. To model this, give 'var' its own AST node with a subpattern and remove the introducer loc from NamedPattern.

Swift SVN r5824
2013-06-26 23:01:47 +00:00
Joe Groff
e460a01af6 Remove the 'UnresolvedCallPattern' I stubbed out.
I talked to John about parsing patterns today, and because of the magnitude of name-lookup-dependent ambiguities between patterns and expressions, we agreed that at least for a first-pass implementation it makes sense to parse patterns as extensions of the expr grammar and charge name binding with distinguishing patterns from expressions. This gets us out of needing the concept of an "unresolved pattern", at least in the short term.

Swift SVN r5808
2013-06-26 04:23:47 +00:00
Joe Groff
8deec52b17 Rework AST representation of CaseStmts.
A single case block can have one or more 'case ...:' labels. 'case' labels contain patterns instead of exprs. 'default:' is a funny spelling for 'case _:'. Change the CaseStmt representation and rip out all the parsing, type-checking, and SILGen built off the old representation.

Swift SVN r5795
2013-06-25 00:31:42 +00:00
Joe Groff
7ba95cfd26 Add AST nodes for refutable patterns.
Introduce Pattern subclasses for the 'is T', 'T(<pattern>)', and '<expr>' pattern syntaxes we'll be introducing for pattern-matching "switch" statements. Also add an 'UnresolvedCalLPattern' to act as an intermediate for name lookup to resolve to a nominal type, oneof element, or function call expression pattern. Since we'll need to be able to rewrite patterns like we do expressions, add setters to AST nodes that contain references to subpatterns. Implement some basic walking logic in places we search patterns for var decls, but punt on any more complex type-checking or SILGen derived from these nodes until we actually use them.

Swift SVN r5780
2013-06-24 17:17:34 +00:00
Argyrios Kyrtzidis
c7b33908ae Move the dumping visitors (PrintDecl/PrintStmt/PrintExpr) into one separate source file, so that they can easily share code, colors, and internal details.
Swift SVN r5770
2013-06-22 17:39:01 +00:00