* Instead of hoisting VarDecl in the bridging functions, do it in
ASTGen.
* Introduce `Decl::forEachDeclToHoist` to handle VarDecls in
PatternBindingDecl, and EnumElementDecl in EnumCaseDecl.
* Intorduce `withBridgedSwiftClosure(closure:call:)` as a callback
mechanism between Swift and C++
* In `generate(sourceFile:)`, instead of using `generate(codeBlockItem:)`
handle `CodeBlockItemSyntax.Item` manually to handle `TLCD` wrapping
and `VarDecl` hoisting.
* Make `generate(variableDecl:)` handle TLCD correctly.
* Include `DeclContext` of the node where possible
* Add 'default-with-decl-contexts' dump style that dumps the dect context
hierarchy in addition to the AST
* Support `-dump-parse` with `-dump-ast-format json`
ASTDumper was never updated to print extra conformance information,
like suppression, preconcurrency, etc. In default mode, we print it
as a comma-delimited list of source-like strings. In JSON mode, we
print objects containing flags.
* Move `AvailabilitySpec` handling logic to AST, so they can be shared
between libParse and ASTGen
* Requestify '-define-availability' arguments parsing and parse them
with 'SwiftParser' according to the 'ParserASTGen' feature flag
* Implement 'AvailableAttr' generation in ASTGen
This only takes the existing AST information and writes it as JSON
instead of S-expressions. Since many of these fields are stringified,
they're not ideal for the kind of analysis clients of the JSON format
would want to do. A future commit will update these values to use a
more structured representation.
This makes the low-level `print*` methods in `PrintBase` simply
forward to the writer, which does the actual work. Right now,
there's only the abstract base class for the writer and the
default (S-expression-like) writer. A later commit will
introduce the JSON writer.
Also update the `printField*` methods to take `Label`s instead
of `StringRef`s.
Availability specs are currently dumped by writing a pre-formatted
string directly to the output stream instead of using the structured
primitives in `PrintBase`. This needs to be fixed before we can
introduce the generalized writers.
The format here is meant to be the same as the format printed by
the original methods, but some colors may differ slightly when
dumping to the terminal.
ASTDumper allows nodes/values to be printed without labels, which
works fine for the default output but won't work for JSON when every
value needs to have a valid key. To balance these needs, we create
a `Label` abstraction that can be created as either `always` or
`optional`. All the current labels are treated as `always`, and all
other values have had `optional` labels associated with them, which
won't be printed in the default AST dump.
This change also adds a `printList` function that replaces anywhere
that `for` loops with `printRec` calls in their bodies. This will
be used to provide the necessary array structuring for JSON output
later. (There are some places where `for` loops call `printFlag`
which will need to be dealt with later.)
Most of the compiler should use SemanticAvailableAttr instead. In contexts like
ASTDumper where a semantic attribute is unavailable use accessors on
AvailableAttr.
NFC.
The platform field now indicates whether the attribute applies universally, to
a specific platform, to the Swift language, or to package descriptions.
Additionally the output now reflects whether or not the attribute specifies
unconditional deprecation or unavailabity or is `noasync`.