on master help sign in
commite021372c205e44dad0069a8cbccf3fcf8bb205de authoriko <mail@iko.soy> dateWed 13 Nov 2024, 16:26 (2 years ago) parenteebb78e
2 files changed+7−2
nock/src/interpreter.rs+3−1 nock/src/main.rs+4−1
nock/src/interpreter.rs+3−1
@@ -42,6 +42,7 @@ pub struct InterpreterContext {
4242 pub nouns: Nouns,
4343 pub big_uints: BigUints,
4444 pub memo: BTreeMap<Hash, Rc<Noun>>,
45+ pub slog: fn(&String) -> (),
4546}
4647
4748pub fn generate_interpreter_context() -> InterpreterContext {
@@ -83,6 +84,7 @@ pub fn generate_interpreter_context() -> InterpreterContext {
8384 },
8485 big_uints,
8586 memo: BTreeMap::new(),
87+ slog: |str: &String| eprintln!("{}", str),
8688 }
8789}
8890
@@ -300,7 +302,7 @@ fn tar_u32<'a>(
300302 let noun = tar(ctx, subj.clone(), &q)?;
301303 let (_prio, tank) = noun.as_cell().ok_or(TTanks::new())?;
302304
303− eprintln!("{}", ram(ctx, tank.clone()).unwrap_or(String::new()));
305+ (ctx.slog)(&ram(ctx, tank.clone()).unwrap_or(String::new()));
304306 eval(ctx)
305307 } else {
306308 eval(ctx)
nock/src/main.rs+4−1
@@ -67,7 +67,10 @@ enum RunCommand {
6767
6868fn main() -> Result<(), std::io::Error> {
6969 let urbit = LazyCell::new(GENERATE_URBIT);
70− let mut ctx = generate_interpreter_context();
70+ let mut ctx = InterpreterContext {
71+ slog: |_| {},
72+ ..generate_interpreter_context()
73+ };
7174
7275 let cli = Cli::parse();
7376