Commit Graph

41 Commits

Author SHA1 Message Date
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Chris Lattner
6afe77d597 Eliminate the Parameter type completely - now ParameterList is just
an overblown array of ParamDecl*'s that also keeps track of parenlocs
and has helper methods.
2016-01-03 14:45:38 -08:00
Chris Lattner
a30ae2bf55 Merge pull request #836 from zachpanz88/new-year
Update copyright date
2015-12-31 19:36:14 -08:00
Chris Lattner
7daaa22d93 Completely reimplement/redesign the AST representation of parameters.
Parameters (to methods, initializers, accessors, subscripts, etc) have always been represented
as Pattern's (of a particular sort), stemming from an early design direction that was abandoned.
Being built on top of patterns leads to patterns being overly complicated (e.g. tuple patterns
have to have varargs and default parameters) and make working on parameter lists complicated
and error prone.  This might have been ok in 2015, but there is no way we can live like this in
2016.

Instead of using Patterns, carve out a new ParameterList and Parameter type to represent all the
parameter specific stuff.  This simplifies many things and allows a lot of simplifications.
Unfortunately, I wasn't able to do this very incrementally, so this is a huge patch.  The good
news is that it erases a ton of code, and the technical debt that went with it.  Ignoring test
suite changes, we have:
   77 files changed, 2359 insertions(+), 3221 deletions(-)

This patch also makes a bunch of wierd things dead, but I'll sweep those out in follow-on
patches.

Fixes <rdar://problem/22846558> No code completions in Foo( when Foo has error type
Fixes <rdar://problem/24026538> Slight regression in generated header, which I filed to go with 3a23d75.

Fixes an overloading bug involving default arguments and curried functions (see the diff to
Constraints/diagnostics.swift, which we now correctly accept).

Fixes cases where problems with parameters would get emitted multiple times, e.g. in the
test/Parse/subscripting.swift testcase.

The source range for ParamDecl now includes its type, which permutes some of the IDE / SourceModel tests
(for the better, I think).

Eliminates the bogus "type annotation missing in pattern" error message when a type isn't
specified for a parameter (see test/decl/func/functions.swift).

This now consistently parenthesizes argument lists in function types, which leads to many diffs in the
SILGen tests among others.

This does break the "sibling indentation" test in SourceKit/CodeFormat/indent-sibling.swift, and
I haven't been able to figure it out.  Given that this is experimental functionality anyway,
I'm just XFAILing the test for now.  i'll look at it separately from this mongo diff.
2015-12-31 19:24:46 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Doug Gregor
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00
John McCall
080b7dfabf Remove the default handle-all Decl and DeclAttribute
cases from ASTVisitor and privatize SILGen's statement
emitter.  NFC.

Swift SVN r26402
2015-03-22 03:22:45 +00:00
Jordan Rose
727a7eb77a Attributes: Use class names in the DAK_* enum instead of attribute spellings.
This allows for single attributes that can be spelled multiple ways.
No functionality change.

Swift SVN r18993
2014-06-18 23:28:28 +00:00
Ted Kremenek
ad2afaeb34 Start serializing out DeclAttribute objects using generalized serialization logic.
To generalize our serialization logic for more attributes, serialize
each DeclAttribute object in a separate bitcode record.

For simple declaration attributes (no arguments), all of this
serialization logic can be fully automatically generated, and is
done so in this patch.  This currently includes @final, but will
expand over time.

To illustrate the plumbing end-to-end, move the serialization logic
for asmnmame over to the new mechanism.

Swift SVN r15933
2014-04-04 08:52:32 +00:00
Doug Gregor
be3ec6359a Make DeclAttributes visitable via an AST visitor.
Swift SVN r15900
2014-04-03 22:57:15 +00:00
Argyrios Kyrtzidis
84e20a0620 [AST] Break down IdentTypeRepr to different subtypes.
This makes memory allocation for it more efficient and it's more convenient to handle.

Swift SVN r12541
2014-01-18 20:19:09 +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
Joe Groff
554b8f4d12 AST: Fix up ASTVisitor's argument support.
Missed a few places where the extra args needed to be forwarded.

Swift SVN r3578
2012-12-21 21:16:34 +00:00
Joe Groff
6378e4312d AST: Allow ASTVisitors to add visit() args.
Allow an ASTVisitor subtype to have additional arguments to visit(T *, Args...) forwarded down to its instance methods.

Swift SVN r3569
2012-12-21 02:37:08 +00:00
Ted Kremenek
0e5ff44b27 Add boilerplate for the *start* of Swift CFGs. Nothing to look at yet. Major WIP.
Swift SVN r2506
2012-08-02 21:21:03 +00:00
John McCall
0cd849b19c Complete the pattern-matching IR emission logic,
at least for exhaustive patterns.

Swift SVN r1359
2012-04-10 08:28:31 +00:00
John McCall
95f97e89ea The DeclRetTy of an ASTVisitor is the third argument.
Swift SVN r1266
2012-03-26 06:08:16 +00:00
Chris Lattner
7c2da880e1 Put 'Expr' in the right place.
Swift SVN r1197
2012-03-11 14:54:43 +00:00
Chris Lattner
672801980d enhance ASTVisitor for expressions to automatically synthesize visit methods for nodes
that are not handled by a visitor.  Make their implementation chain up to a parent node's
implementation.  For example, a (silly) visitor could choose to just implement visitExpr
and get all nodes.


Swift SVN r1194
2012-03-11 14:47:16 +00:00
John McCall
d74f17259c Incremental getterization of Decl.h.
Swift SVN r882
2011-11-18 00:17:20 +00:00
Chris Lattner
7e96d0d53e embrace macro metaprogramming for decls.
Swift SVN r867
2011-11-10 22:08:46 +00:00
John McCall
344fe891da Macro metaprogramming for Stmt nodes.
Swift SVN r726
2011-09-23 23:32:07 +00:00
John McCall
cf0da63bbc A couple more unreachables.
Swift SVN r725
2011-09-23 21:59:16 +00:00
John McCall
ef8b77b718 Use Expr metaprogramming.
Swift SVN r723
2011-09-23 21:53:39 +00:00
John McCall
b2facdae4b Getterize Stmt.h.
Swift SVN r720
2011-09-20 07:07:53 +00:00
John McCall
02e47ed9ce Privatize Expr's Ty and Kind members; introduce getters and setters.
Swift SVN r716
2011-09-19 22:00:20 +00:00
Chris Lattner
8eaddc1cda AST support for floating point literals.
Swift SVN r707
2011-09-15 21:37:46 +00:00
Chris Lattner
77237852d2 implement a.x syntax for using elements of a protocol.
Swift SVN r704
2011-09-11 17:39:45 +00:00
John McCall
54ff2ccf4a Lop the last word off ModuleDecl and TranslationUnitDecl.
Swift SVN r693
2011-09-06 21:43:46 +00:00
John McCall
4a0f713e62 Progress towards a builtin module.
Swift SVN r682
2011-09-03 05:35:49 +00:00
Chris Lattner
a838f412f4 eliminate ProtocolFuncElementDecl, just use FuncDecl instead.
Swift SVN r668
2011-09-01 18:17:12 +00:00
Chris Lattner
70bbb65241 make ProtocolType a DeclContext, add AST and trivial sema support for
ProtocolFuncElementDecl, the first thing we will allow in a protocol.


Swift SVN r664
2011-08-31 23:31:42 +00:00
Chris Lattner
4c9b8ecf11 add ast and sema support for unary operators. We need some serious AST refactoring
to unify our representation of calls, which I'll do later.


Swift SVN r570
2011-08-19 22:40:26 +00:00
John McCall
ddd134854e Rename ApplyExpr to CallExpr and change the signature of SemaCallExpr.
Swift SVN r523
2011-08-12 17:31:14 +00:00
Chris Lattner
ce6f6a83cd add AST support for WhileStmt. This isn't important, but is easy to add.
Swift SVN r501
2011-08-11 20:33:34 +00:00
Chris Lattner
433d6de807 implement AST and parser support for 'return'. We're still not doing a conversion
to a return type yet though.  We happily diagnose thigns like this as an error:

func foo() -> int {
  return 4 5
}



Swift SVN r493
2011-08-03 23:19:24 +00:00
Chris Lattner
c86e786ab5 switch langref to new func syntax, switch implementation to use FuncExpr instead of LambdaExpr.
Swift SVN r487
2011-08-03 00:32:15 +00:00
Chris Lattner
350b89e6e4 Represent assignments as their own AssignStmt, preserving the model we had
before, but removing the hack where we'd represent them as a binary operator
with a null operator function.  We still have no clear semantics for what 
is valid or not.



Swift SVN r478
2011-08-01 17:45:21 +00:00
Chris Lattner
ebc33d306f add AST support for semicolon statements and clean up the parser. While noone cares, it is trivial
to support and good for completeness.


Swift SVN r475
2011-07-31 21:09:23 +00:00
Chris Lattner
fb8621f53a introduce DeclVisitor, ExprVisitor, and StmtVisitor template typedefs.
Swift SVN r472
2011-07-31 20:46:12 +00:00
Chris Lattner
d5523fa257 rename ExprStmtVisitor to ASTVisitor.
Swift SVN r471
2011-07-31 20:41:11 +00:00