Commit Graph

483 Commits

Author SHA1 Message Date
Doug Gregor
04ffc8c432 Introduce a new abstract type, SubstitutableType, to cover types that
can be substituted, and do some simply renaming to distance ourselves
from archetypes in these code paths.


Swift SVN r2295
2012-07-03 17:37:27 +00:00
John McCall
668f674bfa Split off a PolymorphicFunctionType from FunctionType. I am
*positive* that the behavior here is blatantly wrong in a lot
of places, but I'm going to leave it to Doug to clean up after me. :)

Swift SVN r2255
2012-06-27 00:22:15 +00:00
Eli Friedman
ecc56538b3 Add a basic TypeLoc; start threading it through the parser.
Doug, please double-check that this is going in the right direction...



Swift SVN r2146
2012-06-05 00:11:59 +00:00
Doug Gregor
c079874625 Implement parsing, AST, type canonicalization, and type validation for
protocol conformance types, e.g., 'protocol<P, Q>'. A few things
people *might* want to scream about, or at least scrutinize:

  - The parsing of the '<' and '>' is odd, because '<' and '>' aren't
    tokens, but are part of the operator grammar. Neither are '>>',
    '>>>', '<>', etc., which also come up and need to be parsed
    here. Rather than turning anything starting with '<' or '>' into a
    different kind of token, I instead parse the initial '<' or '>'
    from an operator token and leave the rest of the token as the
    remaining operator.
  - The canonical form of a protocol-composition type is minimized by
    removing any protocols in the list that were inherited by other
    protocols in the list, then sorting it. If a singleton list is
    left, then the canonical type is simply that protocol type.
  - It's a little unfortunate that we now have two existential types
    in the system (ProtocolType and ProtocolCompositionType), because
    many places will have to check both. Once ProtocolCompositionTypes
    are working, we should consider whether it makes sense to remove
    ProtocolType.

Still to come: name lookup, coercions.



Swift SVN r2066
2012-05-30 00:39:08 +00:00
Doug Gregor
9096497f0f Rename "dependent type" to "unresolved type" universally. We've been
using the term "unresolved" in expressions for a while, and it fits
for types better than "dependent type."

The term "dependent type" will likely come back at some point to mean
"involves an archetype".



Swift SVN r1962
2012-05-23 19:03:14 +00:00
Doug Gregor
8e1cd3990b Implement substitution of types, which substitutes concrete types for
archetypes. Use this substitution when checking the
variable/function/subscript witnesses during protocol conformance.

This allows us to check the conforms-to relationship for the Range
protocol as we want to express it.


Swift SVN r1945
2012-05-23 00:39:06 +00:00
Doug Gregor
d37602629e Implement parsing, AST, and conformance checking for associated types
in protocols, e.g.,

  protocol Range {
    typealias Element
    func getAndAdvance() -> Element
  }



Swift SVN r1941
2012-05-22 21:45:58 +00:00
John McCall
38bac7c706 Add Builtin.ObjCPointer with accompanying IR-gen support and
wrap it in an 'id' type in the standard library.

Also fix a bug noticed by inspection where initWithTake for
function types wasn't entering a cleanup for the taken value.
This probably doesn't matter for existing possibilities, but
it's potentially important under exceptions.

Swift SVN r1902
2012-05-18 23:40:17 +00:00
Eli Friedman
bb0a98d487 Finish off varargs.
Swift SVN r1892
2012-05-18 00:04:07 +00:00
Eli Friedman
79c3276b07 AST representation for ClassDecls.
Swift SVN r1858
2012-05-15 21:53:38 +00:00
Eli Friedman
d98c55f665 Followup to r1819: there was an issue with that commit I hadn't spotted before related to mismatched types. This commit solves it for FuncDecls, but not SubscriptDecls (see the FIXME).
Swift SVN r1822
2012-05-12 02:52:14 +00:00
Eli Friedman
df9156589b Ban default values in patterns in semantic analysis. Null out default values from patterns for function signatures, since default values are really part of the type, not the pattern, in that case. Fixes <rdar://problem/11406484>.
Swift SVN r1821
2012-05-12 01:53:37 +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
Chris Lattner
54c7c6ea74 Add some helper functions to help treat "spaced" lparen and lsquares uniformly.
Swift SVN r1708
2012-05-02 00:30:45 +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
9ba80f7716 Properly pass the arguments specified for subscripting access down to
the functions that we generate for the getter/setter, so that the
index parameters are in scope. 


Swift SVN r1479
2012-04-18 23:38:10 +00:00
John McCall
6133630544 When type-checking a slice type, "desugar" it to a type that is
generic over the type of the base.  By "generic" I mean that it's
looked up by prepending the word "Slice" to the name of the base
type.

Swift SVN r1464
2012-04-18 08:09:10 +00:00
Doug Gregor
6ce55acfc4 Parse getters and setters for variables.
Swift SVN r1408
2012-04-12 23:59:53 +00:00
Eli Friedman
361481835c Introduce a notion of module scope declarations; use it where appropriate instead of checking for a local declcontext.
Swift SVN r1380
2012-04-11 02:52:40 +00:00
Eli Friedman
065a74d237 Make sure we always explicitly set the DeclContext for a VarDecl built from a pattern.
Swift SVN r1379
2012-04-11 02:24:36 +00:00
Chris Lattner
65b400e30d introduce a new "Builtin.RawPointer" type, which corresponds to LLVM's "i8*" type,
and is just an unmanaged pointer.  Also, introduce a basic swift.string type.

This is progress towards rdar://10923403 and strings.  Review welcome.



Swift SVN r1349
2012-04-10 00:52:52 +00:00
Eli Friedman
70770465e4 Get rid of ParseResult. <rdar://problem/11018362>.
Swift SVN r1321
2012-04-04 20:21:35 +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
Doug Gregor
4cc616f2be Rename the DependentType class to UnstructuredDependentType, because
this type is only going to cover dependent types for which there is
absolutely no structure. Still no functionality change.


Swift SVN r1292
2012-03-29 14:14:48 +00:00
John McCall
1f118dbda6 Basic support for Builtin.ObjectPointer as a completely
opaque type.  Also some rudimentary support for retain/release.

Swift SVN r1214
2012-03-16 09:26:32 +00:00
John McCall
b2a2027a43 Revert r1144, r1145, and r1146. These changes (which removed ParenType
in favor of a single-element non-canonical TupleType) broke the type
system, in that supposed sugar (the TupleType) supported a different
set of operations from the canonical type.  For example, a
single-element unlabelled tuple type supports elementwise projection
(foo.$0), but the underlying element does not (or supports it
differently).

The IR-gen failure was due to a very related problem:  IR-gen
was not updated to reflect that a single unlabelled tuple element
is the same type as its element type, and therefore it was giving
different representations to these types ({ %foo } and %foo,
respectively), which broke widespread assumptions.

The removal of ParenType was done in pursuit of an AST invariant
that's not actually particularly interesting in the first place
and which, furthermore, is problematic to attain.

Swift SVN r1182
2012-03-11 09:15:21 +00:00
Chris Lattner
6641b06283 remove ParenType, which is now dead. Grouping parens are represented
as non-canonical tuple types.


Swift SVN r1147
2012-03-02 00:17:45 +00:00
Chris Lattner
6692cba150 simplify expression parsing to return a NullablePtr<Expr> instead of a ParseError<Expr>.
The later could represent semantic errors, but we'd rather represent those with an
ExprError node instead.  This simplifies the code and allows the parser to build a more
fully-formed AST that IDE clients will like.


Swift SVN r1141
2012-03-01 22:34:32 +00:00
Chris Lattner
17ea0a6670 finish my pass over LangRef, updating it and changing it and the parser to keep the grammars in sync.
Swift SVN r1132
2012-03-01 16:55:09 +00:00
John McCall
7b29a420f6 Design and implement the [byref] attribute, checking that
it doesn't appear in places it shouldn't.  The only limits on
this checking right now is the inadequacy of location information
for types, which is something we ought to fix.

Fix type-checking of byref applications.  Fix IR generation
of byref variables.  Whole lotta fixin' goin' on.

But hey, byref calls work.



Swift SVN r1111
2012-02-10 09:42:50 +00:00
John McCall
7f60469fdf Introduce the notion of a "fully-typed" type, necessary
because tuple types can have defaulted elements.  Check for
it and complain in function signatures.



Swift SVN r1109
2012-02-07 03:48:23 +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
16f8b2e656 Revise the language design for function argument clause syntax.
A function argument clause is now one or more patterns (which
must be parenthesized and explicitly type all positions) not
separated by arrows;  the first arrow then separates off the
return type.

Revisions to language reference forthcoming.



Swift SVN r1099
2012-01-26 01:25:26 +00:00