limit scope of raw mode on stdout to allow interrupts to work
This commit is contained in:
@@ -3180,6 +3180,7 @@ impl MachineState {
|
|||||||
let interrupted = INTERRUPT.load(std::sync::atomic::Ordering::Relaxed);
|
let interrupted = INTERRUPT.load(std::sync::atomic::Ordering::Relaxed);
|
||||||
|
|
||||||
if INTERRUPT.compare_and_swap(interrupted, false, std::sync::atomic::Ordering::Relaxed) {
|
if INTERRUPT.compare_and_swap(interrupted, false, std::sync::atomic::Ordering::Relaxed) {
|
||||||
|
self.reset();
|
||||||
self.fail = true;
|
self.fail = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -604,44 +604,42 @@ impl Machine {
|
|||||||
stdout().flush().unwrap();
|
stdout().flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut raw_stdout = stdout().into_raw_mode().unwrap();
|
|
||||||
|
|
||||||
if !attr_goals.is_empty() {
|
if !attr_goals.is_empty() {
|
||||||
if bindings.is_empty() {
|
if bindings.is_empty() {
|
||||||
write!(raw_stdout, "{}", attr_goals).unwrap();
|
print!("{}", attr_goals);
|
||||||
} else {
|
} else {
|
||||||
write!(raw_stdout, "{}, {}", bindings, attr_goals).unwrap();
|
print!("{}, {}", bindings, attr_goals);
|
||||||
}
|
}
|
||||||
} else if !bindings.is_empty() {
|
} else if !bindings.is_empty() {
|
||||||
write!(raw_stdout, "{}", bindings).unwrap();
|
print!("{}", bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.machine_st.b > 0 {
|
if self.machine_st.b > 0 {
|
||||||
raw_stdout.flush().unwrap();
|
let keypress = {
|
||||||
|
let mut raw_stdout = stdout().into_raw_mode().unwrap();
|
||||||
let result = match next_keypress() {
|
raw_stdout.flush().unwrap();
|
||||||
|
next_keypress()
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = match keypress {
|
||||||
ContinueResult::ContinueQuery => {
|
ContinueResult::ContinueQuery => {
|
||||||
write!(raw_stdout, " ;\r\n").unwrap();
|
print!(" ;\r\n");
|
||||||
self.continue_query(&alloc_locs)
|
self.continue_query(&alloc_locs)
|
||||||
}
|
}
|
||||||
ContinueResult::Conclude => {
|
ContinueResult::Conclude => {
|
||||||
write!(raw_stdout, " ...\r\n").unwrap();
|
print!(" ...\r\n");
|
||||||
self.machine_st.absorb_snapshot(snapshot);
|
self.machine_st.absorb_snapshot(snapshot);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut raw_stdout = stdout().into_raw_mode().unwrap();
|
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
EvalSession::QueryFailure => {
|
EvalSession::QueryFailure => {
|
||||||
if self.machine_st.ball.stub.len() > 0 {
|
if self.machine_st.ball.stub.len() > 0 {
|
||||||
self.propagate_exception_to_toplevel(snapshot);
|
self.propagate_exception_to_toplevel(snapshot);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
write!(raw_stdout, "false.\r\n").unwrap();
|
print!("false.\r\n");
|
||||||
raw_stdout.flush().unwrap();
|
|
||||||
|
|
||||||
self.machine_st.absorb_snapshot(snapshot);
|
self.machine_st.absorb_snapshot(snapshot);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -655,7 +653,7 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if bindings.is_empty() && attr_goals.is_empty() {
|
if bindings.is_empty() && attr_goals.is_empty() {
|
||||||
write!(raw_stdout, "true.\r\n").unwrap();
|
print!("true.\r\n");
|
||||||
} else {
|
} else {
|
||||||
let space = if !attr_goals.is_empty() {
|
let space = if !attr_goals.is_empty() {
|
||||||
if requires_space(&attr_goals, ".") {
|
if requires_space(&attr_goals, ".") {
|
||||||
@@ -671,7 +669,7 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
write!(raw_stdout, "{}.\r\n", space).unwrap();
|
print!("{}.\r\n", space);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -693,7 +691,7 @@ impl Machine {
|
|||||||
|
|
||||||
self.machine_st.absorb_snapshot(snapshot);
|
self.machine_st.absorb_snapshot(snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn run_query(&mut self, alloc_locs: &AllocVarDict) {
|
pub(super) fn run_query(&mut self, alloc_locs: &AllocVarDict) {
|
||||||
self.machine_st.cp = LocalCodePtr::TopLevel(0, self.code_repo.size_of_cached_query());
|
self.machine_st.cp = LocalCodePtr::TopLevel(0, self.code_repo.size_of_cached_query());
|
||||||
let end_ptr = CodePtr::Local(self.machine_st.cp);
|
let end_ptr = CodePtr::Local(self.machine_st.cp);
|
||||||
|
|||||||
Reference in New Issue
Block a user