on master help sign in
e021372iko
nock/src/interpreter.rs+3−1
@@ -42,6 +42,7 @@ pub struct InterpreterContext {
42 pub nouns: Nouns,
42 pub nouns: Nouns,
43 pub big_uints: BigUints,
43 pub big_uints: BigUints,
44 pub memo: BTreeMap<Hash, Rc<Noun>>,
44 pub memo: BTreeMap<Hash, Rc<Noun>>,
45+ pub slog: fn(&String) -> (),
45}
46}
46
47
47pub fn generate_interpreter_context() -> InterpreterContext {
48pub fn generate_interpreter_context() -> InterpreterContext {
@@ -83,6 +84,7 @@ pub fn generate_interpreter_context() -> InterpreterContext {
83 },
84 },
84 big_uints,
85 big_uints,
85 memo: BTreeMap::new(),
86 memo: BTreeMap::new(),
87+ slog: |str: &String| eprintln!("{}", str),
86 }
88 }
87}
89}
88
90
@@ -300,7 +302,7 @@ fn tar_u32<'a>(
300 let noun = tar(ctx, subj.clone(), &q)?;
302 let noun = tar(ctx, subj.clone(), &q)?;
301 let (_prio, tank) = noun.as_cell().ok_or(TTanks::new())?;
303 let (_prio, tank) = noun.as_cell().ok_or(TTanks::new())?;
302
304
303− eprintln!("{}", ram(ctx, tank.clone()).unwrap_or(String::new()));
305+ (ctx.slog)(&ram(ctx, tank.clone()).unwrap_or(String::new()));
304 eval(ctx)
306 eval(ctx)
305 } else {
307 } else {
306 eval(ctx)
308 eval(ctx)
nock/src/main.rs+4−1
@@ -67,7 +67,10 @@ enum RunCommand {
67
67
68fn main() -> Result<(), std::io::Error> {
68fn main() -> Result<(), std::io::Error> {
69 let urbit = LazyCell::new(GENERATE_URBIT);
69 let urbit = LazyCell::new(GENERATE_URBIT);
70+ let mut ctx = InterpreterContext {
71+ slog: |_| {},
70− let mut ctx = generate_interpreter_context();
72+ ..generate_interpreter_context()
73+ };
71
74
72 let cli = Cli::parse();
75 let cli = Cli::parse();
73
76