on master help sign in
commitef80ea93de0cef48109b57e6a11c448692aa89e3 authoriko <mail@iko.soy> dateMon 11 Nov 2024, 23:27 (2 years ago) parent5513ecc
6 files changed+308−213
nock/hello.hoon+2−1 nock/hello.nock nock/src/interpreter.rs+164−34 nock/src/jets.rs+134−128 nock/src/lib.rs+1−34 nock/src/main.rs+7−16
nock/hello.hoon+2−1
@@ -1,5 +1,6 @@
11|= name=@t
2+~& name
23?+ name (crip (weld "Hello, " (trip name)))
34 'Curtis' 'Hello, daddy...'
4− '' 'Hello, world!'
5+ %'' 'Hello, world!'
56==
nock/hello.nock

Binary file not shown.

nock/src/interpreter.rs+164−34
@@ -1,6 +1,9 @@
1+use core::str;
12use std::borrow::Borrow;
3+use std::borrow::BorrowMut;
24use std::collections::BTreeMap;
35use std::rc::Rc;
6+use std::str::Utf8Error;
47
58use fplist::cons;
69use fplist::PersistentList;
@@ -22,6 +25,7 @@ pub struct Nouns {
2225 pub two_three: Rc<Noun>,
2326 pub memo: Rc<Noun>,
2427 pub mean: Rc<Noun>,
28+ pub slog: Rc<Noun>,
2529}
2630
2731#[derive(Clone)]
@@ -61,6 +65,7 @@ pub fn generate_interpreter_context() -> InterpreterContext {
6165 let two_three = cell(&two, &three);
6266 let memo = Rc::new(Noun::from_bytes(b"memo"));
6367 let mean = Rc::new(Noun::from_bytes(b"mean"));
68+ let slog = Rc::new(Noun::from_bytes(b"slog"));
6469 InterpreterContext {
6570 jets,
6671 double_jets,
@@ -76,6 +81,7 @@ pub fn generate_interpreter_context() -> InterpreterContext {
7681 two_three,
7782 memo,
7883 mean,
84+ slog,
7985 },
8086 big_uints,
8187 memo: BTreeMap::new(),
@@ -89,7 +95,7 @@ fn wut<'a>(ctx: &'a InterpreterContext, noun: &Noun) -> &'a Rc<Noun> {
8995 }
9096}
9197
92−fn lus(noun: &Noun) -> Result<Noun, Tanks> {
98+fn lus(noun: &Noun) -> Result<Noun, TTanks> {
9399 match noun {
94100 Noun::Cell { .. } => Err(PersistentList::new()),
95101 Noun::Atom(atm) => Ok(Noun::Atom(atm + 1u32)),
@@ -104,7 +110,7 @@ fn tis<'a>(ctx: &'a InterpreterContext, lhs: &Noun, rhs: &Noun) -> &'a Rc<Noun>
104110 }
105111}
106112
107−fn fas(ctx: &InterpreterContext, addr: &Atom, noun: &Noun) -> Result<Rc<Noun>, Tanks> {
113+fn fas(ctx: &InterpreterContext, addr: &Atom, noun: &Noun) -> Result<Rc<Noun>, TTanks> {
108114 let mut addr_iter = addr.iter_u32_digits();
109115
110116 match (addr_iter.next(), addr_iter.next()) {
@@ -124,7 +130,7 @@ fn fas(ctx: &InterpreterContext, addr: &Atom, noun: &Noun) -> Result<Rc<Noun>, T
124130 }
125131}
126132
127−fn fas_u32(addr: u32, noun: &Noun) -> Result<Rc<Noun>, Tanks> {
133+fn fas_u32(addr: u32, noun: &Noun) -> Result<Rc<Noun>, TTanks> {
128134 match addr {
129135 0 => Err(PersistentList::new()),
130136 1 => Ok(Rc::new(noun.clone())),
@@ -142,7 +148,7 @@ fn fas_u32(addr: u32, noun: &Noun) -> Result<Rc<Noun>, Tanks> {
142148 }
143149}
144150
145−fn hax_u32(addr: u32, new_value: &Rc<Noun>, target: &Rc<Noun>) -> Result<Rc<Noun>, Tanks> {
151+fn hax_u32(addr: u32, new_value: &Rc<Noun>, target: &Rc<Noun>) -> Result<Rc<Noun>, TTanks> {
146152 match addr {
147153 0 => Err(PersistentList::new()),
148154 1 => Ok(new_value.clone()),
@@ -164,11 +170,11 @@ fn hax(
164170 addr: &Atom,
165171 new_value: &Rc<Noun>,
166172 target: &Rc<Noun>,
167−) -> Result<Rc<Noun>, Tanks> {
173+) -> Result<Rc<Noun>, TTanks> {
168174 let mut addr_iter = addr.iter_u32_digits();
169175
170176 match (addr_iter.next(), addr_iter.next()) {
171− (None, _) => Err(Tanks::new()),
177+ (None, _) => Err(TTanks::new()),
172178 (Some(x), None) => hax_u32(x, new_value, target),
173179 _ => hax(
174180 ctx,
@@ -190,15 +196,15 @@ fn tar_u32<'a>(
190196 subj: Rc<Noun>,
191197 op: u32,
192198 formula: &'a Rc<Noun>,
193−) -> Result<Rc<Noun>, Tanks> {
199+) -> Result<Rc<Noun>, TTanks> {
194200 match op {
195201 0 => {
196− let b = formula.as_atom().ok_or(Tanks::new())?;
202+ let b = formula.as_atom().ok_or(TTanks::new())?;
197203 fas(ctx, b, &*subj)
198204 }
199205 1 => Ok(formula.clone()),
200206 2 => {
201− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
207+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
202208
203209 match c.borrow() {
204210 Noun::Cell { p, q, .. }
@@ -229,14 +235,14 @@ fn tar_u32<'a>(
229235 }
230236 4 => Ok(Rc::new(lus(&*tar(ctx, subj, &formula)?)?)),
231237 5 => {
232− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
238+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
233239 let foo = tar(ctx, subj.clone(), &b)?;
234240 let bar = tar(ctx, subj, &c)?;
235241 Ok(tis(ctx, &foo, &bar).clone())
236242 }
237243 6 => {
238− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
239− let (c, d) = c.as_cell().ok_or(Tanks::new())?;
244+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
245+ let (c, d) = c.as_cell().ok_or(TTanks::new())?;
240246
241247 let bar = tar_u32(ctx, subj.clone(), 4, &cell(&ctx.nouns.four.clone(), &b))?;
242248
@@ -246,17 +252,17 @@ fn tar_u32<'a>(
246252 tar(ctx, subj, &foo)
247253 }
248254 7 => {
249− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
255+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
250256 let foo = tar(ctx, subj, &b)?;
251257 tar(ctx, foo, &c)
252258 }
253259 8 => {
254− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
260+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
255261 let foo = tar(ctx, subj.clone(), &b)?;
256262 tar(ctx, cell(&foo, &subj), &c)
257263 }
258264 9 => {
259− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
265+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
260266 let foo = tar(ctx, subj, &c)?;
261267 tar_u32(
262268 ctx,
@@ -266,16 +272,16 @@ fn tar_u32<'a>(
266272 )
267273 }
268274 10 => {
269− let (b, d) = formula.as_cell().ok_or(Tanks::new())?;
270− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
271− let b = b.as_atom().ok_or(Tanks::new())?;
275+ let (b, d) = formula.as_cell().ok_or(TTanks::new())?;
276+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
277+ let b = b.as_atom().ok_or(TTanks::new())?;
272278
273279 let foo = tar(ctx, subj.clone(), &c)?;
274280 let bar = tar(ctx, subj, &d)?;
275281 hax(ctx, b, &foo, &bar)
276282 }
277283 11 => {
278− let (b, d) = formula.as_cell().ok_or(Tanks::new())?;
284+ let (b, d) = formula.as_cell().ok_or(TTanks::new())?;
279285 match b.borrow() {
280286 Noun::Atom(_) => tar(ctx, subj, &d),
281287 Noun::Cell { p, q, .. } => {
@@ -292,34 +298,155 @@ fn tar_u32<'a>(
292298 }
293299 } else if *p == ctx.nouns.mean {
294300 with_trace((subj.clone(), q.clone()), eval(ctx))
301+ } else if *p == ctx.nouns.slog {
302+ let noun = tar(ctx, subj.clone(), &q)?;
303+ let (_prio, tank) = noun.as_cell().ok_or(TTanks::new())?;
304+
305+ eprintln!("{}", ram(ctx, tank.clone()).unwrap_or(String::new()));
306+ eval(ctx)
295307 } else {
296308 eval(ctx)
297309 }
298310 }
299311 }
300312 }
301− _ => Err(Tanks::new()),
313+ _ => Err(TTanks::new()),
302314 }
303315}
304316
305−fn with_trace<T>(tank: (Rc<Noun>, Rc<Noun>), src: Result<T, Tanks>) -> Result<T, Tanks> {
317+fn ram(ctx: &mut InterpreterContext, tank: Rc<Noun>) -> Option<String> {
318+ match tank.borrow() {
319+ Noun::Atom(str) => {
320+ let mut bytes = str.to_bytes_le();
321+ Some(String::from(str::from_utf8_mut(&mut bytes).ok()?))
322+ }
323+ Noun::Cell { p, q, .. } => {
324+ let tag = p.as_atom()?.to_bytes_le();
325+ if tag == b"leaf" {
326+ let mut bytes = crip(ctx, q.clone()).ok()?.as_atom()?.to_bytes_le();
327+ Some(String::from(str::from_utf8_mut(&mut bytes).ok()?))
328+ } else if tag == b"palm" {
329+ let (mid, foo) = q.as_cell()?;
330+ let (open, foo) = foo.as_cell()?;
331+ let (flat_open, foo) = foo.as_cell()?;
332+ let (close, tanks) = foo.as_cell()?;
333+
334+ let mut mid = mid.as_bytes()?;
335+ let mid = String::from(str::from_utf8_mut(&mut mid).ok()?);
336+
337+ let mut open = open.as_bytes()?;
338+ let open = String::from(str::from_utf8_mut(&mut open).ok()?);
339+
340+ let mut flat_open = flat_open.as_bytes()?;
341+ let flat_open = String::from(str::from_utf8_mut(&mut flat_open).ok()?);
342+
343+ let mut close = close.as_bytes()?;
344+ let close = String::from(str::from_utf8_mut(&mut close).ok()?);
345+
346+ let mut target = String::new();
347+
348+ target.push_str(&*open);
349+ target.push_str(&*flat_open);
350+
351+ let mut is_first = true;
352+ for tank in tanks.list_iter() {
353+ if !is_first {
354+ target.push_str(&*mid);
355+ }
356+
357+ target.push_str(&*(ram(ctx, tank.clone())?));
358+
359+ is_first = false;
360+ }
361+
362+ target.push_str(&*close);
363+
364+ Some(target)
365+ } else if tag == b"rose" {
366+ let (mid, foo) = q.as_cell()?;
367+ let (open, foo) = foo.as_cell()?;
368+ let (close, tanks) = foo.as_cell()?;
369+
370+ let mut mid = mid.as_bytes()?;
371+ let mid = String::from(str::from_utf8_mut(&mut mid).ok()?);
372+
373+ let mut open = open.as_bytes()?;
374+ let open = String::from(str::from_utf8_mut(&mut open).ok()?);
375+
376+ let mut close = close.as_bytes()?;
377+ let close = String::from(str::from_utf8_mut(&mut close).ok()?);
378+
379+ let mut target = String::new();
380+
381+ target.push_str(&*open);
382+
383+ let mut is_first = true;
384+ for tank in tanks.list_iter() {
385+ if !is_first {
386+ target.push_str(&*mid);
387+ }
388+
389+ target.push_str(&*(ram(ctx, tank.clone())?));
390+
391+ is_first = false;
392+ }
393+
394+ target.push_str(&*close);
395+
396+ Some(target)
397+ } else {
398+ None
399+ }
400+ }
401+ }
402+}
403+
404+pub fn ram_ttanks(ctx: &mut InterpreterContext, tanks: TTanks) -> String {
405+ let mut target = String::new();
406+
407+ for tank in tanks.iter() {
408+ target.push_str(&*ram_ttank(ctx, tank.clone()));
409+ }
410+
411+ target
412+}
413+
414+pub fn ram_ttank(ctx: &mut InterpreterContext, ttank: TTank) -> String {
415+ let (subj, q) = ttank;
416+
417+ let tank = match tar(ctx, subj.clone(), &q) {
418+ Ok(gate) => match eval_pulled_gate(ctx, gate) {
419+ Ok(tank) => tank,
420+ Err(_) => return String::new(),
421+ },
422+ Err(_) => return String::new(),
423+ };
424+ ram(ctx, tank).unwrap_or(String::new())
425+}
426+
427+fn crip(ctx: &mut InterpreterContext, tape: Rc<Noun>) -> Result<Rc<Noun>, TTanks> {
428+ RAP(ctx, &cell(&Rc::new(Noun::from_u32(3)), &tape))
429+}
430+
431+fn with_trace<T>(tank: (Rc<Noun>, Rc<Noun>), src: Result<T, TTanks>) -> Result<T, TTanks> {
306432 match src {
307433 Ok(a) => Ok(a),
308434 Err(tanks) => Err(cons(tank, tanks)),
309435 }
310436}
311437
312−pub type Tank = Rc<Noun>;
313−pub type Tanks = PersistentList<(Rc<Noun>, Rc<Noun>)>;
438+/// Not actually a tank, but rather a thunk (subject, formula) which calculates the tank.
439+pub type TTank = (Rc<Noun>, Rc<Noun>);
440+pub type TTanks = PersistentList<TTank>;
314441
315−pub const EMPTY_TANKS: Tanks = Tanks::new();
442+pub const EMPTY_TANKS: TTanks = TTanks::new();
316443
317444pub fn tar<'a>(
318445 ctx: &mut InterpreterContext,
319446 subj: Rc<Noun>,
320447 formula: &'a Noun,
321−) -> Result<Rc<Noun>, Tanks> {
322− let (op, formula) = formula.as_cell().ok_or(Tanks::new())?;
448+) -> Result<Rc<Noun>, TTanks> {
449+ let (op, formula) = formula.as_cell().ok_or(TTanks::new())?;
323450 match op.borrow() {
324451 Noun::Cell { .. } => {
325452 let foo = tar(ctx, subj.clone(), &op)?;
@@ -333,13 +460,16 @@ pub fn tar<'a>(
333460 1 => Some(op_iter.next().unwrap()),
334461 _ => None,
335462 };
336− let op = op.ok_or(Tanks::new())?;
463+ let op = op.ok_or(TTanks::new())?;
337464 stacker::maybe_grow(32 * 1024, 1024 * 1024, || tar_u32(ctx, subj, op, formula))
338465 }
339466 }
340467}
341468
342−pub fn eval_gate(ctx: &mut InterpreterContext, gate_factory: &Rc<Noun>) -> Result<Rc<Noun>, Tanks> {
469+pub fn eval_gate(
470+ ctx: &mut InterpreterContext,
471+ gate_factory: &Rc<Noun>,
472+) -> Result<Rc<Noun>, TTanks> {
343473 let pulled_gate = tar(ctx, ctx.nouns.sig.clone(), &gate_factory)?;
344474 eval_pulled_gate(ctx, pulled_gate)
345475}
@@ -348,7 +478,7 @@ pub fn slam(
348478 ctx: &mut InterpreterContext,
349479 gate_factory: &Rc<Noun>,
350480 sample: &Rc<Noun>,
351−) -> Result<Rc<Noun>, Tanks> {
481+) -> Result<Rc<Noun>, TTanks> {
352482 let gate = tar(ctx, ctx.nouns.sig.clone(), &gate_factory)?;
353483
354484 eval_pulled_gate(ctx, replace_sample(&gate, sample)?)
@@ -356,7 +486,7 @@ pub fn slam(
356486
357487/// This is useful for evaluaing gates produced by running `.foo/nock gate-name` in the dojo.
358488/// Also for calling gates from within jets.
359−pub fn eval_pulled_gate(ctx: &mut InterpreterContext, gate: Rc<Noun>) -> Result<Rc<Noun>, Tanks> {
489+pub fn eval_pulled_gate(ctx: &mut InterpreterContext, gate: Rc<Noun>) -> Result<Rc<Noun>, TTanks> {
360490 tar(
361491 ctx,
362492 gate,
@@ -373,13 +503,13 @@ pub fn slam_pulled_gate(
373503 ctx: &mut InterpreterContext,
374504 gate: &Rc<Noun>,
375505 sample: &Rc<Noun>,
376−) -> Result<Rc<Noun>, Tanks> {
506+) -> Result<Rc<Noun>, TTanks> {
377507 eval_pulled_gate(ctx, replace_sample(gate, sample)?)
378508}
379509
380−pub fn replace_sample(gate: &Rc<Noun>, sample: &Rc<Noun>) -> Result<Rc<Noun>, Tanks> {
381− let (battery, payload) = gate.as_cell().ok_or(Tanks::new())?;
382− let (_sample, context) = payload.as_cell().ok_or(Tanks::new())?;
510+pub fn replace_sample(gate: &Rc<Noun>, sample: &Rc<Noun>) -> Result<Rc<Noun>, TTanks> {
511+ let (battery, payload) = gate.as_cell().ok_or(TTanks::new())?;
512+ let (_sample, context) = payload.as_cell().ok_or(TTanks::new())?;
383513
384514 Ok(cell(battery, &cell(sample, context)))
385515}
nock/src/jets.rs+134−128
@@ -8,7 +8,7 @@ use std::{
88};
99
1010use crate::{
11− interpreter::{slam_pulled_gate, InterpreterContext, Tanks},
11+ interpreter::{slam_pulled_gate, InterpreterContext, TTanks},
1212 noun::{self, cell, Atom, Edge, Hair, Nail, Noun},
1313};
1414
@@ -110,15 +110,15 @@ pub fn generate_jets() -> Jets {
110110 ])
111111}
112112
113−pub type Jet = fn(ctx: &mut InterpreterContext, &Rc<Noun>) -> Result<Rc<Noun>, Tanks>;
113+pub type Jet = fn(ctx: &mut InterpreterContext, &Rc<Noun>) -> Result<Rc<Noun>, TTanks>;
114114pub type DoubleJet = fn(ctx: &mut InterpreterContext, &Rc<Noun>, &Rc<Noun>) -> Option<Rc<Noun>>;
115115
116−static BINARY_ATOM: fn(&Rc<Noun>, fn(&Atom, &Atom) -> Atom) -> Result<Rc<Noun>, Tanks> =
116+static BINARY_ATOM: fn(&Rc<Noun>, fn(&Atom, &Atom) -> Atom) -> Result<Rc<Noun>, TTanks> =
117117 |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> Atom| {
118− let (p, q) = n.as_cell().ok_or(Tanks::new())?;
118+ let (p, q) = n.as_cell().ok_or(TTanks::new())?;
119119 Ok(Rc::new(Noun::Atom(f(
120− p.as_atom().ok_or(Tanks::new())?,
121− q.as_atom().ok_or(Tanks::new())?,
120+ p.as_atom().ok_or(TTanks::new())?,
121+ q.as_atom().ok_or(TTanks::new())?,
122122 ))))
123123 };
124124
@@ -126,13 +126,13 @@ static BINARY_ATOM_LOOB: fn(
126126 &InterpreterContext,
127127 &Rc<Noun>,
128128 fn(&Atom, &Atom) -> bool,
129−) -> Result<Rc<Noun>, Tanks> =
129+) -> Result<Rc<Noun>, TTanks> =
130130 |ctx: &InterpreterContext, n: &Rc<Noun>, f: fn(&Atom, &Atom) -> bool| {
131− let (p, q) = n.as_cell().ok_or(Tanks::new())?;
131+ let (p, q) = n.as_cell().ok_or(TTanks::new())?;
132132
133133 if f(
134− p.as_atom().ok_or(Tanks::new())?,
135− q.as_atom().ok_or(Tanks::new())?,
134+ p.as_atom().ok_or(TTanks::new())?,
135+ q.as_atom().ok_or(TTanks::new())?,
136136 ) {
137137 Ok(ctx.nouns.sig.clone())
138138 } else {
@@ -143,18 +143,22 @@ static BINARY_ATOM_LOOB: fn(
143143static BINARY_ATOM_PAIR: fn(
144144 &Rc<Noun>,
145145 fn(&Atom, &Atom) -> (Atom, Atom),
146−) -> Result<Rc<Noun>, Tanks> = |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
147− let (p, q) = n.as_cell().ok_or(Tanks::new())?;
146+) -> Result<Rc<Noun>, TTanks> = |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
147+ let (p, q) = n.as_cell().ok_or(TTanks::new())?;
148148
149149 let (a, b) = f(
150− p.as_atom().ok_or(Tanks::new())?,
151− q.as_atom().ok_or(Tanks::new())?,
150+ p.as_atom().ok_or(TTanks::new())?,
151+ q.as_atom().ok_or(TTanks::new())?,
152152 );
153153 Ok(cell(&Rc::new(Noun::Atom(a)), &Rc::new(Noun::Atom(b))))
154154};
155155
156156static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
157−static DEC: Jet = |_ctx, n| Ok(Rc::new(Noun::Atom(n.as_atom().ok_or(Tanks::new())? - 1u32)));
157+static DEC: Jet = |_ctx, n| {
158+ Ok(Rc::new(Noun::Atom(
159+ n.as_atom().ok_or(TTanks::new())? - 1u32,
160+ )))
161+};
158162static DVR: Jet = |_ctx, n| BINARY_ATOM_PAIR(n, |a, b| a.div_rem(&b));
159163static DIV: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a / b);
160164static GTE: Jet = |ctx, n| BINARY_ATOM_LOOB(ctx, n, |a, b| a >= b);
@@ -168,30 +172,30 @@ static MUL: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a * b);
168172static SUB: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a - b);
169173
170174static CAP: Jet = |ctx, n| {
171− let n = n.as_atom().ok_or(Tanks::new())?;
175+ let n = n.as_atom().ok_or(TTanks::new())?;
172176 CAP_ATOM(ctx, n.clone())
173177};
174178
175−static CAP_ATOM: fn(&InterpreterContext, Atom) -> Result<Rc<Noun>, Tanks> = |ctx, n: Atom| {
179+static CAP_ATOM: fn(&InterpreterContext, Atom) -> Result<Rc<Noun>, TTanks> = |ctx, n: Atom| {
176180 let mut n_iter = n.iter_u32_digits();
177181
178182 match n_iter.len() {
179− 0 => Err(Tanks::new()),
183+ 0 => Err(TTanks::new()),
180184 1 => CAP_U32(ctx, n_iter.next().unwrap()),
181185 _ => CAP_ATOM(ctx, n >> 1),
182186 }
183187};
184−static CAP_U32: fn(ctx: &InterpreterContext, u32) -> Result<Rc<Noun>, Tanks> = |ctx, n| match n {
185− 0 | 1 => Err(Tanks::new()),
188+static CAP_U32: fn(ctx: &InterpreterContext, u32) -> Result<Rc<Noun>, TTanks> = |ctx, n| match n {
189+ 0 | 1 => Err(TTanks::new()),
186190 2 => Ok(ctx.nouns.two.clone()),
187191 3 => Ok(ctx.nouns.three.clone()),
188192 n => CAP_U32(ctx, n >> 1),
189193};
190194
191195static MAS: Jet = |ctx, n| {
192− let n = n.as_atom().ok_or(Tanks::new())?;
196+ let n = n.as_atom().ok_or(TTanks::new())?;
193197 Ok(Rc::new(Noun::Atom(
194− MAS_ATOM(ctx, n.clone()).ok_or(Tanks::new())?,
198+ MAS_ATOM(ctx, n.clone()).ok_or(TTanks::new())?,
195199 )))
196200};
197201static MAS_ATOM: fn(&InterpreterContext, Atom) -> Option<Atom> = |ctx, n| {
@@ -213,22 +217,22 @@ static MAS_U32: fn(u32) -> u32 = |n| match n {
213217};
214218
215219static PEG: Jet = |ctx, n| {
216− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
220+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
217221
218− let a = a.as_atom().ok_or(Tanks::new())?;
219− let b = b.as_atom().ok_or(Tanks::new())?;
222+ let a = a.as_atom().ok_or(TTanks::new())?;
223+ let b = b.as_atom().ok_or(TTanks::new())?;
220224
221225 if *a == Atom::ZERO {
222− return Err(Tanks::new());
226+ return Err(TTanks::new());
223227 };
224228
225229 Ok(Rc::new(Noun::Atom(PEG_ATOM(ctx, a, b.clone())?)))
226230};
227−static PEG_ATOM: fn(&InterpreterContext, &Atom, Atom) -> Result<Atom, Tanks> = |ctx, a, b| {
231+static PEG_ATOM: fn(&InterpreterContext, &Atom, Atom) -> Result<Atom, TTanks> = |ctx, a, b| {
228232 let mut b_iter = b.iter_u32_digits();
229233
230234 match b_iter.len() {
231− 0 => Err(Tanks::new()),
235+ 0 => Err(TTanks::new()),
232236 1 => Ok(PEG_U32(a, b_iter.next().unwrap())),
233237 _ => Ok((&b & &ctx.big_uints.one) + (PEG_ATOM(ctx, a, b >> 1)? << 1)),
234238 }
@@ -242,7 +246,7 @@ static PEG_U32: fn(&Atom, u32) -> Atom = |a, b| match b {
242246};
243247
244248static FAND: Jet = |ctx, n| {
245− let (nedl, hstk) = n.as_cell().ok_or(Tanks::new())?;
249+ let (nedl, hstk) = n.as_cell().ok_or(TTanks::new())?;
246250 if nedl.is_sig() || hstk.is_sig() {
247251 return Ok(ctx.nouns.sig.clone());
248252 }
@@ -272,7 +276,7 @@ static FAND: Jet = |ctx, n| {
272276};
273277
274278static FIND: Jet = |ctx, n| {
275− let (nedl, hstk) = n.as_cell().ok_or(Tanks::new())?;
279+ let (nedl, hstk) = n.as_cell().ok_or(TTanks::new())?;
276280 if nedl.is_sig() || hstk.is_sig() {
277281 return Ok(ctx.nouns.sig.clone());
278282 }
@@ -305,13 +309,13 @@ static FLOP: Jet = |ctx, n| {
305309};
306310
307311static GULF: Jet = |_ctx, n| {
308− let (from, to) = n.as_cell().ok_or(Tanks::new())?;
312+ let (from, to) = n.as_cell().ok_or(TTanks::new())?;
309313
310− let mut from = (*from.as_atom().ok_or(Tanks::new())?).clone();
311− let to = to.as_atom().ok_or(Tanks::new())?.clone();
314+ let mut from = (*from.as_atom().ok_or(TTanks::new())?).clone();
315+ let to = to.as_atom().ok_or(TTanks::new())?.clone();
312316
313317 if from > to {
314− return Err(Tanks::new());
318+ return Err(TTanks::new());
315319 }
316320
317321 let mut tmp = Vec::new();
@@ -325,10 +329,10 @@ static GULF: Jet = |_ctx, n| {
325329};
326330
327331static INTO: Jet = |_ctx, n| {
328− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
329− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
332+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
333+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
330334
331− let mut b_iter = b.as_atom().ok_or(Tanks::new())?.iter_u32_digits();
335+ let mut b_iter = b.as_atom().ok_or(TTanks::new())?.iter_u32_digits();
332336
333337 match b_iter.len() {
334338 0 => Ok(cell(&c, &a)),
@@ -358,7 +362,7 @@ static INTO: Jet = |_ctx, n| {
358362};
359363
360364static JOIN: Jet = |_ctx, n| {
361− let (sep, list) = n.as_cell().ok_or(Tanks::new())?;
365+ let (sep, list) = n.as_cell().ok_or(TTanks::new())?;
362366 Ok(Noun::list_refs(
363367 list.list_iter()
364368 .intersperse(sep)
@@ -376,7 +380,7 @@ static LENT: Jet = |_ctx, n| {
376380};
377381
378382static LEVY: Jet = |ctx, n| {
379− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
383+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
380384 if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
381385 .iter()
382386 .all(|x| x.is_y())
@@ -388,7 +392,7 @@ static LEVY: Jet = |ctx, n| {
388392};
389393
390394static LIEN: Jet = |ctx, n| {
391− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
395+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
392396 if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
393397 .iter()
394398 .any(|x| x.is_y())
@@ -400,7 +404,7 @@ static LIEN: Jet = |ctx, n| {
400404};
401405
402406static MURN: Jet = |ctx, n| {
403− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
407+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
404408
405409 Ok(Noun::list_refs(
406410 traverse_iter_result(
@@ -413,7 +417,7 @@ static MURN: Jet = |ctx, n| {
413417};
414418
415419static REAP: Jet = |_ctx, n| {
416− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
420+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
417421
418422 Ok(Noun::list_refs(repeat_n(
419423 b.clone(),
@@ -421,17 +425,17 @@ static REAP: Jet = |_ctx, n| {
421425 )))
422426};
423427
424−static REAR: Jet = |_ctx, n| n.list_iter().last().ok_or(Tanks::new()).cloned();
428+static REAR: Jet = |_ctx, n| n.list_iter().last().ok_or(TTanks::new()).cloned();
425429
426430static REEL: Jet = |ctx, n| {
427− let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
431+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
428432
429433 list.list_iter().collect::<Vec<_>>().iter().rfold(
430434 Ok(gate
431435 .gate_sample()
432− .ok_or(Tanks::new())?
436+ .ok_or(TTanks::new())?
433437 .as_cell()
434− .ok_or(Tanks::new())?
438+ .ok_or(TTanks::new())?
435439 .1
436440 .clone()),
437441 |acc, next| {
@@ -442,15 +446,15 @@ static REEL: Jet = |ctx, n| {
442446};
443447
444448static ROLL: Jet = |ctx, n| {
445− let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
449+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
446450
447451 list.list_iter().fold(
448452 Ok(gate
449453 .clone()
450454 .gate_sample()
451− .ok_or(Tanks::new())?
455+ .ok_or(TTanks::new())?
452456 .as_cell()
453− .ok_or(Tanks::new())?
457+ .ok_or(TTanks::new())?
454458 .1
455459 .clone()),
456460 |acc, next| {
@@ -461,7 +465,7 @@ static ROLL: Jet = |ctx, n| {
461465};
462466
463467static SCAG: Jet = |_ctx, n| {
464− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
468+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
465469
466470 Ok(Noun::list_refs(
467471 b.list_iter()
@@ -474,7 +478,7 @@ static SCAG: Jet = |_ctx, n| {
474478};
475479
476480static SKID: Jet = |ctx, n| {
477− let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
481+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
478482
479483 let slammed_n = traverse_iter_result(
480484 list.list_iter()
@@ -489,7 +493,7 @@ static SKID: Jet = |ctx, n| {
489493};
490494
491495static SKIM: Jet = |ctx, n| {
492− let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
496+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
493497
494498 Ok(Noun::list_refs(
495499 traverse_iter_result(
@@ -503,7 +507,7 @@ static SKIM: Jet = |ctx, n| {
503507};
504508
505509static SKIP: Jet = |ctx, n| {
506− let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
510+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
507511
508512 Ok(Noun::list_refs(
509513 traverse_iter_result(
@@ -517,9 +521,9 @@ static SKIP: Jet = |ctx, n| {
517521};
518522
519523static SLAG: Jet = |ctx, n| {
520− let (a, list) = n.as_cell().ok_or(Tanks::new())?;
524+ let (a, list) = n.as_cell().ok_or(TTanks::new())?;
521525
522− let mut a_iter = a.as_atom().ok_or(Tanks::new())?.iter_u32_digits();
526+ let mut a_iter = a.as_atom().ok_or(TTanks::new())?.iter_u32_digits();
523527
524528 match a_iter.len() {
525529 0 => Ok(list.clone()),
@@ -536,12 +540,12 @@ static SLAG: Jet = |ctx, n| {
536540};
537541
538542static SNAG: Jet = |_ctx, n| {
539− let (a, list) = n.as_cell().ok_or(Tanks::new())?;
543+ let (a, list) = n.as_cell().ok_or(TTanks::new())?;
540544
541545 list.list_iter()
542546 .nth(a.as_u32().unwrap() as usize)
543547 .cloned()
544− .ok_or(Tanks::new())
548+ .ok_or(TTanks::new())
545549};
546550
547551static SNIP: Jet = |_ctx, n| {
@@ -558,7 +562,7 @@ static SNIP: Jet = |_ctx, n| {
558562};
559563
560564static SNOC: Jet = |_ctx, n| {
561− let (list, b) = n.as_cell().ok_or(Tanks::new())?;
565+ let (list, b) = n.as_cell().ok_or(TTanks::new())?;
562566
563567 Ok(Noun::list_refs(
564568 list.list_iter()
@@ -589,15 +593,15 @@ static SNOC: Jet = |_ctx, n| {
589593// };
590594
591595static SPIN: Jet = |ctx, n| {
592− let (list, b) = n.as_cell().ok_or(Tanks::new())?;
593− let (acc, gate) = b.as_cell().ok_or(Tanks::new())?;
596+ let (list, b) = n.as_cell().ok_or(TTanks::new())?;
597+ let (acc, gate) = b.as_cell().ok_or(TTanks::new())?;
594598
595599 let mut res = Vec::new();
596600 let mut acc = acc.clone();
597601
598602 for n in list.list_iter() {
599603 let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
600− let (el, new_acc) = foo.as_cell().ok_or(Tanks::new())?;
604+ let (el, new_acc) = foo.as_cell().ok_or(TTanks::new())?;
601605 acc = new_acc.clone();
602606 res.push(el.clone());
603607 }
@@ -606,20 +610,20 @@ static SPIN: Jet = |ctx, n| {
606610};
607611
608612static SPUN: Jet = |ctx, n| {
609− let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
613+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
610614
611615 let mut res = Vec::new();
612616 let mut acc = gate
613617 .gate_sample()
614− .ok_or(Tanks::new())?
618+ .ok_or(TTanks::new())?
615619 .as_cell()
616− .ok_or(Tanks::new())?
620+ .ok_or(TTanks::new())?
617621 .1
618622 .clone();
619623
620624 for n in list.list_iter() {
621625 let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
622− let (el, new_acc) = foo.as_cell().ok_or(Tanks::new())?;
626+ let (el, new_acc) = foo.as_cell().ok_or(TTanks::new())?;
623627 acc = new_acc.clone();
624628 res.push(el.clone());
625629 }
@@ -628,7 +632,7 @@ static SPUN: Jet = |ctx, n| {
628632};
629633
630634static TURN: Jet = |ctx, n| {
631− let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
635+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
632636 Ok(Noun::list_refs(
633637 traverse_iter_result(list.list_iter().map(|x| slam_pulled_gate(ctx, gate, x)))?
634638 .iter()
@@ -637,7 +641,7 @@ static TURN: Jet = |ctx, n| {
637641};
638642
639643static WELD: Jet = |_ctx, n| {
640− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
644+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
641645
642646 Ok(Noun::list_refs(
643647 a.list_iter()
@@ -670,18 +674,20 @@ static BEX: Jet = |ctx, n| {
670674};
671675
672676static END: Jet = |ctx, n| {
673− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
677+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
674678 let bite = a.as_bite();
675679
676680 let bits = bite.bits();
677681
678682 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
679683
680− Ok(Rc::new(Noun::Atom(mask & b.as_atom().ok_or(Tanks::new())?)))
684+ Ok(Rc::new(Noun::Atom(
685+ mask & b.as_atom().ok_or(TTanks::new())?,
686+ )))
681687};
682688
683689static CAN: Jet = |ctx, n| {
684− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
690+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
685691 let bloq = a.as_u32().unwrap();
686692 let bloq_ = 2u32.pow(bloq);
687693
@@ -696,16 +702,16 @@ static CAN: Jet = |ctx, n| {
696702 Some((acc? << bits) | (mask & q.as_atom()?))
697703 },
698704 );
699− Ok(Rc::new(Noun::Atom(atom.ok_or(Tanks::new())?)))
705+ Ok(Rc::new(Noun::Atom(atom.ok_or(TTanks::new())?)))
700706};
701707
702708static CAT: Jet = |_ctx, n| {
703− let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
704− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
709+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
710+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
705711
706− let bloq = bloq.as_u32().ok_or(Tanks::new())?;
707− let b = b.as_atom().ok_or(Tanks::new())?;
708− let c = c.as_atom().ok_or(Tanks::new())?;
712+ let bloq = bloq.as_u32().ok_or(TTanks::new())?;
713+ let b = b.as_atom().ok_or(TTanks::new())?;
714+ let c = c.as_atom().ok_or(TTanks::new())?;
709715
710716 Ok(Rc::new(Noun::Atom(
711717 (c << (met(bloq, &b) * 2u32.pow(bloq))) | b,
@@ -713,8 +719,8 @@ static CAT: Jet = |_ctx, n| {
713719};
714720
715721static MET: Jet = |_ctx, n| {
716− let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
717− let b: Atom = b.as_atom().ok_or(Tanks::new())?.clone();
722+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
723+ let b: Atom = b.as_atom().ok_or(TTanks::new())?.clone();
718724 let bloq = bloq.as_u32().unwrap();
719725
720726 Ok(Rc::new(Noun::from_u32(met(bloq, &b))))
@@ -725,28 +731,28 @@ fn met(bloq: u32, a: &Atom) -> u32 {
725731}
726732
727733static CUT: Jet = |ctx, n| {
728− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
729− let (b, d) = b.as_cell().ok_or(Tanks::new())?;
730− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
734+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
735+ let (b, d) = b.as_cell().ok_or(TTanks::new())?;
736+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
731737
732738 let bits = 2u32.pow(a.as_u32().unwrap());
733739
734740 let mask = (&ctx.big_uints.one << (bits * c.as_u32().unwrap())) - &ctx.big_uints.one;
735741
736742 Ok(Rc::new(Noun::Atom(
737− (d.as_atom().ok_or(Tanks::new())? >> (bits * b.as_u32().unwrap())) & mask,
743+ (d.as_atom().ok_or(TTanks::new())? >> (bits * b.as_u32().unwrap())) & mask,
738744 )))
739745};
740746
741747static FIL: Jet = |ctx, n| {
742− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
743− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
748+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
749+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
744750
745751 let bits = 2u32.pow(a.as_u32().unwrap());
746752
747753 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
748754
749− let src = c.as_atom().ok_or(Tanks::new())? & mask;
755+ let src = c.as_atom().ok_or(TTanks::new())? & mask;
750756
751757 let mut target = ctx.big_uints.zero.clone();
752758
@@ -758,30 +764,30 @@ static FIL: Jet = |ctx, n| {
758764};
759765
760766static LSH: Jet = |_ctx, n| {
761− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
767+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
762768 let a = a.as_bite();
763− let b = b.as_atom().ok_or(Tanks::new())?;
769+ let b = b.as_atom().ok_or(TTanks::new())?;
764770
765771 Ok(Rc::new(Noun::Atom(b << a.bits())))
766772};
767773
768774static RSH: Jet = |_ctx, n| {
769− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
775+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
770776 let a = a.as_bite();
771− let b = b.as_atom().ok_or(Tanks::new())?;
777+ let b = b.as_atom().ok_or(TTanks::new())?;
772778
773779 Ok(Rc::new(Noun::Atom(b >> a.bits())))
774780};
775781
776−static RAP: Jet = |ctx, n| {
777− let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
782+pub static RAP: Jet = |ctx, n| {
783+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
778784 let bloq = bloq.as_u32().unwrap();
779785 let bits = 2u32.pow(bloq);
780786
781787 let mut target = ctx.big_uints.zero.clone();
782788
783789 for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
784− let el = el.as_atom().ok_or(Tanks::new())?;
790+ let el = el.as_atom().ok_or(TTanks::new())?;
785791 if el != &ctx.big_uints.zero {
786792 target = (target << (bits * met(bloq, &el))) | el;
787793 }
@@ -791,7 +797,7 @@ static RAP: Jet = |ctx, n| {
791797};
792798
793799static REP: Jet = |ctx, n| {
794− let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
800+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
795801 let bite = bite.as_bite();
796802
797803 let bits = bite.bits();
@@ -800,18 +806,18 @@ static REP: Jet = |ctx, n| {
800806 let mut target = ctx.big_uints.zero.clone();
801807
802808 for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
803− target = (target << bits) | (el.as_atom().ok_or(Tanks::new())? & &mask);
809+ target = (target << bits) | (el.as_atom().ok_or(TTanks::new())? & &mask);
804810 }
805811
806812 Ok(Rc::new(Noun::Atom(target)))
807813};
808814
809815static REV: Jet = |ctx, n| {
810− let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
811− let (len, dat) = b.as_cell().ok_or(Tanks::new())?;
816+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
817+ let (len, dat) = b.as_cell().ok_or(TTanks::new())?;
812818 let bloq = bloq.as_u32().unwrap();
813819 let len = len.as_u32().unwrap();
814− let mut dat: Atom = dat.as_atom().ok_or(Tanks::new())?.clone();
820+ let mut dat: Atom = dat.as_atom().ok_or(TTanks::new())?.clone();
815821
816822 let bits = 2u32.pow(bloq);
817823 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -827,9 +833,9 @@ static REV: Jet = |ctx, n| {
827833};
828834
829835static RIP: Jet = |ctx, n| {
830− let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
836+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
831837 let bite = bite.as_bite();
832− let mut b: Atom = b.as_atom().ok_or(Tanks::new())?.clone();
838+ let mut b: Atom = b.as_atom().ok_or(TTanks::new())?.clone();
833839
834840 let bits = bite.bits();
835841 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -845,11 +851,11 @@ static RIP: Jet = |ctx, n| {
845851};
846852
847853static RUN: Jet = |ctx, n| {
848− let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
849− let (b, gate) = b.as_cell().ok_or(Tanks::new())?;
854+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
855+ let (b, gate) = b.as_cell().ok_or(TTanks::new())?;
850856
851857 let bite = bite.as_bite();
852− let mut b: Atom = b.as_atom().ok_or(Tanks::new())?.clone();
858+ let mut b: Atom = b.as_atom().ok_or(TTanks::new())?.clone();
853859
854860 let bits = bite.bits();
855861 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -860,7 +866,7 @@ static RUN: Jet = |ctx, n| {
860866 target = (target << bits)
861867 | ((*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
862868 .as_atom()
863− .ok_or(Tanks::new())?
869+ .ok_or(TTanks::new())?
864870 & &mask);
865871 b = b >> bits;
866872 }
@@ -869,11 +875,11 @@ static RUN: Jet = |ctx, n| {
869875};
870876
871877static RUT: Jet = |ctx, n| {
872− let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
873− let (b, gate) = b.as_cell().ok_or(Tanks::new())?;
878+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
879+ let (b, gate) = b.as_cell().ok_or(TTanks::new())?;
874880
875881 let bite = bite.as_bite();
876− let mut b: Atom = b.as_atom().ok_or(Tanks::new())?.clone();
882+ let mut b: Atom = b.as_atom().ok_or(TTanks::new())?.clone();
877883
878884 let bits = bite.bits();
879885 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -884,7 +890,7 @@ static RUT: Jet = |ctx, n| {
884890 target.push(
885891 (*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
886892 .as_atom()
887− .ok_or(Tanks::new())?
893+ .ok_or(TTanks::new())?
888894 & &mask,
889895 );
890896 b = b >> bits;
@@ -894,12 +900,12 @@ static RUT: Jet = |ctx, n| {
894900};
895901
896902static SEW: Jet = |ctx, n| {
897− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
898− let (b, recipient) = b.as_cell().ok_or(Tanks::new())?;
899− let (sew_start, c) = b.as_cell().ok_or(Tanks::new())?;
900− let (number_of_blocks, donor) = c.as_cell().ok_or(Tanks::new())?;
901− let recipient = recipient.as_atom().ok_or(Tanks::new())?;
902− let donor = donor.as_atom().ok_or(Tanks::new())?;
903+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
904+ let (b, recipient) = b.as_cell().ok_or(TTanks::new())?;
905+ let (sew_start, c) = b.as_cell().ok_or(TTanks::new())?;
906+ let (number_of_blocks, donor) = c.as_cell().ok_or(TTanks::new())?;
907+ let recipient = recipient.as_atom().ok_or(TTanks::new())?;
908+ let donor = donor.as_atom().ok_or(TTanks::new())?;
903909
904910 let bloq = a.as_u32().unwrap();
905911 let bits = 2u32.pow(bloq);
@@ -915,12 +921,12 @@ static SEW: Jet = |ctx, n| {
915921};
916922
917923static SWP: Jet = |ctx, n| {
918− let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
924+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
919925 let bloq = bloq.as_u32().unwrap();
920926 let bits = 2u32.pow(bloq);
921927 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
922928
923− let mut source = b.as_atom().ok_or(Tanks::new())?.clone();
929+ let mut source = b.as_atom().ok_or(TTanks::new())?.clone();
924930 let mut target = ctx.big_uints.zero.clone();
925931
926932 while source > ctx.big_uints.zero {
@@ -932,7 +938,7 @@ static SWP: Jet = |ctx, n| {
932938};
933939
934940static XEB: Jet = |_ctx, n| {
935− let mut a = n.as_atom().ok_or(Tanks::new())?.clone();
941+ let mut a = n.as_atom().ok_or(TTanks::new())?.clone();
936942
937943 let mut c = 0;
938944
@@ -949,22 +955,22 @@ static DIS: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a & b);
949955static MIX: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a ^ b);
950956
951957static NOT: Jet = |ctx, n| {
952− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
953− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
958+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
959+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
954960
955961 let bloq = a.as_u32().unwrap();
956962 let bits = 2u32.pow(bloq);
957963 let mask = (&ctx.big_uints.one << (bits * b.as_u32().unwrap())) - &ctx.big_uints.one;
958964
959− let target = c.as_atom().ok_or(Tanks::new())? ^ &mask;
965+ let target = c.as_atom().ok_or(TTanks::new())? ^ &mask;
960966
961967 Ok(Rc::new(Noun::Atom(target)))
962968};
963969
964970static LAST: Jet = |_ctx, n| {
965− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
966− let a = a.as_hair().ok_or(Tanks::new())?;
967− let b = b.as_hair().ok_or(Tanks::new())?;
971+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
972+ let a = a.as_hair().ok_or(TTanks::new())?;
973+ let b = b.as_hair().ok_or(TTanks::new())?;
968974 Ok(Noun::from_hair(last(&a, &b)))
969975};
970976
@@ -985,18 +991,18 @@ fn last<'a>(a: &'a Hair, b: &'a Hair) -> &'a Hair {
985991}
986992
987993static TRIP: Jet = |_ctx, n| {
988− let a = n.as_atom().ok_or(Tanks::new())?;
994+ let a = n.as_atom().ok_or(TTanks::new())?;
989995 Ok(Noun::list(
990996 a.to_bytes_le().iter().map(|b| Noun::from_u32(*b as u32)),
991997 ))
992998};
993999
9941000static MUK: Jet = |_ctx, n| {
995− let (seed, len) = n.as_cell().ok_or(Tanks::new())?;
996− let (len, key) = len.as_cell().ok_or(Tanks::new())?;
997− let seed = seed.as_u32().ok_or(Tanks::new())?;
998− let len = len.as_u32().ok_or(Tanks::new())?;
999− let key = key.as_atom().ok_or(Tanks::new())?;
1001+ let (seed, len) = n.as_cell().ok_or(TTanks::new())?;
1002+ let (len, key) = len.as_cell().ok_or(TTanks::new())?;
1003+ let seed = seed.as_u32().ok_or(TTanks::new())?;
1004+ let len = len.as_u32().ok_or(TTanks::new())?;
1005+ let key = key.as_atom().ok_or(TTanks::new())?;
10001006
10011007 Ok(Rc::new(Noun::from_u32(muk(seed, len, key))))
10021008};
nock/src/lib.rs+1−34
@@ -4,7 +4,7 @@
44use core::str;
55use std::{borrow::Borrow, rc::Rc};
66
7−use interpreter::{eval_pulled_gate, slam_pulled_gate, tar, InterpreterContext, Tanks};
7+use interpreter::{eval_pulled_gate, slam_pulled_gate, tar, InterpreterContext, TTank, TTanks};
88use noun::{cell, Noun};
99pub mod cue;
1010pub mod interpreter;
@@ -13,36 +13,3 @@ mod jets;
1313pub mod noun;
1414
1515pub type Vase = (Rc<Noun>, Rc<Noun>);
16−
17−pub fn wash(ctx: &mut InterpreterContext, urbit: &Rc<Noun>, tanks: Tanks) -> String {
18− let mut target = String::new();
19− for (subj, q) in tanks.iter() {
20− match tar(ctx, subj.clone(), q).unwrap().borrow() {
21− Noun::Atom(a) => {
22− target.push_str(str::from_utf8_mut(&mut *a.to_bytes_le()).unwrap());
23− }
24− gate @ Noun::Cell { .. } => {
25− let tank = eval_pulled_gate(ctx, Rc::new(gate.clone())).unwrap();
26− let mut str = slam_pulled_gate(
27− ctx,
28− &urbit,
29− &cell(
30− &Rc::new(Noun::from_bytes(b"wash")),
31− &cell(
32− &cell(&Rc::new(Noun::from_u32(0)), &Rc::new(Noun::from_u32(80))),
33− &tank,
34− ),
35− ),
36− )
37− .unwrap()
38− .as_atom()
39− .unwrap()
40− .to_bytes_le();
41−
42− target.push_str(str::from_utf8_mut(&mut *str).unwrap())
43− }
44− }
45− }
46−
47− target
48−}
nock/src/main.rs+7−16
@@ -1,7 +1,6 @@
11use clap::{command, error::Result, Parser, Subcommand};
22use core::str;
3−use nock::interpreter::{eval_pulled_gate, slam_pulled_gate, tar, InterpreterContext, Tanks};
4−use nock::wash;
3+use nock::interpreter::{ram_ttanks, slam_pulled_gate, tar, InterpreterContext, TTanks};
54use nock::{
65 cue::cue_bytes,
76 interpreter::{generate_interpreter_context, slam},
@@ -9,7 +8,6 @@ use nock::{
98 noun::{cell, Atom, Noun},
109};
1110use spinoff::Spinner;
12−use std::borrow::Borrow;
1311use std::cell::LazyCell;
1412use std::{
1513 fs::File,
@@ -91,7 +89,7 @@ fn main() -> Result<(), std::io::Error> {
9189 spinner.fail("Gate execution failed");
9290
9391 let mut spinner = new_spinner(String::from("Building trace"));
94− let trace = wash(&mut ctx, &urbit, tanks);
92+ let trace = ram_ttanks(&mut ctx, tanks);
9593 spinner.success("Trace built");
9694 println!("{trace}");
9795 exit(1);
@@ -182,13 +180,7 @@ fn compile_to_nock(
182180 &urbit,
183181 &cell(&Rc::new(Noun::from_bytes(b"hoon")), &ctx.nouns.sig),
184182 );
185− let hoon = or_wash_fail(
186− ctx,
187− urbit,
188− hoon,
189− spinner,
190− "Failed to read Hoon standard library",
191− );
183+ let hoon = or_wash_fail(ctx, hoon, spinner, "Failed to read Hoon standard library");
192184 let (hoon_type, hoon) = hoon.as_cell().unwrap();
193185
194186 spinner.update_text(format!("Compiling {root:#?}"));
@@ -206,7 +198,7 @@ fn compile_to_nock(
206198 ),
207199 ),
208200 );
209− let target = or_wash_fail(ctx, urbit, target, spinner, "Compilation failed");
201+ let target = or_wash_fail(ctx, target, spinner, "Compilation failed");
210202
211203 let (target_type, target_nock) = target.as_cell().unwrap();
212204
@@ -222,7 +214,7 @@ fn compile_to_nock(
222214 );
223215 let combined_nock = cell(
224216 target_type,
225− &or_wash_fail(ctx, urbit, combined_nock, spinner, "Failed to combine Nock"),
217+ &or_wash_fail(ctx, combined_nock, spinner, "Failed to combine Nock"),
226218 );
227219 Ok(combined_nock)
228220}
@@ -244,8 +236,7 @@ fn read_nock_or_compile(
244236
245237fn or_wash_fail(
246238 ctx: &mut InterpreterContext,
247− urbit: &Rc<Noun>,
248− source: Result<Rc<Noun>, Tanks>,
239+ source: Result<Rc<Noun>, TTanks>,
249240 spinner: &mut Spinner,
250241 fail_err: &str,
251242) -> Rc<Noun> {
@@ -253,7 +244,7 @@ fn or_wash_fail(
253244 Ok(source) => source,
254245 Err(tanks) => {
255246 spinner.fail(fail_err);
256− let washed_tanks = wash(ctx, urbit, tanks);
247+ let washed_tanks = ram_ttanks(ctx, tanks);
257248 eprintln!("{}", washed_tanks);
258249 exit(1)
259250 }