Commit 720b89d
[Parse/Sema/SIL] Implement
- Adds a new kind of accessor - init accessor - which could be used
to initialize one or more stored properties of the type.
- Just like getter and setter accessors, init accessor could be used
on any computed property.
- Init accessors can specify a set of properties they initialize and
accesses (property that should be initialized already) via declaration
attributes - `initializes` and `accesses`;
- Example of init accessor that initializes a stored property:
```swift
public struct Test {
private var _a: Int
public var a: Int {
init(initialValue) initializes(_a) {
_a = initialValue
}
get { _a }
set { _a = newValue }
}
}
```
- Modifies memberwise initializers to take advantage of this new
mechanism by replacing one or more stored property parameters with
corresponding init accessor(s).
- `struct Test` from previous example would get `init(a: Int) { self.a = a }`.
- Adds a new SIL instruction - `assign_or_init`; Similar to `assign_by_wrapper`
the "mode" is set by DI based on each use site.
- New intruction also tracks "assignments" - fields that have been
previously initialized and would re-assigned by invocation of init
accessor, it enables as to call init accessors multiple times even
before all fields have been initializes.
- When used in an initializer body, init accessor (i.e. `self.a = a`)
call becomes either an initialization (if all of the fields haven't
been initialized yet), or a call to setter.init accessors feature1 parent 7a32caf commit 720b89d
File tree
79 files changed
+2828
-53
lines changed- include/swift
- AST
- Basic
- Demangling
- Parse
- SIL
- lib
- AST
- Demangling
- IRGen
- Index
- Parse
- SILGen
- SILOptimizer
- Mandatory
- UtilityPasses
- Utils
- SIL
- IR
- Parser
- Utils
- Verifier
- Sema
- Serialization
- test
- Interpreter
- SILOptimizer
- decl/var
- tools
- SourceKit/lib/SwiftLang
- swift-ide-test
- utils
- gyb_sourcekit_support
- gyb_syntax_support
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
79 files changed
+2828
-53
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
103 | 111 | | |
104 | 112 | | |
105 | 113 | | |
| |||
174 | 182 | | |
175 | 183 | | |
176 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
177 | 189 | | |
178 | | - | |
| 190 | + | |
179 | 191 | | |
180 | 192 | | |
181 | 193 | | |
| 194 | + | |
182 | 195 | | |
183 | 196 | | |
184 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
1530 | 1531 | | |
1531 | 1532 | | |
1532 | 1533 | | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
1533 | 1596 | | |
1534 | 1597 | | |
1535 | 1598 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
188 | 190 | | |
| |||
3979 | 3981 | | |
3980 | 3982 | | |
3981 | 3983 | | |
| 3984 | + | |
| 3985 | + | |
| 3986 | + | |
| 3987 | + | |
| 3988 | + | |
| 3989 | + | |
| 3990 | + | |
| 3991 | + | |
| 3992 | + | |
| 3993 | + | |
3982 | 3994 | | |
3983 | 3995 | | |
3984 | 3996 | | |
| |||
7564 | 7576 | | |
7565 | 7577 | | |
7566 | 7578 | | |
| 7579 | + | |
| 7580 | + | |
| 7581 | + | |
| 7582 | + | |
7567 | 7583 | | |
7568 | 7584 | | |
7569 | 7585 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
312 | 315 | | |
313 | 316 | | |
314 | 317 | | |
| |||
2116 | 2119 | | |
2117 | 2120 | | |
2118 | 2121 | | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
2119 | 2130 | | |
2120 | 2131 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
192 | 195 | | |
193 | 196 | | |
194 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5807 | 5807 | | |
5808 | 5808 | | |
5809 | 5809 | | |
| 5810 | + | |
| 5811 | + | |
5810 | 5812 | | |
5811 | 5813 | | |
5812 | 5814 | | |
| |||
7226 | 7228 | | |
7227 | 7229 | | |
7228 | 7230 | | |
| 7231 | + | |
| 7232 | + | |
| 7233 | + | |
| 7234 | + | |
| 7235 | + | |
| 7236 | + | |
| 7237 | + | |
| 7238 | + | |
| 7239 | + | |
| 7240 | + | |
| 7241 | + | |
| 7242 | + | |
| 7243 | + | |
| 7244 | + | |
| 7245 | + | |
| 7246 | + | |
| 7247 | + | |
| 7248 | + | |
| 7249 | + | |
7229 | 7250 | | |
7230 | 7251 | | |
7231 | 7252 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1671 | 1671 | | |
1672 | 1672 | | |
1673 | 1673 | | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
1674 | 1693 | | |
1675 | 1694 | | |
1676 | 1695 | | |
| |||
4274 | 4293 | | |
4275 | 4294 | | |
4276 | 4295 | | |
| 4296 | + | |
| 4297 | + | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
| 4302 | + | |
| 4303 | + | |
| 4304 | + | |
| 4305 | + | |
| 4306 | + | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
| 4312 | + | |
| 4313 | + | |
| 4314 | + | |
4277 | 4315 | | |
4278 | 4316 | | |
4279 | 4317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
309 | 312 | | |
310 | 313 | | |
311 | 314 | | |
| |||
481 | 484 | | |
482 | 485 | | |
483 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| |||
0 commit comments