From 6ac9b164ed9922cfb35a26fc7df304258d5d562e Mon Sep 17 00:00:00 2001 From: Edward Amsden Date: Fri, 23 Aug 2024 20:35:46 -0500 Subject: [PATCH] interpret: add %dont hint to bail-fail, for catching jet misses --- rust/sword/Cargo.toml | 1 + rust/sword/src/interpreter.rs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/rust/sword/Cargo.toml b/rust/sword/Cargo.toml index 958bfba..6dc4294 100644 --- a/rust/sword/Cargo.toml +++ b/rust/sword/Cargo.toml @@ -51,3 +51,4 @@ check_forwarding = [] check_junior = [] sham_hints = [] stop_for_debug = [] +hint_dont = [] diff --git a/rust/sword/src/interpreter.rs b/rust/sword/src/interpreter.rs index daf7b80..f2b22e9 100644 --- a/rust/sword/src/interpreter.rs +++ b/rust/sword/src/interpreter.rs @@ -1500,6 +1500,13 @@ mod hint { ) -> Option { // XX: handle IndirectAtom tags match tag.direct()?.data() { + tas!(b"dont") => { + if cfg!(feature = "hint_dont") { + Some(Err(Error::NonDeterministic(Mote::Fail, D(0)))) + } else { + None + } + }, tas!(b"slog") => { let stack = &mut context.stack; let slogger = &mut context.slogger; @@ -1511,6 +1518,7 @@ mod hint { let s = (*slogger).deref_mut(); s.slog(stack, pri, tank); + None } tas!(b"hand") | tas!(b"hunk") | tas!(b"lose") | tas!(b"mean") | tas!(b"spot") => { let terminator = Arc::clone(&TERMINATOR); @@ -1522,6 +1530,7 @@ mod hint { let (_form, clue) = hint?; let noun = T(stack, &[tag.as_noun(), clue]); mean_push(stack, noun); + None } tas!(b"hela") => { // XX: This only prints the trace down to the bottom of THIS @@ -1560,6 +1569,7 @@ mod hint { break; } } + None } Err(_) => { // +mook should only ever bail if the input is not [%2 (list)]. Since we control the input @@ -1568,10 +1578,8 @@ mod hint { } } } - _ => {} - }; - - None + _ => { None } + } } /** Match static and dynamic hints after the nock formula is evaluated */