Commit Graph

783 Commits

Author SHA1 Message Date
Robert Widmann
f4f7f7f2ce Finish Off ASTGen Implementation for Types
Complete the lowering for the type ASTs present in SwiftSyntax to C++ TypeReprs
2022-10-27 11:11:11 -07:00
Doug Gregor
6cd0327655 Merge pull request #61691 from DougGregor/macros-expand-and-type-check 2022-10-24 05:47:57 -07:00
Doug Gregor
f04fd94465 [Macros] Separate out the expansion of macros into its own source file.
Once we've expanded a macro, create a new source buffer containing
the expanded macro contents.
2022-10-23 14:53:11 -07:00
Alex Hoppen
0738413fb7 [CMake] Link swiftParse and swiftAST against SwiftParserDiagnostics 2022-10-23 23:34:13 +02:00
Doug Gregor
e2993ea9bf [ASTGen] Support older host compilers 2022-10-21 06:41:06 -07:00
Doug Gregor
9979bb0e0a [Macros] Pass evaluated macro source back into the C++ part of the compiler.
Use this to print out the rewritten macro, for now.
2022-10-21 06:41:06 -07:00
Doug Gregor
636e6d1524 [Macros] "Expand" builtin macros for magic literals.
Introduce an experimental option `BuiltinMacros` that takes the magic
literals (`#file`, `#line`, `#function`, etc.) after type checking and
processes the original source for the expression using the build
syntactic macro system in the swift-syntax library. At present, the
result of expansion is printed to standard output, but it's enough to
verify that we're able to find the corresponding syntax node based on
the C++ AST.
2022-10-21 06:41:05 -07:00
Doug Gregor
9c528c6fe2 [ASTGen] Link in syntactic macros 2022-10-21 06:39:53 -07:00
Doug Gregor
2b741ad376 Move ASTGen source-file handling to its own (Swift) file 2022-10-21 06:39:53 -07:00
Doug Gregor
d33998538c Hold on to the SwiftSyntax source file parsed by ASTGen.
Rework the ASTGen interface to split apart parsing a source file,
turning the top-level declarations from that source file into C++ AST
nodes, and then deallocating that source file. Hold on to the source
file in the C++ SourceFile abstraction so we can query it later if we
need to.

And we will need to.
2022-10-21 06:39:53 -07:00
Doug Gregor
dec8813797 Merge pull request #61538 from DougGregor/astgen-spurious-whitespace
[ASTGen] Remove spurious whitespace
2022-10-12 15:42:59 -07:00
Doug Gregor
46703efe57 [ASTGen] Remove spurious whitespace 2022-10-10 16:42:13 -07:00
Doug Gregor
e35e82e7fd Add more missing dependencies 2022-10-10 14:33:38 -07:00
Doug Gregor
aed4f74f3f [ASTGen] Set the target triple for swiftASTGen.
Builds of Swift sources via CMake are not getting a target triple set,
so they pick up the host triple. This leads to spurious warnings about
linking in code built for a newer OS version (e.g., the one you're on)
into libraries with an older deployment target. It also breaks
building a cross-compiler. Always set the target triple.
2022-10-07 21:49:34 -07:00
Doug Gregor
7fd7e4fba5 [CMake Export swiftASTGen so the LLDB target can use it 2022-10-07 16:01:44 -07:00
Doug Gregor
5a0d775fa5 [ASTGen] Add a comment about the purporse of its Package.swift 2022-10-07 10:19:06 -07:00
Doug Gregor
c95b6c40c9 [ASTGen] Fix integer and string literal mapping 2022-10-07 10:19:06 -07:00
Doug Gregor
f516223c60 [ASTGen] Do a little property-wrapper dance to move DeclContext into the visitor 2022-10-07 10:19:06 -07:00
Doug Gregor
8d7f4dfdef Remove xcworkspacedata and UserInterfaceState.xcuserstate 2022-10-07 10:19:06 -07:00
Doug Gregor
d4e7371ac4 [ASTGen] Make sure we spin the C++ parser even when we don't use it.
This is a temporary hack; we shouldn't even need to create the C++
parser here.
2022-10-07 10:19:06 -07:00
Doug Gregor
2f61489543 Don't try to bridge diagnostics from C++ to Swift
We'll be going the other way, with diagnostics existentials.
2022-10-07 10:19:06 -07:00
Doug Gregor
7483373326 [ASTGen] Use UTF-8 rather than C char, and use BridgedIdentifier consistently 2022-10-07 10:19:06 -07:00
Doug Gregor
54bcb33ee9 [CMake] Make sure swiftASTGen links swiftAST. 2022-10-07 10:19:06 -07:00
Doug Gregor
39f54bc1b4 Use add_library for Swift ASTGen library 2022-10-07 10:19:06 -07:00
Doug Gregor
8e6628616d Fix the package that builds swiftASTGen. 2022-10-07 10:19:06 -07:00
Doug Gregor
4da85ea091 Clean up build logic for ASTGen library.
Only introduce it and its dependency when the new Swift parser is being
built, and rely more on existing logic to make sure we get the right
build/link flags.
2022-10-07 10:19:05 -07:00
zoecarver
73fe41373b Support functions with statements in their body.
(cherry picked from commit 5935670931)
2022-10-07 10:19:05 -07:00
zoecarver
93f1505e8a Add support for bool literals.
(cherry picked from commit d58a01db95)
2022-10-07 10:19:05 -07:00
zoecarver
94f890d6c7 [nfc] Split ASTGen into files + extensions.
(cherry picked from commit 629fb688f0)
2022-10-07 10:19:05 -07:00
zoecarver
f7d501d770 Add support for structs/classes.
(cherry picked from commit 1b1944ea48)
2022-10-07 10:19:05 -07:00
zoecarver
bed2742ba8 Make ASTGen a swift package
(cherry picked from commit 4e9e5fe6a8)
2022-10-07 10:19:05 -07:00
zoecarver
73a7c0ecc6 Apply Doug's review comments
(cherry picked from commit ddede209c7)
2022-10-07 10:18:40 -07:00
zoecarver
129fd386f9 Move ASTGen into Swift from swift-syntax.
(cherry picked from commit 2df25fc6e0)
2022-10-07 10:18:40 -07:00