Skip to content

Remove integrated REPL #31187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions include/swift/AST/IRGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ class IRGenOptions {
/// Whether we're generating IR for the JIT.
unsigned UseJIT : 1;

/// Whether we're generating code for the integrated REPL.
unsigned IntegratedREPL : 1;

/// Whether we should run LLVM optimizations after IRGen.
unsigned DisableLLVMOptzns : 1;

Expand Down Expand Up @@ -320,7 +317,7 @@ class IRGenOptions {
DebugInfoLevel(IRGenDebugInfoLevel::None),
DebugInfoFormat(IRGenDebugInfoFormat::None),
DisableClangModuleSkeletonCUs(false), UseJIT(false),
IntegratedREPL(false), DisableLLVMOptzns(false),
DisableLLVMOptzns(false),
DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false),
DisableFPElim(true), Playground(false), EmitStackPromotionChecks(false),
FunctionSections(false), PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
Expand Down
1 change: 0 additions & 1 deletion include/swift/AST/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ enum class FileUnitKind {
enum class SourceFileKind {
Library, ///< A normal .swift file.
Main, ///< A .swift file that can have top-level code.
REPL, ///< A virtual file that holds the user's input in the REPL.
SIL, ///< Came from a .sil file.
Interface ///< Came from a .swiftinterface file, representing another module.
};
Expand Down
12 changes: 1 addition & 11 deletions include/swift/AST/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class SourceFile final : public FileUnit {

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

Expand Down Expand Up @@ -232,15 +232,6 @@ class SourceFile final : public FileUnit {
return llvm::makeArrayRef(*Decls);
}

/// Truncates the list of top-level decls so it contains \c count elements. Do
/// not add any additional uses of this function.
void truncateTopLevelDecls(unsigned count) {
// Force decl parsing if we haven't already.
(void)getTopLevelDecls();
assert(count <= Decls->size() && "Can only truncate top-level decls!");
Decls->resize(count);
}

/// Retrieve the parsing options for the file.
ParsingOptions getParsingOptions() const { return ParsingOpts; }

Expand Down Expand Up @@ -524,7 +515,6 @@ class SourceFile final : public FileUnit {
bool isScriptMode() const {
switch (Kind) {
case SourceFileKind::Main:
case SourceFileKind::REPL:
return true;

case SourceFileKind::Library:
Expand Down
3 changes: 0 additions & 3 deletions include/swift/Immediate/Immediate.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ namespace swift {
int RunImmediately(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
const IRGenOptions &IRGenOpts, const SILOptions &SILOpts,
std::unique_ptr<SILModule> &&SM);

void runREPL(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
bool ParseStdlib);
} // end namespace swift

#endif // SWIFT_IMMEDIATE_IMMEDIATE_H
4 changes: 1 addition & 3 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,9 +1196,7 @@ class Verifier : public ASTWalker {
// it should be parented by the innermost function.
auto enclosingScope = Scopes[Scopes.size() - 2];
auto enclosingDC = enclosingScope.dyn_cast<DeclContext*>();
if (enclosingDC && !isa<AbstractClosureExpr>(enclosingDC)
&& !(isa<SourceFile>(enclosingDC)
&& cast<SourceFile>(enclosingDC)->Kind == SourceFileKind::REPL)){
if (enclosingDC && !isa<AbstractClosureExpr>(enclosingDC)){
auto parentDC = E->getParent();
if (!isa<Initializer>(parentDC)) {
Out << "a closure in non-local context should be parented "
Expand Down
10 changes: 1 addition & 9 deletions lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1686,12 +1686,6 @@ SourceFile::collectLinkLibraries(ModuleDecl::LinkLibraryCallback callback) const
continue;

if (next->getName() != getParentModule()->getName()) {
// Hack: Assume other REPL files already have their libraries linked.
if (!next->getFiles().empty())
if (auto *nextSource = dyn_cast<SourceFile>(next->getFiles().front()))
if (nextSource->Kind == SourceFileKind::REPL)
continue;

next->collectLinkLibraries(callback);
}

Expand Down Expand Up @@ -2461,7 +2455,6 @@ bool SourceFile::shouldCollectToken() const {
case SourceFileKind::Main:
case SourceFileKind::Interface:
return (bool)AllCorrectedTokens;
case SourceFileKind::REPL:
case SourceFileKind::SIL:
return false;
}
Expand All @@ -2478,7 +2471,6 @@ bool SourceFile::canBeParsedInFull() const {
case SourceFileKind::Main:
case SourceFileKind::Interface:
return true;
case SourceFileKind::REPL:
case SourceFileKind::SIL:
return false;
}
Expand All @@ -2490,7 +2482,7 @@ bool SourceFile::hasDelayedBodyParsing() const {
return false;

// Not supported right now.
if (Kind == SourceFileKind::REPL || Kind == SourceFileKind::SIL)
if (Kind == SourceFileKind::SIL)
return false;
if (hasInterfaceHash())
return false;
Expand Down
1 change: 0 additions & 1 deletion lib/AST/TypeCheckRequests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,6 @@ void TypeCheckSourceFileRequest::cacheResult(evaluator::SideEffect) const {
// skip verification and avoid caching it.
#ifndef NDEBUG
if (!Ctx.TypeCheckerOpts.DelayWholeModuleChecking &&
SF->Kind != SourceFileKind::REPL &&
SF->Kind != SourceFileKind::SIL &&
!Ctx.LangOpts.DebuggerSupport) {
Ctx.verifyAllLoadedModules();
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ SourceFileKind CompilerInvocation::getSourceFileKind() const {
case InputFileKind::SwiftLibrary:
return SourceFileKind::Library;
case InputFileKind::SwiftREPL:
return SourceFileKind::REPL;
return SourceFileKind::Main;
case InputFileKind::SwiftModuleInterface:
return SourceFileKind::Interface;
case InputFileKind::SIL:
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ void CompilerInstance::performSemaUpTo(SourceFile::ASTStage_t LimitStage) {
// Create the initial empty REPL file. This only exists to feed in the
// implicit imports such as the standard library.
auto *replFile =
createSourceFileForMainModule(SourceFileKind::REPL, /*BufferID*/ None);
createSourceFileForMainModule(SourceFileKind::Main, /*BufferID*/ None);
performImportResolution(*replFile);
return;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,9 +1278,8 @@ static bool performCompile(CompilerInstance &Instance,
(void)migrator::updateCodeAndEmitRemapIfNeeded(&Instance);

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

if (auto r = dumpASTIfNeeded(Instance))
Expand Down
4 changes: 1 addition & 3 deletions lib/IDE/REPLCodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ doCodeCompletion(SourceFile &SF, StringRef EnteredCode, unsigned *BufferID,
auto *newModule = ModuleDecl::create(
Ctx.getIdentifier("REPL_Code_Completion"), Ctx, implicitImports);
auto &newSF =
*new (Ctx) SourceFile(*newModule, SourceFileKind::REPL, *BufferID);
*new (Ctx) SourceFile(*newModule, SourceFileKind::Main, *BufferID);
newModule->addFile(newSF);

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

assert(SF.Kind == SourceFileKind::REPL && "Can't append to a non-REPL file");

unsigned BufferID;
doCodeCompletion(SF, EnteredCode, &BufferID,
CompletionCallbacksFactory.get());
Expand Down
5 changes: 0 additions & 5 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3020,11 +3020,6 @@ IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity) {
cast<llvm::GlobalValue>(entry), entity);
return {gotEquivalent, ConstantReference::Indirect};
};

// The integrated REPL incrementally adds new definitions, so always use
// indirect references in this mode.
if (IRGen.Opts.IntegratedREPL)
return indirect();

// Dynamically replaceable function keys are stored in the GlobalVars
// table, but they don't have an associated Decl, so they require
Expand Down
7 changes: 0 additions & 7 deletions lib/Immediate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
add_swift_host_library(swiftImmediate STATIC
Immediate.cpp
REPL.cpp
LLVM_LINK_COMPONENTS
executionengine
linker
Expand All @@ -14,9 +13,3 @@ target_link_libraries(swiftImmediate PRIVATE
swiftIRGen
swiftSILGen
swiftSILOptimizer)
if(LibEdit_FOUND AND LibEdit_HAS_UNICODE)
target_compile_definitions(swiftImmediate PRIVATE
HAVE_LIBEDIT)
target_link_libraries(swiftImmediate PRIVATE
libedit)
endif()
Loading