mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add :dump_ir to the REPL. <rdar://problem/11305412>.
Swift SVN r1582
This commit is contained in:
@@ -201,6 +201,7 @@ void swift::REPL(ASTContext &Context) {
|
|||||||
llvm::SmallPtrSet<TranslationUnit*, 8> ImportedModules;
|
llvm::SmallPtrSet<TranslationUnit*, 8> ImportedModules;
|
||||||
llvm::LLVMContext LLVMContext;
|
llvm::LLVMContext LLVMContext;
|
||||||
llvm::Module Module("REPL", LLVMContext);
|
llvm::Module Module("REPL", LLVMContext);
|
||||||
|
llvm::Module DumpModule("REPL", LLVMContext);
|
||||||
|
|
||||||
LoadSwiftRuntime();
|
LoadSwiftRuntime();
|
||||||
|
|
||||||
@@ -299,6 +300,8 @@ void swift::REPL(ASTContext &Context) {
|
|||||||
} else if (L.peekNextToken().getText() == "quit" ||
|
} else if (L.peekNextToken().getText() == "quit" ||
|
||||||
L.peekNextToken().getText() == "exit") {
|
L.peekNextToken().getText() == "exit") {
|
||||||
return;
|
return;
|
||||||
|
} else if (L.peekNextToken().getText() == "dump_ir") {
|
||||||
|
DumpModule.dump();
|
||||||
} else {
|
} else {
|
||||||
printf("%s", "Unknown interpreter escape; try :help\n");
|
printf("%s", "Unknown interpreter escape; try :help\n");
|
||||||
}
|
}
|
||||||
@@ -360,12 +363,21 @@ void swift::REPL(ASTContext &Context) {
|
|||||||
|
|
||||||
std::string ErrorMessage;
|
std::string ErrorMessage;
|
||||||
if (llvm::Linker::LinkModules(&Module, &LineModule,
|
if (llvm::Linker::LinkModules(&Module, &LineModule,
|
||||||
|
llvm::Linker::PreserveSource,
|
||||||
|
&ErrorMessage)) {
|
||||||
|
llvm::errs() << "Error linking swift modules\n";
|
||||||
|
llvm::errs() << ErrorMessage << "\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (llvm::Linker::LinkModules(&DumpModule, &LineModule,
|
||||||
llvm::Linker::DestroySource,
|
llvm::Linker::DestroySource,
|
||||||
&ErrorMessage)) {
|
&ErrorMessage)) {
|
||||||
llvm::errs() << "Error linking swift modules\n";
|
llvm::errs() << "Error linking swift modules\n";
|
||||||
llvm::errs() << ErrorMessage << "\n";
|
llvm::errs() << ErrorMessage << "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
llvm::Function *DumpModuleMain = DumpModule.getFunction("main");
|
||||||
|
DumpModuleMain->setName("repl.line");
|
||||||
|
|
||||||
if (IRGenImportedModules(TU, EE, Module, ImportedModules, Options))
|
if (IRGenImportedModules(TU, EE, Module, ImportedModules, Options))
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user