Commit Graph

21 Commits

Author SHA1 Message Date
Jordan Rose
f6ee9f6dc9 [ModuleInterface] Print imports (including '@_exported')
Part of preserving enough information to reconstitute a textual
interface back to a binary module.
2018-09-06 16:05:16 -07:00
Harlan
ad7e1d0e67 [InterfaceGen] Print private/internal properties (#19127)
* [Interface] Print private/internal properties

All properties which contribute to the storage of a type should be
printed, and their names should be hidden from interfaces. Print them
with '_' as their name, and teach the parser to recognize these special
patterns when parsing interface files.

Partially resolves rdar://43810647

* Address review comments

* Disable accessor generation for nameless vars

* Test to ensure interface files preserve type layout

* Ignore attribute differences on Linux
2018-09-06 09:58:33 -07:00
Harlan
dc1bc823e6 [InterfaceGen] Remove #ifs from default arguments (#19075)
* [InterfaceGen] Remove #ifs from default args

This patch removes all #if configs form the bodies of default arguments,
which can contain multiline closures, while preserving the bodies of the
clauses that are active.

This code is generalized and should "just work" for inlinable function
bodies, which will come in a later patch.

* Address review comments

* Fix and test CharSourceRange.overlaps

* Fix CharSourceRange::print to respect half-open ranges
2018-08-31 20:18:48 -07:00
Jordan Rose
eeb8f330f9 [ModuleInterface] Allow conformances to be missing value witnesses (#18932)
It's not clear whether we'll actually need this feature in the long
run, but we certainly need it now because non-@usableFromInline
members can (currently) satisfy public requirements when a
@usableFromInline internal type conforms to a public protocol. In
these cases, we'll treat the witnesses as present but opaque, and
clients will perform dynamic dispatch when using them even when
a generic function gets specialized.

With this, we're able to generate a textual interface for the standard
library, compile it back to a swiftmodule, and use it to build a Hello
World program!
2018-08-23 16:46:06 -07:00
Jordan Rose
46a542e75b Merge pull request #18863 from jrose-apple/gutenberg
Small improvements to AST printing in service of textual interfaces
2018-08-21 14:47:24 -07:00
Jordan Rose
71a2adbdde Check default arguments even if a function has no body (#18864)
This is needed for textual interfaces, but the behavior doesn't
have to be specific to that, since functions without bodies don't
come up in other situations.
2018-08-21 10:41:24 -07:00
Jordan Rose
7046980f99 [ModuleInterface] Print normally unprinted attributes
We need @_transparent to control mandatory inlining; @_fixed_layout to
control, well, layout; and @_effects to help optimization. We still
don't need the ImplicitlyUnwrappedOptional attribute, and we don't
need access control attributes (because we handle that uniformly).

This also fixes up the printing of the '_effects' attribute to include
its underscore, so that it matches the source spelling.
2018-08-20 18:30:01 -07:00
Jordan Rose
ad4d72568a [AST] Print "__owned" and "__shared" with leading underscores
The type printer was being optimistic about these, but that's a
problem for testing textual interfaces right now.
2018-08-20 18:30:00 -07:00
Jordan Rose
a17dbfbf29 Merge pull request #18778 from jrose-apple/towards-stability
[ModuleInterface] More changes to printing and parsing .swiftinterface files
2018-08-17 09:10:57 -07:00
Jordan Rose
dd8b37ee9f Merge pull request #18772 from jrose-apple/access-denied
Stop printing access on extensions and protocol requirements
2018-08-16 18:24:58 -07:00
Jordan Rose
c62fcad553 Don't synthesize initializers in swiftinterface files
...and then don't complain about a class not having any initializers.
2018-08-16 17:59:24 -07:00
Jordan Rose
0ca78265ef [ModuleInterface] Allow global/static variables without initial values 2018-08-16 17:59:24 -07:00
Jordan Rose
f061dff9b7 [ModuleInterface] Don't print typealiases that match generic params
These are synthesized to satisfy associated type requirements, but
they're not needed in source, and they look like self-referential
definitions (`typealias X = X`).
2018-08-16 17:59:24 -07:00
Jordan Rose
6526f11400 [ModuleInterface] Don't print access on extensions
This ends up meaning "don't print access attributes, then print access
uniformly on ValueDecls if you're not printing access attributes".
2018-08-16 16:00:42 -07:00
Jordan Rose
1a3cb5b630 [ModuleInterface] "Smoke test" struct and enum declarations too
This is not an exhaustive test of language features, but it at
least checks that the simple stuff is working.
2018-08-16 15:52:18 -07:00
Jordan Rose
e2a245d211 [SILGen] Also handle initializers without bodies
I was surprised to see this parses fine already, but SILGen still
needs a new check.
2018-08-16 15:52:18 -07:00
Jordan Rose
ec0719d3e0 Handle parsing deinitializers without bodies for .swiftinterfaces
The presence of a deinitializer will eventually indicate whether a
class's deinitializer is non-trivial for non-resilient modules.

Also improve recovery for normal source files for various bad ways
of declaring a deinitializer.
2018-08-16 15:48:13 -07:00
Jordan Rose
318e988ae1 [Parse] Allow parsing accessors without bodies for .swiftinterfaces
We're going to do need to do more here for inlinable accessors, which
/do/ have bodies, but this helps us get to a bare minimum testing
configuration.
2018-08-16 13:57:45 -07:00
Jordan Rose
d9e47650d5 Add a new SourceFileKind and InputFileKind for textual interfaces
And test this by tweaking the rules to allow functions without
definitions, like SIL files.
2018-08-07 08:55:07 -07:00
Jordan Rose
59940b7f04 [ModuleInterface] Filter using access control and @usableFromInline (#18521)
These are the parts of a (resilient) module that affect the public
interface and ABI; everything else is uninteresting. Or at least ought
to be.
2018-08-06 19:40:44 -07:00
Jordan Rose
e8e0584785 Hook up -emit-interface-path to a simple AST printer
We'll want more complexity soon, but this is a start.
2018-08-01 14:34:29 -07:00