Commit Graph

2062 Commits

Author SHA1 Message Date
Dmitri Hrybenko
e2bb01f8ea AST printer: don't forget to pass down printing options when printing tuples
and function return types

rdar://15576210


Swift SVN r10752
2013-12-03 19:56:35 +00:00
John McCall
20e58dcf93 Change the type of function values in SIL to SILFunctionType.
Perform major abstraction remappings in SILGen.  Introduce
thunking functions as necessary to map between abstraction
patterns.

Swift SVN r10562
2013-11-19 22:55:09 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Joe Groff
19457c12ea Give Builtin.Word an abstract size.
Instead of hardcoding Builtin.Word to be an alias for Builtin.Int64, make it its own type of abstract pointer width.

- Change BuiltinIntegerType's width representation to accommodate abstract widths.

- In the AST and in SIL, store values of the types as the greatest supported size for the abstract width (64 bits for a pointer).

- Add some type safety to the ([sz]ext|trunc)(OrBitCast)? builtins that they're used appropriately given the upper and lower bounds of the abstract sizes they're working with.

- Now that Builtin.Word is a distinct type, give it its own mangling.

- In IRGen, lower pointer-sized BuiltinIntegerType appropriately for the target, and truncate lowered SIL values if necessary.

Fixes <rdar://problem/15367913>.

Swift SVN r10467
2013-11-14 19:56:26 +00:00
Joe Groff
b64d601bba Sema: Don't try to initialize static properties in implicit constructors.
The implicit default constructor shouldn't try to initialize static properties, and the implicit memberwise constructor shouldn't have arguments for static properties.

Swift SVN r10378
2013-11-12 22:10:15 +00:00
Doug Gregor
e5ca2c90d0 Parse @optional attribute on protocol members.
Swift SVN r9959
2013-11-05 15:58:19 +00:00
Dmitri Hrybenko
2e2f651f10 @objc inference: we don't ever infer @objc on a protocol
Swift SVN r9937
2013-11-04 23:14:41 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +00:00
Dmitri Hrybenko
8be81e8bfd @objc inference: add tests for inferring @objc on a class
Swift SVN r9837
2013-10-31 01:45:00 +00:00
Dmitri Hrybenko
1abce88392 AST Printer / @objc: print @objc(inferred) for constructors and destructors
Swift SVN r9833
2013-10-31 01:01:29 +00:00
Dmitri Hrybenko
324e6940c4 AST Printer / @objc: print @objc(inferred) for stored properties
Swift SVN r9832
2013-10-31 00:50:21 +00:00
Dmitri Hrybenko
a1b1be735a AST Printer: print inferred @objc attributes for variables, properties, and
getters/setters


Swift SVN r9822
2013-10-30 23:07:33 +00:00
Argyrios Kyrtzidis
e31c93add3 [AST] The ASTContext parameter in FuncDecl::getResultType() is not really needed.
Swift SVN r9798
2013-10-30 17:09:56 +00:00
Jordan Rose
0702acab3d Make SourceFile a DeclContext, but don't actually do anything with it yet.
Swift SVN r9646
2013-10-24 18:59:21 +00:00
Doug Gregor
d7a1d536b4 Introduce value witness markers into the generic set of requirements.
Value witness markers note the location within a generic function
type's list of requirements where the value witness table will be
placed when calling a generic function with that type. It allows one
to get the same effect from walking the requirements of a generic
function that one would get from walking all levels of a
GenericParamList, with all archetypes of each generic parameter list,
along with all of the protocols to which each archetype conforms,
which SILGen and IRGen both do.

AST verification ensures that the property above holds; we're not
making use of it just yet.


Swift SVN r9509
2013-10-19 00:19:01 +00:00
Joe Groff
5721bdda01 Don't pretend we can parse enum case refined types.
There's no way we'll be able to fully implement GADTs anytime soon.

Swift SVN r9477
2013-10-18 01:34:25 +00:00
Chris Lattner
d564b86916 fix the astprinter to print attributes in the right place, which should
fix IDE/print_ast_tc_decls.swift


Swift SVN r9286
2013-10-13 16:29:59 +00:00
Chris Lattner
6d6ad84831 switch ast printer to print attributes in the new syntax.
Swift SVN r9281
2013-10-13 14:56:54 +00:00
Dmitri Hrybenko
d585bf1a73 Fix tests after r9275
Swift SVN r9279
2013-10-13 06:56:43 +00:00
Chris Lattner
a476f65471 Abolish the old attribute syntax for type attributes (and SIL type attrs)
- Change type attribute printing logic (in astprinter and the demangler) 
  to print in the new syntax
- Change the swift parser to only accept type attributes in the new syntax.
- Update canParseTypeTupleBody to lookahead over new-syntax type attributes.
- Update the testsuite to use the new syntax.



Swift SVN r9273
2013-10-13 05:39:46 +00:00
Chris Lattner
80aee75507 The weak/unowned attributes are overloaded to mean two things:
1) on decls, they say the decl is weak/unowned.
2) in sil mode, on types, they indicate that the type has weak/unowned storage.

Since these are different things, split the SIL type attributes out to new 
attributes (sil_weak/sil_unowned) to crystalize the relationship.


Swift SVN r9270
2013-10-13 04:38:11 +00:00
Chris Lattner
e341dd94e9 inout, localstorage and silself are type attributes, not decl attributes.
Swift SVN r9269
2013-10-13 04:14:03 +00:00
Chris Lattner
b75e7c135b cc, auto_closure, thin, and objc_block attributes are only valid on types, make them
specific to types.  While we're at it, improve the diagnostic for when a decl-specific
attribute is applied to a type, or a type-specific attribute is applied to a decl.


Swift SVN r9268
2013-10-13 04:05:45 +00:00
Chris Lattner
09705dc7cd 1) Redesign DeclAttributes to be based around an array indexed by attribute, instead
of having a ton of ad-hoc bools in it.  This allows us to consolidate a ton of 
   boilerplate, eliminating 250 lines of code:

 17 files changed, 435 insertions(+), 662 deletions(-)

2) This eliminates the special case for weak and unowned attributes, which previously
   didn't show up in Attr.def.

3) While we're at it, keep track of proper source locations for each attribute, and
   use these to emit diagnostics pointing at the attribute in question instead of at
   a funcdecl or the @ sign.

4) Fix axle attributes, which had vertex and fragment swapped.



Swift SVN r9263
2013-10-13 01:25:50 +00:00
Dmitri Hrybenko
89a8cddbe0 AST Printer: add PrintOptions::SynthesizeSugarOnTypes for use by LLDB in some
cases


Swift SVN r9248
2013-10-12 00:43:32 +00:00
Dmitri Hrybenko
2acfadb38d AST printer: correctly print more complex cases of variadic tuple patterns
Swift SVN r9236
2013-10-11 23:47:07 +00:00
John McCall
af706c889a swift::SILFunctionType::ParameterType -> swift::SILParameterInfo
swift::SILFunctionType::ReturnType -> swift::SILReturnInfo

Swift SVN r9116
2013-10-10 00:31:38 +00:00
Doug Gregor
7fee09b41e Axle: Implement Matrix<T, N> and Matrix<T, N, M> syntactic sugar.
This completes the majority of <rdar://problem/15100137>.


Swift SVN r9098
2013-10-09 22:24:21 +00:00
Dmitri Hrybenko
6ad6518a56 AST Printer: prefer visit() to nested print() calls
Swift SVN r9093
2013-10-09 21:38:46 +00:00
Doug Gregor
fba128e191 Axle: Implement Vec<T, N> syntactic sugar for the VecTxN structs.
Implements the first part of <rdar://problem/15100137>.


Swift SVN r9092
2013-10-09 21:12:19 +00:00
John McCall
a38abec9fe Introduce (but don't yet use) SILFunctionType.
Swift SVN r9088
2013-10-09 20:55:42 +00:00
Doug Gregor
a012f60633 Make protocol methods generic over <Self>.
Pull the implicit 'Self' associated type out of the protocol and into
an implicitly-declared generic parameter list for the protocol. This
makes all of the methods of a protocol polymorphic, e.g., given

  protocol P {
    typealias Assoc
    func getAssoc() -> Assoc
  }

the type of P.getAssoc is:

  <Self : P> (self : @inout P) -> () -> Self.Assoc

This directly expresses the notion that protocol methods are
polymorphic, even though 'Self' is always implicitly bound. It can be
used to simplify IRgen and some parts of the type checker, as well as
laying more of the groundwork for default definitions within
protocols as well as sundry other improvements to the generics
system.

There are a number of moving parts that needed to be updated in tandem
for this. In no particular order:
  - Protocols always get an implicit generic parameter list, with a
  single generic parameter 'Self' that conforms to the protocol itself.
  - The 'Self' archetype type now knows which protocol it is
  associated with (since we can no longer point it at the Self
  associated type declaration).
  - Protocol methods now get interface types (i.e., canonicalizable
  dependent function types).
  - The "all archetypes" list for a polymorphic function type does not
  include the Self archetype nor its nested types, because they are
  handled implicitly. This avoids the need to rework IRGen's handling
  of archetypes for now.
  - When (de-)serializing a XREF for a function type that has an
  interface type, use the canonicalized interface type, which can be
  meaningfully compared during deserialization (unlike the
  PolymorphicFunctionType we'd otherwise be dealing with).
  - Added a SIL-specific type attribute @sil_self, which extracts the
  'Self' archetype of a protocol, because we can no longer refer to
  the associated type "P.Self". 




Swift SVN r9066
2013-10-09 17:27:58 +00:00
Joe Groff
0d8d756c83 Sema: Teach conformance checking to derive requirements if needed.
For derivable protocols, such as RawRepresentable on raw-typed enums, when checking the conformance, create a conforming decl if an explicit decl wasn't found. Refactor the conformance derivation for toRaw/fromRaw to be driven by conformance checking in this way.

Swift SVN r8930
2013-10-04 20:50:43 +00:00
Doug Gregor
361447021c Canonicalize generic type parameters with depth/index.
Swift SVN r8893
2013-10-03 22:33:22 +00:00
Doug Gregor
12e228c0f1 Introduce a new representation of polymorphic function types.
Introduces a new kind of function type, GenericFunctionType, that
represents a polymorphic function type with all of its generic
parameters and requirements stored in a more readily canonicalizable
form. It is meant to eventually replace PolymorphicFunctionType, but
for now we build it up in parallel so we can switch over to it
pieacemeal.

Note: this representation is built and then thrown away. We'll start
recording it soon.


Swift SVN r8881
2013-10-03 17:59:35 +00:00
Dmitri Hrybenko
b884b17891 AST Printer: don't print a space before a colon in a tuple label
For example:

  func f(a: Int)

instead of:

  func f(a : Int)


Swift SVN r8795
2013-09-30 22:58:16 +00:00
Joe Groff
92cce69e15 AST: Give NominalTypePattern a better AST-level representation.
Instead of relying on the subpattern being a well-formed TuplePattern, let's track our own subelements so we can associate them to properties and validate them ourselves.

Swift SVN r8771
2013-09-30 01:03:18 +00:00
Dmitri Hrybenko
52555294f9 Type printer: replace a broken variant of GenericParamList printer with a use of AST printer
Swift SVN r8751
2013-09-28 02:45:44 +00:00
Dmitri Hrybenko
38994060d5 AST printing: merge swift::Type::PrintOptions into swift::PrintOptions
There is no reason to have two different options structs.


Swift SVN r8749
2013-09-28 02:19:31 +00:00
Dmitri Hrybenko
b33caadd89 AST printer: print raw type of EnumDecl
Swift SVN r8716
2013-09-27 01:52:07 +00:00
Dmitri Hrybenko
448d7cff8e AST Printer: add tests for printing deserialized modules
...and fix bugs found by this.


Swift SVN r8706
2013-09-26 23:17:32 +00:00
Jordan Rose
e05c03d5bc Standardize terminology for "computed", "stored", "variable", and "property".
These are the terms sent out in the proposal last week and described in
StoredAndComputedVariables.rst.

variable
  anything declared with 'var'
member variable
  a variable inside a nominal type (may be an instance variable or not)
property
  another term for "member variable"
computed variable
  a variable with a custom getter or setter
stored variable
  a variable with backing storage; any non-computed variable

These terms pre-exist in SIL and IRGen, so I only attempted to solidify
their definitions. Other than the use of "field" for "tuple element",
none of these should be exposed to users.

field
  a tuple element, or
  the underlying storage for a stored variable in a struct or class
physical
  describes an entity whose value can be accessed directly
logical
  describes an entity whose value must be accessed through some accessor

Swift SVN r8698
2013-09-26 18:50:44 +00:00
Dmitri Hrybenko
5c142346c6 Destructor syntax: require an empty parameter list for destructors
rdar://14968738


Swift SVN r8694
2013-09-26 18:09:12 +00:00
Dmitri Hrybenko
5268940301 AST Printer: simplify the check for DynamicLookup known protocol
Swift SVN r8677
2013-09-25 23:41:33 +00:00
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +00:00
Anna Zaks
970bcd3bc6 fixup for r8625
Fix a copy and paste error + a better comment.
Thanks Dmitry.

Swift SVN r8631
2013-09-25 17:56:23 +00:00
Anna Zaks
30039a59f1 Emit Swift declarations when printing SIL.
Only print function member declarations and skip the bodies since the bodies are already represented in SIL and ASTPrinter is not good enough to print arbitrary expressions.

In order to have valid output, make sure that ASTPrinter does not print references to DynamicLookup protocol.

Swift SVN r8627
2013-09-25 17:08:42 +00:00
Dmitri Hrybenko
725b0e01eb AST Printer: fix printing of same type requirement in generic parameter lists
These types are really the same for the type checker, so they are printed in
exactly the same way.  To recover the original spelling, prefer to print
a TypeRepr, if available.


Swift SVN r8603
2013-09-24 21:16:35 +00:00
Dmitri Hrybenko
71dddd1c88 AST Printer: implement requirement printing in a generic parameter list
Swift SVN r8595
2013-09-24 17:55:19 +00:00