Commit Graph

4421 Commits

Author SHA1 Message Date
Doug Gregor
611a5cce4b Replace the library-defined postfix '!' with an expr-postfix production.
As with the monadic '?', we treat any left-bound '!' as a postfix
operator. Currently, it extracts the value of its optional
subexpression, failing at run-time if the optional is empty.


Swift SVN r8948
2013-10-06 23:09:58 +00:00
Dave Abrahams
55b215b021 [stdlib] StringDesign.rst: incremental progress
Swift SVN r8916
2013-10-04 16:47:33 +00:00
Chris Lattner
2f3f76f582 update langref to describe the new attribute syntax. Drop the old syntax, even
though the parser still eats it temporarily.


Swift SVN r8911
2013-10-04 05:17:14 +00:00
John McCall
298577676e Introduce the monadic ? operator.
A ? operator is interpreted as this if it's left-bound,
so ternary operators now have to be spaced on the left.

Swift SVN r8832
2013-10-02 01:27:45 +00:00
Jordan Rose
47f642ea73 [docs] Massage wording in Modules.rst.
Swift SVN r8820
2013-10-01 21:51:32 +00:00
Joe Groff
5049dbbc13 Update LangRef for 'x as T'.
Swift SVN r8813
2013-10-01 21:11:40 +00:00
Jordan Rose
700dcab4f4 [docs] Add some Objective-C interop stuff to Modules.rst.
Doesn't feel very complete, but I'm not sure how much there is to say here.
The user model is either that it works, or it doesn't.

Swift SVN r8810
2013-10-01 20:53:32 +00:00
Joe Groff
911929f1dd Parse and type check initializer closures after 'new T[n]' exprs.
Require that either T be default constructible or that the user provide a closure that maps indices to initial values. We don't actually call the closure yet to initialize the array; that's blocked on function abstraction difference <rdar://problem/13251236>.

Swift SVN r8801
2013-10-01 05:12:54 +00:00
Jordan Rose
8666b38886 [docs] Fill out another third or so of the Modules User Model doc.
This includes some potentially controversial topics:
- Multiple source files (to be discussed on existing e-mail thread)
- Ambiguity resolution rules
- Hierarchical names (unfinished)

Swift SVN r8799
2013-10-01 00:06:46 +00:00
Argyrios Kyrtzidis
f0773bcba1 Rename '__subscript' -> 'subscript'.
Since 'subscript' is a keyword, it cannot conflict with a function name.

Swift SVN r8787
2013-09-30 19:17:29 +00:00
Joe Groff
df5f1f51dd Parse attribute list after enum 'case' keyword.
For consistency with our other decl types. There aren't any case-specific attributes yet, but if/when we add them, this is where they'll go.

Swift SVN r8779
2013-09-30 17:13:34 +00:00
Joe Groff
0e7a6178d7 SIL.rst: Some fun facts about enums.
Swift SVN r8752
2013-09-28 03:23:10 +00:00
Joe Groff
ef6965b3bc SIL.rst: Update for removal of 'specialize'.
Swift SVN r8748
2013-09-28 00:36:23 +00:00
Jordan Rose
d9b8186653 [docs] Tweak description of a computed variable's lack of storage
Based on discussion with Anna.

Swift SVN r8746
2013-09-27 23:23:53 +00:00
Jordan Rose
91e1ade1e7 [docs] Start of Modules User Model: the high-level purpose and semantics.
Still to come:
- submodules
- source files as modules
- import search paths
- ObjC interop stuff

For a later doc:
- build model

Things to note as future work:
- namespaces
- fragility
- SPI vs. API

Swift SVN r8745
2013-09-27 23:13:10 +00:00
Michael Gottesman
68a6817ed1 [SIL] Update docs to specify that copy_addr/destroy_addr on trivial types is equivalent to a load/store and no-op respectively.
This patch just documents the answer I got from Joe when I asked him this
question.

Swift SVN r8742
2013-09-27 21:36:13 +00:00
Jordan Rose
75ae10d9b1 [docs] Note that our abstract model for literals has arbitrary precision.
Swift SVN r8701
2013-09-26 21:52:56 +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
Joe Groff
2118a70dc7 SIL.rst: Describe new checked cast instructions.
Swift SVN r8697
2013-09-26 18:44:54 +00:00
Dmitri Hrybenko
8b1628bad0 Update LangRef for destructor syntax change
Swift SVN r8695
2013-09-26 18:12:07 +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
Jordan Rose
8f112c2e47 [docs] Add a side doc describing the literal conversion process.
Not yet linked from the top-level because it's just for reference and has
not been vetted by anyone.

Swift SVN r8693
2013-09-26 17:48:17 +00:00
Jordan Rose
9993fa86c5 [docs] Add a description of stored and computed variables.
This is the proposal discussed on the mailing list and at Tuesday's
design meeting, in a more declarative form.

Swift SVN r8675
2013-09-25 23:39:59 +00:00
Joe Groff
cbfe3710f6 SIL: Rename the 'isObjC' SILDeclRef specifier to 'isForeign'.
Doug pointed out that 'isObjC' incorrectly excludes C functions, for which we'll also need to be able to independently reference Swift and foreign entries.

Swift SVN r8669
2013-09-25 21:59:03 +00:00
Joe Groff
b398492e23 LangRef: Elaborate on interaction of closure capture and inout.
Swift SVN r8666
2013-09-25 21:23:40 +00:00
Joe Groff
0621b811ad Describe inout semantics in more detail in LangRef.
Swift SVN r8663
2013-09-25 21:12:11 +00:00
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +00:00
Joe Groff
823d2ced20 Enums.rst: Spot fixes.
Swift SVN r8658
2013-09-25 20:29:52 +00:00
Joe Groff
2219b8417a Enums.rst: ReST errors.
Swift SVN r8657
2013-09-25 20:27:52 +00:00
Dave Abrahams
2e1333417c [docs] SIL.rst: fix ReST errors
Swift SVN r8656
2013-09-25 20:24:27 +00:00
Joe Groff
801efc55e7 SIL.rst: ReST typo.
Swift SVN r8577
2013-09-24 00:17:56 +00:00
Joe Groff
014f270516 SIL: Have project_existential_ref project to a protocol Self archetype.
This mirrors the behavior of project_existential and simplifies some special cases in SILGen. It unfortunately makes dynamic_lookup sequences a bit noisier because of the need to explicitly cast the projection from DynamicLookup.Self to Builtin.ObjCPointer, but I think this modeling is more solid and will fit better with my planned redesign of archetype_method/protocol_method.

Swift SVN r8572
2013-09-23 21:57:12 +00:00
Joe Groff
14f1b9da42 SIL.rst: Update for 'This' -> 'Self' sea change.
Swift SVN r8571
2013-09-23 21:57:05 +00:00
Joe Groff
9e54a69016 SIL: Allow RefToObjectPointer and ObjectPointerToRef to cast to/from Builtin.ObjCPointer.
Swift SVN r8558
2013-09-23 16:20:29 +00:00
Joe Groff
8d0d6ff1be LangRef: Demonstrate comma-separated case syntax.
The grammar already until-now-incorrectly claimed that 'case A, B' worked, but insert an example now that it actually works.

Swift SVN r8515
2013-09-20 20:44:11 +00:00
Joe Groff
26125d050b Update 'union' references in other docs.
Swift SVN r8483
2013-09-20 04:41:49 +00:00
Joe Groff
5106cd5e7c Capture the current enum game plan in a proposal doc.
Swift SVN r8481
2013-09-20 04:20:33 +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
John McCall
7954960797 Add 'copy_value' and 'destroy_value' operations to destroy
entire aggregates at once.

This has three worth effects:
  - It significantly decreases the amount of SIL required
    for these operations.
  - It makes it far easier for IR-gen to choose efficient
    patterns of destruction, e.g. calling a single entrypoint
    or recognizing that it can just use the runtime 'release'
    entrypoints.
  - It makes it easier to recognize and optimize aggregate
    copy/destroy operations.
It does make SROA-like tasks a bit more challenging.  The
intent is to give TypeLowering a way to expand these into
their primitive behavior.

Swift SVN r8465
2013-09-19 22:14:55 +00:00
Dave Abrahams
36db63b0d8 [stdlib] StringDesign.rst: remove "Extended with Restraint" section per Chris Kane's advice
Swift SVN r8449
2013-09-19 17:15:45 +00:00
Dave Abrahams
15673a1601 [stdlib] StringDesign.rst: add "Goals" and "Non-Goals" to introduction
Swift SVN r8429
2013-09-18 23:46:39 +00:00
Chris Lattner
1928361a5a Change the list of usecases for structs.
Swift SVN r8402
2013-09-18 16:12:14 +00:00
Howard Hinnant
810d2db1c6 Fix some minor type-o's and grammar mistakes.
Swift SVN r8401
2013-09-18 16:07:24 +00:00
Dave Zarzycki
fa8792d8a8 LangRef: Discuss why structs do not support inheritance
Swift SVN r8399
2013-09-18 15:18:48 +00:00
Doug Gregor
a14ddd41ba Minimally update LangRef for "constructor" -> "init" changes.
Swift SVN r8396
2013-09-18 05:49:34 +00:00
Dave Abrahams
e1a48abb0e [stdlib] StringDesign.rst: finalize first installment
Swift SVN r8365
2013-09-17 23:29:36 +00:00
Doug Gregor
90b8b3e499 Constructor selectors always start with 'init'.
Implement the new rules for mapping between selector names and
constructors. The selector for a given constructor is formed by
looking at the names of the constructor parameters:
  * For the first parameter, prepend "init" to the parameter name and
  uppercase the first letter of the parameter name. Append ':' if
  there are > 1 parameters or the parameter has non-empty-tuple type.
  * For the remaining parameters, the name of each parameter followed
  by ':'.

When a parameter doesn't exist, assume that the parameter name is the
empty string.

And, because I failed to commit it separately, support selector-style
declarations of constructor parameters so that we can actually write
constructors nicely, e.g.:

  // selector is initWithFoo:bar:
  constructor withFoo(foo : Foo) bar(bar : Bar) { ... }



Swift SVN r8361
2013-09-17 22:49:05 +00:00
Howard Hinnant
0a16b96587 Swift containers and value types
Swift SVN r8353
2013-09-17 21:20:35 +00:00
Doug Gregor
64ae92c4b4 Destruction of partially-constructed objects is required for any replacement of 'self'.
Thanks, Greg.


Swift SVN r8291
2013-09-16 20:29:45 +00:00
Doug Gregor
25bec36f9e Allow dynamic lookup through DynamicLookup.metatype.
Given an object of type DynamicLookup.metatype, allow us to find both
static and instance methods. 

Sema only; SILGen and IRGen changes to come.


Swift SVN r8290
2013-09-16 20:26:02 +00:00