18
18
#include " swift/Basic/LLVM.h"
19
19
#include " swift/Basic/LangOptions.h"
20
20
#include " swift/Bridging/ASTGen.h"
21
- #include " swift/Parse/Parser.h"
22
21
#include " swift/Subsystems.h"
23
22
#include " llvm/Support/CommandLine.h"
24
23
#include " llvm/Support/Error.h"
@@ -86,6 +85,9 @@ struct LibParseExecutor {
86
85
std::unique_ptr<ASTContext> ctx (ASTContext::get (
87
86
langOpts, typeckOpts, silOpts, searchPathOpts, clangOpts, symbolOpts,
88
87
casOpts, serializationOpts, SM, diagEngine));
88
+ auto &eval = ctx->evaluator ;
89
+ registerParseRequestFunctions (eval);
90
+ registerTypeCheckerRequestFunctions (eval);
89
91
90
92
SourceFile::ParsingOptions parseOpts;
91
93
parseOpts |= SourceFile::ParsingFlags::DisablePoundIfEvaluation;
@@ -96,13 +98,9 @@ struct LibParseExecutor {
96
98
SourceFile *SF =
97
99
new (*ctx) SourceFile (*M, SourceFileKind::Library, bufferID, parseOpts);
98
100
99
- Parser parser (bufferID, *SF, /* SILParserState=*/ nullptr );
100
- SmallVector<ASTNode> items;
101
- parser.parseTopLevelItems (items);
101
+ auto items = evaluateOrDefault (eval, ParseSourceFileRequest{SF}, {}).TopLevelItems ;
102
102
103
103
if (opts.contains (ExecuteOptionFlag::Dump)) {
104
- registerParseRequestFunctions (ctx->evaluator );
105
- registerTypeCheckerRequestFunctions (ctx->evaluator );
106
104
for (auto &item : items) {
107
105
item.dump (llvm::outs ());
108
106
}
@@ -163,8 +161,9 @@ struct ASTGenExecutor {
163
161
std::unique_ptr<ASTContext> ctx (ASTContext::get (
164
162
langOpts, typeckOpts, silOpts, searchPathOpts, clangOpts, symbolOpts,
165
163
casOpts, serializationOpts, SM, diagEngine));
166
- registerParseRequestFunctions (ctx->evaluator );
167
- registerTypeCheckerRequestFunctions (ctx->evaluator );
164
+ auto &eval = ctx->evaluator ;
165
+ registerParseRequestFunctions (eval);
166
+ registerTypeCheckerRequestFunctions (eval);
168
167
169
168
SourceFile::ParsingOptions parseOpts;
170
169
parseOpts |= SourceFile::ParsingFlags::DisablePoundIfEvaluation;
@@ -175,9 +174,7 @@ struct ASTGenExecutor {
175
174
SourceFile *SF =
176
175
new (*ctx) SourceFile (*M, SourceFileKind::Library, bufferID, parseOpts);
177
176
178
- Parser P (bufferID, *SF, nullptr );
179
- SmallVector<ASTNode> items;
180
- P.parseTopLevelItems (items);
177
+ auto items = evaluateOrDefault (eval, ParseSourceFileRequest{SF}, {}).TopLevelItems ;
181
178
182
179
if (opts.contains (ExecuteOptionFlag::Dump)) {
183
180
for (auto &item : items) {
0 commit comments