bb_b_put(Key, NewValue) :-
( '$bb_get_with_offset'(Key, OldValue, OldOffset) ->
call_cleanup((store_global_var_with_offset(Key, NewValue) ; false),
- reset_global_var_at_offset(Key, OldValue, OldOffset))
+ reset_global_var_at_offset(Key, OldValue, OldOffset))
; call_cleanup((store_global_var_with_offset(Key, NewValue) ; false),
- reset_global_var_at_key(Key))
+ reset_global_var_at_key(Key))
).
store_global_var_with_offset(Key, Value) :- '$store_global_var_with_offset'(Key, Value).
)
}
+ #[inline]
+ pub(super)
+ fn interrupt_error() -> Self {
+ let stub = functor!("$interrupt_thrown");
+
+ MachineError {
+ stub,
+ location: None,
+ from: ErrorProvenance::Received,
+ }
+ }
+
pub(super)
fn evaluation_error(eval_error: EvalError) -> Self {
let stub = functor!("evaluation_error", [atom(eval_error.as_str())]);
self.p += 1;
}
+ fn throw_interrupt_exception(&mut self) {
+ let err = MachineError::interrupt_error();
+ let src = functor!("repl");
+ let err = self.error_form(err, src);
+
+ self.throw_exception(err);
+ }
+
fn handle_call_clause(
&mut self,
indices: &mut IndexStore,
let interrupted = INTERRUPT.load(std::sync::atomic::Ordering::Relaxed);
if INTERRUPT.compare_and_swap(interrupted, false, std::sync::atomic::Ordering::Relaxed) {
- self.reset();
- self.fail = true;
+ self.throw_interrupt_exception();
return;
}
).
print_exception(E) :-
+ ( E == error('$interrupt_thrown', repl) -> nl % print the exception on a newline to evade "^C".
+ ; true
+ ),
write_term('caught: ', [quoted(false), max_depth(20)]),
writeq(E),
nl.