mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Replace the REPL command :dump_constraints with a way to toggle the
LangOptions bits for using the constraint solver and emitting its diagnostics. Swift SVN r2839
This commit is contained in:
@@ -316,9 +316,6 @@ void swift::REPL(ASTContext &Context) {
|
||||
printf("%s", "Welcome to swift. Type ':help' for assistance.\n");
|
||||
|
||||
while (1) {
|
||||
bool useConstraintSolver = false;
|
||||
bool debugConstraints = false;
|
||||
|
||||
// Read one line.
|
||||
e.PromptContinuationLevel = BraceCount;
|
||||
e.NeedPromptContinuation = BraceCount != 0 || HadLineContinuation;
|
||||
@@ -366,13 +363,15 @@ void swift::REPL(ASTContext &Context) {
|
||||
printf("%s", "Available commands:\n"
|
||||
" :quit - quit the interpreter (you can also use :exit"
|
||||
" or Control+D or exit(0))\n"
|
||||
" :constraints (on|off) - turn on/off the constraint-"
|
||||
"based type checker"
|
||||
" :constraints debug (on|off) - turn on/off the debug "
|
||||
"output for the constraint-based type checker"
|
||||
" :dump_ir - dump the LLVM IR generated by the REPL\n"
|
||||
" :dump_ast - dump the AST representation of"
|
||||
" the REPL input\n"
|
||||
" :dump_source - dump the user input (ignoring"
|
||||
" lines with errors)\n"
|
||||
" :dump_constraints <expr> - dump the constraints for "
|
||||
" the given expression"
|
||||
"API documentation etc. will be here eventually.\n");
|
||||
} else if (L.peekNextToken().getText() == "quit" ||
|
||||
L.peekNextToken().getText() == "exit") {
|
||||
@@ -383,25 +382,33 @@ void swift::REPL(ASTContext &Context) {
|
||||
TU->dump();
|
||||
} else if (L.peekNextToken().getText() == "dump_source") {
|
||||
llvm::errs() << DumpSource;
|
||||
} else if (L.peekNextToken().getText() == "dump_constraints") {
|
||||
useConstraintSolver = true;
|
||||
debugConstraints = true;
|
||||
} else if (L.peekNextToken().getText() == "constraints") {
|
||||
L.lex(Tok);
|
||||
L.lex(Tok);
|
||||
if (Tok.getText() == "on") {
|
||||
TU->getASTContext().LangOpts.UseConstraintSolver = true;
|
||||
} else if (Tok.getText() == "off") {
|
||||
TU->getASTContext().LangOpts.UseConstraintSolver = false;
|
||||
} else if (Tok.getText() == "debug") {
|
||||
L.lex(Tok);
|
||||
if (Tok.getText() == "on") {
|
||||
TU->getASTContext().LangOpts.DebugConstraintSolver = true;
|
||||
} else if (Tok.getText() == "off") {
|
||||
TU->getASTContext().LangOpts.DebugConstraintSolver = false;
|
||||
} else {
|
||||
printf("%s", "Unknown :constraints debug command; try :help\n");
|
||||
}
|
||||
} else {
|
||||
printf("%s", "Unknown :constraints command; try :help\n");
|
||||
}
|
||||
} else {
|
||||
printf("%s", "Unknown interpreter escape; try :help\n");
|
||||
}
|
||||
|
||||
if (!useConstraintSolver) {
|
||||
CurBufferOffset = CurBufferEndOffset;
|
||||
CurChunkLines = 0;
|
||||
LastValidLineEnd = CurBuffer;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Continue parsing after the directive.
|
||||
L.lex(Tok);
|
||||
L.lex(Tok);
|
||||
CurBufferOffset = CurBufferOffset
|
||||
+ (Tok.getLoc().Value.getPointer() - Line);
|
||||
CurBufferOffset = CurBufferEndOffset;
|
||||
CurChunkLines = 0;
|
||||
LastValidLineEnd = CurBuffer;
|
||||
continue;
|
||||
}
|
||||
do {
|
||||
if (Tok.is(tok::l_brace) || Tok.is(tok::l_paren) ||
|
||||
@@ -421,17 +428,11 @@ void swift::REPL(ASTContext &Context) {
|
||||
continue;
|
||||
|
||||
// Parse the current line(s).
|
||||
llvm::SaveAndRestore<bool> setUseCS(
|
||||
TU->getASTContext().LangOpts.UseConstraintSolver,
|
||||
TU->getASTContext().LangOpts.UseConstraintSolver || useConstraintSolver);
|
||||
llvm::SaveAndRestore<bool> setDebugCS(
|
||||
TU->getASTContext().LangOpts.DebugConstraintSolver,
|
||||
TU->getASTContext().LangOpts.DebugConstraintSolver || debugConstraints);
|
||||
bool ShouldRun =
|
||||
swift::appendToMainTranslationUnit(TU, BufferID, CurTUElem,
|
||||
CurBufferOffset,
|
||||
CurBufferEndOffset);
|
||||
if (useConstraintSolver) {
|
||||
if (TU->getASTContext().LangOpts.UseConstraintSolver) {
|
||||
ShouldRun = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user