Commit Graph

42 Commits

Author SHA1 Message Date
Chris Lattner
fe9fe47b7e Implement support for generic typealiases. 2016-03-07 22:20:16 -08:00
Chris Lattner
dd3e962698 sink some more logic down to GenericTypeDecl, add support for safe downcasting
from Decl to GenericTypeDecl.  NFC.
2016-03-06 21:44:40 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
practicalswift
50baf2e53b Use consistent formatting in top of file headers. 2016-01-04 02:17:48 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Slava Pestov
5899e62637 AST: Add dynamic cast from Decl to IterableDeclContext
Also allow cast<> from any Decl to DeclContext, not just ValueDecl.
An example of a Decl that is a DeclContext but not a ValueDecl is
ExtensionDecl.

The const_cast<> hack is horrid but its needed to deal with both const
and non-const operands in the patch that eventually uses this.

Note that this adds an explicit 'const auto' to the prior usage of
cast<DeclContext> in Mangling.cpp.

NFC

Progress on <rdar://problem/20981254>.

Swift SVN r28929
2015-05-22 20:28:16 +00:00
Joe Groff
ae1f3af9be AST: Add the ability to dyn_cast a ValueDecl to DeclContext.
Swift SVN r28341
2015-05-08 23:57:23 +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
Doug Gregor
09797f7f99 Introduce a new declaration node, ParamDecl, for function parameters.
Use this node to capture the argument name and its source location in
the AST. We're only building these in one place at the moment; the
rest will be updated soon.


Swift SVN r16581
2014-04-20 05:23:35 +00:00
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00
Chris Lattner
a8d8e14254 introduce AbstractStorageDecl. Right now, just
move OverriddenDecl and usesObjCGetterAndSetter() up to it.
This allows usesObjCGetterAndSetter to subsume the logic
for subscript decls as well.



Swift SVN r12535
2014-01-18 19:08:39 +00:00
Joe Groff
5d8a7ff9e7 Allow multiple comma-separated enum elements in a 'case' decl.
Introduce an EnumCaseDecl for source fidelity to track the 'case' location and ordering of EnumElementDecls. Parse a comma-separated list of EnumElementDecls after a 'case' token.

Swift SVN r8509
2013-09-20 19:51:13 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Argyrios Kyrtzidis
d0d0978e19 [AST] Fix the parents in a few entries in DeclNodes.def.
Where's tablegen when you need it..

Swift SVN r8306
2013-09-16 23:37:23 +00:00
Dmitri Hrybenko
3cc01cf7d6 Introduce AbstractFunctionDecl -- a base class for ConstructorDecl,
DestructorDecl, FuncDecl -- and move some of the common concepts and logic
into it

No functionality change.


Swift SVN r8090
2013-09-11 04:04:01 +00:00
Dmitri Hrybenko
dae1d10c76 Fix an error in DeclNodes: ValueDecl did not include DestructorDecl
Found by reading code, so no tests.


Swift SVN r8024
2013-09-07 01:49:39 +00:00
Jordan Rose
fb74a12311 Fix indentation. No functionality change.
Swift SVN r7919
2013-09-04 22:18:44 +00:00
Doug Gregor
1ddb34fb71 Factor generic parameters and associated types into their own decl nodes.
Previously, TypeAliasDecl was used for typealiases, generic
parameters, and assocaited types, which is hideous and the source of
much confusion. Factor the latter two out into their own decl nodes,
with a common abstract base for "type parameters", and push these
nodes throughout the frontend.

No real functionality change, but this is a step toward uniquing
polymorphic types, among other things.


Swift SVN r7345
2013-08-19 23:36:58 +00:00
Jordan Rose
674a03b085 Replace "oneof" with "union"...everywhere.
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!

Swift SVN r6783
2013-07-31 21:33:33 +00:00
Joe Groff
aeeda4ee12 Parser: Parse operator decls.
At the top level, if 'operator' is followed by 'infix', 'prefix', or 'postfix', consider it a contextual keyword, and parse an operator decl following it that looks like:

  operator {infix|postfix|prefix} <+> {
    attributes…
  }

Prefix and postfix operator decls currently admit no attributes. Infix operators have 'associativity {left|right|none}' and 'precedence <int>' attributes.

This patch implements parsing for operator declarations but does not yet attach the declared attributes to func decls for the operators.

Swift SVN r4596
2013-04-03 23:30:50 +00:00
John McCall
0eb93abb96 Add the ability to metaprogram nominal type declarations.
Swift SVN r2403
2012-07-23 07:35:21 +00:00
Eli Friedman
6b4a248f04 Parsing and AST support for destructors on classes.
Swift SVN r2348
2012-07-12 01:26:02 +00:00
Eli Friedman
e5b4b924a1 More work on constructors. Basic testcases with "constructor" declarations appear to be working, although there's probably more work to be done. (Both old-style and new-style constructors work for the moment.)
Swift SVN r2163
2012-06-07 01:57:57 +00:00
Eli Friedman
75907029f1 Add parsing and semantic analysis for a basic ConstructorDecl. Still missing: no IRGen, and semantic analysis to actually call them.
Swift SVN r2159
2012-06-05 23:51:19 +00:00
Eli Friedman
5e206bc10f Rename DistinctTypeDecl to NominalTypeDecl.
Swift SVN r1882
2012-05-17 01:54:15 +00:00
Eli Friedman
79c3276b07 AST representation for ClassDecls.
Swift SVN r1858
2012-05-15 21:53:38 +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
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
Chris Lattner
774a557e5c Merge NamedDecl into ValueDecl, rdar://11379147.
Swift SVN r1737
2012-05-04 04:50:53 +00:00
Eli Friedman
255c5c0b14 Fix some obvious issues in DeclNodes.def found by inspection.
Swift SVN r1735
2012-05-04 00:51:03 +00:00
Doug Gregor
cd43490fb3 Implement semantic analysis for subscript expressions, using overload
resolution to pick the best subscript getter/setter pair. Does not yet
allow type coercion to influence overload resolution.



Swift SVN r1515
2012-04-19 23:01:04 +00:00
Eli Friedman
d5e7784010 Get rid of isModuleScope bit, since we don't like scattering bits across the AST; as a replacement, introduce TopLevelCodeDecl, which provides a DeclContext for all expressions and statements at the top level. <rdar://problem/11259941>.
Swift SVN r1503
2012-04-19 21:22:12 +00:00
Doug Gregor
06881faea2 Introduce an AST node for subscript declarations, and verify that the bodies of the getter and setter are being type-checked.
Swift SVN r1496
2012-04-19 20:29:48 +00:00
Eli Friedman
94244131f7 Remove ElementRefDecl and DeclVarName. Add the replacement, PatternBindingDecl. Use proper pattern parsing for variable declarations. Uniformly use PatternBindingDecl for variable initialization. Adapt type-checking and IRGen for this new style of variable declaration. <rdar://problem/11124980>.
Swift SVN r1312
2012-04-02 23:49:28 +00:00
John McCall
ce7780af04 I don't think we're really getting anything out of ArgDecl
at the moment.  We can put it back if I'm wrong.



Swift SVN r1100
2012-01-26 02:08:52 +00:00
John McCall
286abfc5f7 Mostly kill off RValue. More tomorrow. :)
Swift SVN r1020
2012-01-12 10:18:40 +00:00
Chris Lattner
37cb633b12 Change TypeAliasDecl to be a ValueDecl, whose type is MetaTypeType.
Swift SVN r1004
2012-01-11 07:13:32 +00:00
Chris Lattner
e22a30a130 revert r995: "introduce MetaTypeDecl (though nothing creates it yet)".
After some pondering on this, I can just use DeclRefExpr(TypeAliasDecl) to
represent a named metatype, there is not need to have yet-another decl.  I'm
glad about this, because it didn't seem right.



Swift SVN r999
2012-01-11 05:42:22 +00:00
Chris Lattner
f204abf010 introduce MetaTypeDecl (though nothing creates it yet)
Swift SVN r997
2012-01-06 20:50:56 +00:00
Chris Lattner
d666cc4fda define ExtensionDecl.
Swift SVN r892
2011-11-29 22:40:24 +00:00
Chris Lattner
7e96d0d53e embrace macro metaprogramming for decls.
Swift SVN r867
2011-11-10 22:08:46 +00:00