Skip to content

Commit 590f83c

Browse files
authored
Merge pull request #31187 from slavapestov/remove-integrated-repl
Remove integrated REPL
2 parents 4a3e76b + 2a388b5 commit 590f83c

36 files changed

+20
-2365
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@ class IRGenOptions {
181181
/// Whether we're generating IR for the JIT.
182182
unsigned UseJIT : 1;
183183

184-
/// Whether we're generating code for the integrated REPL.
185-
unsigned IntegratedREPL : 1;
186-
187184
/// Whether we should run LLVM optimizations after IRGen.
188185
unsigned DisableLLVMOptzns : 1;
189186

@@ -320,7 +317,7 @@ class IRGenOptions {
320317
DebugInfoLevel(IRGenDebugInfoLevel::None),
321318
DebugInfoFormat(IRGenDebugInfoFormat::None),
322319
DisableClangModuleSkeletonCUs(false), UseJIT(false),
323-
IntegratedREPL(false), DisableLLVMOptzns(false),
320+
DisableLLVMOptzns(false),
324321
DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false),
325322
DisableFPElim(true), Playground(false), EmitStackPromotionChecks(false),
326323
FunctionSections(false), PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),

include/swift/AST/Module.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ enum class FileUnitKind {
107107
enum class SourceFileKind {
108108
Library, ///< A normal .swift file.
109109
Main, ///< A .swift file that can have top-level code.
110-
REPL, ///< A virtual file that holds the user's input in the REPL.
111110
SIL, ///< Came from a .sil file.
112111
Interface ///< Came from a .swiftinterface file, representing another module.
113112
};

include/swift/AST/SourceFile.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class SourceFile final : public FileUnit {
172172

173173
/// The list of top-level declarations in the source file. This is \c None if
174174
/// they have not yet been parsed.
175-
/// FIXME: Once addTopLevelDecl/prependTopLevelDecl/truncateTopLevelDecls
175+
/// FIXME: Once addTopLevelDecl/prependTopLevelDecl
176176
/// have been removed, this can become an optional ArrayRef.
177177
Optional<std::vector<Decl *>> Decls;
178178

@@ -232,15 +232,6 @@ class SourceFile final : public FileUnit {
232232
return llvm::makeArrayRef(*Decls);
233233
}
234234

235-
/// Truncates the list of top-level decls so it contains \c count elements. Do
236-
/// not add any additional uses of this function.
237-
void truncateTopLevelDecls(unsigned count) {
238-
// Force decl parsing if we haven't already.
239-
(void)getTopLevelDecls();
240-
assert(count <= Decls->size() && "Can only truncate top-level decls!");
241-
Decls->resize(count);
242-
}
243-
244235
/// Retrieve the parsing options for the file.
245236
ParsingOptions getParsingOptions() const { return ParsingOpts; }
246237

@@ -524,7 +515,6 @@ class SourceFile final : public FileUnit {
524515
bool isScriptMode() const {
525516
switch (Kind) {
526517
case SourceFileKind::Main:
527-
case SourceFileKind::REPL:
528518
return true;
529519

530520
case SourceFileKind::Library:

include/swift/Immediate/Immediate.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ namespace swift {
4141
int RunImmediately(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
4242
const IRGenOptions &IRGenOpts, const SILOptions &SILOpts,
4343
std::unique_ptr<SILModule> &&SM);
44-
45-
void runREPL(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
46-
bool ParseStdlib);
4744
} // end namespace swift
4845

4946
#endif // SWIFT_IMMEDIATE_IMMEDIATE_H

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,7 @@ class Verifier : public ASTWalker {
11961196
// it should be parented by the innermost function.
11971197
auto enclosingScope = Scopes[Scopes.size() - 2];
11981198
auto enclosingDC = enclosingScope.dyn_cast<DeclContext*>();
1199-
if (enclosingDC && !isa<AbstractClosureExpr>(enclosingDC)
1200-
&& !(isa<SourceFile>(enclosingDC)
1201-
&& cast<SourceFile>(enclosingDC)->Kind == SourceFileKind::REPL)){
1199+
if (enclosingDC && !isa<AbstractClosureExpr>(enclosingDC)){
12021200
auto parentDC = E->getParent();
12031201
if (!isa<Initializer>(parentDC)) {
12041202
Out << "a closure in non-local context should be parented "

lib/AST/Module.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,12 +1686,6 @@ SourceFile::collectLinkLibraries(ModuleDecl::LinkLibraryCallback callback) const
16861686
continue;
16871687

16881688
if (next->getName() != getParentModule()->getName()) {
1689-
// Hack: Assume other REPL files already have their libraries linked.
1690-
if (!next->getFiles().empty())
1691-
if (auto *nextSource = dyn_cast<SourceFile>(next->getFiles().front()))
1692-
if (nextSource->Kind == SourceFileKind::REPL)
1693-
continue;
1694-
16951689
next->collectLinkLibraries(callback);
16961690
}
16971691

@@ -2461,7 +2455,6 @@ bool SourceFile::shouldCollectToken() const {
24612455
case SourceFileKind::Main:
24622456
case SourceFileKind::Interface:
24632457
return (bool)AllCorrectedTokens;
2464-
case SourceFileKind::REPL:
24652458
case SourceFileKind::SIL:
24662459
return false;
24672460
}
@@ -2478,7 +2471,6 @@ bool SourceFile::canBeParsedInFull() const {
24782471
case SourceFileKind::Main:
24792472
case SourceFileKind::Interface:
24802473
return true;
2481-
case SourceFileKind::REPL:
24822474
case SourceFileKind::SIL:
24832475
return false;
24842476
}
@@ -2490,7 +2482,7 @@ bool SourceFile::hasDelayedBodyParsing() const {
24902482
return false;
24912483

24922484
// Not supported right now.
2493-
if (Kind == SourceFileKind::REPL || Kind == SourceFileKind::SIL)
2485+
if (Kind == SourceFileKind::SIL)
24942486
return false;
24952487
if (hasInterfaceHash())
24962488
return false;

lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,6 @@ void TypeCheckSourceFileRequest::cacheResult(evaluator::SideEffect) const {
14681468
// skip verification and avoid caching it.
14691469
#ifndef NDEBUG
14701470
if (!Ctx.TypeCheckerOpts.DelayWholeModuleChecking &&
1471-
SF->Kind != SourceFileKind::REPL &&
14721471
SF->Kind != SourceFileKind::SIL &&
14731472
!Ctx.LangOpts.DebuggerSupport) {
14741473
Ctx.verifyAllLoadedModules();

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ SourceFileKind CompilerInvocation::getSourceFileKind() const {
197197
case InputFileKind::SwiftLibrary:
198198
return SourceFileKind::Library;
199199
case InputFileKind::SwiftREPL:
200-
return SourceFileKind::REPL;
200+
return SourceFileKind::Main;
201201
case InputFileKind::SwiftModuleInterface:
202202
return SourceFileKind::Interface;
203203
case InputFileKind::SIL:

lib/Frontend/Frontend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ void CompilerInstance::performSemaUpTo(SourceFile::ASTStage_t LimitStage) {
783783
// Create the initial empty REPL file. This only exists to feed in the
784784
// implicit imports such as the standard library.
785785
auto *replFile =
786-
createSourceFileForMainModule(SourceFileKind::REPL, /*BufferID*/ None);
786+
createSourceFileForMainModule(SourceFileKind::Main, /*BufferID*/ None);
787787
performImportResolution(*replFile);
788788
return;
789789
}

lib/FrontendTool/FrontendTool.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,9 +1278,8 @@ static bool performCompile(CompilerInstance &Instance,
12781278
(void)migrator::updateCodeAndEmitRemapIfNeeded(&Instance);
12791279

12801280
if (Action == FrontendOptions::ActionType::REPL) {
1281-
runREPL(Instance, ProcessCmdLine(Args.begin(), Args.end()),
1282-
Invocation.getParseStdlib());
1283-
return Context.hadError();
1281+
llvm::report_fatal_error("Compiler-internal integrated REPL has been "
1282+
"removed; use the LLDB-enhanced REPL instead.");
12841283
}
12851284

12861285
if (auto r = dumpASTIfNeeded(Instance))

lib/IDE/REPLCodeCompletion.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ doCodeCompletion(SourceFile &SF, StringRef EnteredCode, unsigned *BufferID,
235235
auto *newModule = ModuleDecl::create(
236236
Ctx.getIdentifier("REPL_Code_Completion"), Ctx, implicitImports);
237237
auto &newSF =
238-
*new (Ctx) SourceFile(*newModule, SourceFileKind::REPL, *BufferID);
238+
*new (Ctx) SourceFile(*newModule, SourceFileKind::Main, *BufferID);
239239
newModule->addFile(newSF);
240240

241241
performImportResolution(newSF);
@@ -256,8 +256,6 @@ void REPLCompletions::populate(SourceFile &SF, StringRef EnteredCode) {
256256
CompletionStrings.clear();
257257
CookedResults.clear();
258258

259-
assert(SF.Kind == SourceFileKind::REPL && "Can't append to a non-REPL file");
260-
261259
unsigned BufferID;
262260
doCodeCompletion(SF, EnteredCode, &BufferID,
263261
CompletionCallbacksFactory.get());

lib/IRGen/GenDecl.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,11 +3020,6 @@ IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity) {
30203020
cast<llvm::GlobalValue>(entry), entity);
30213021
return {gotEquivalent, ConstantReference::Indirect};
30223022
};
3023-
3024-
// The integrated REPL incrementally adds new definitions, so always use
3025-
// indirect references in this mode.
3026-
if (IRGen.Opts.IntegratedREPL)
3027-
return indirect();
30283023

30293024
// Dynamically replaceable function keys are stored in the GlobalVars
30303025
// table, but they don't have an associated Decl, so they require

lib/Immediate/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
add_swift_host_library(swiftImmediate STATIC
22
Immediate.cpp
3-
REPL.cpp
43
LLVM_LINK_COMPONENTS
54
executionengine
65
linker
@@ -14,9 +13,3 @@ target_link_libraries(swiftImmediate PRIVATE
1413
swiftIRGen
1514
swiftSILGen
1615
swiftSILOptimizer)
17-
if(LibEdit_FOUND AND LibEdit_HAS_UNICODE)
18-
target_compile_definitions(swiftImmediate PRIVATE
19-
HAVE_LIBEDIT)
20-
target_link_libraries(swiftImmediate PRIVATE
21-
libedit)
22-
endif()

0 commit comments

Comments
 (0)