on master help sign in
ef80ea9iko
nock/hello.hoon+2−1
@@ -1,5 +1,6 @@
1|= name=@t
1|= name=@t
2+~& name
2?+ name (crip (weld "Hello, " (trip name)))
3?+ name (crip (weld "Hello, " (trip name)))
3 'Curtis' 'Hello, daddy...'
4 'Curtis' 'Hello, daddy...'
4− '' 'Hello, world!'
5+ %'' 'Hello, world!'
5==
6==
nock/hello.nock

Binary file not shown.

nock/src/interpreter.rs+164−34
@@ -1,6 +1,9 @@
1+use core::str;
1use std::borrow::Borrow;
2use std::borrow::Borrow;
3+use std::borrow::BorrowMut;
2use std::collections::BTreeMap;
4use std::collections::BTreeMap;
3use std::rc::Rc;
5use std::rc::Rc;
6+use std::str::Utf8Error;
4
7
5use fplist::cons;
8use fplist::cons;
6use fplist::PersistentList;
9use fplist::PersistentList;
@@ -22,6 +25,7 @@ pub struct Nouns {
22 pub two_three: Rc<Noun>,
25 pub two_three: Rc<Noun>,
23 pub memo: Rc<Noun>,
26 pub memo: Rc<Noun>,
24 pub mean: Rc<Noun>,
27 pub mean: Rc<Noun>,
28+ pub slog: Rc<Noun>,
25}
29}
26
30
27#[derive(Clone)]
31#[derive(Clone)]
@@ -61,6 +65,7 @@ pub fn generate_interpreter_context() -> InterpreterContext {
61 let two_three = cell(&two, &three);
65 let two_three = cell(&two, &three);
62 let memo = Rc::new(Noun::from_bytes(b"memo"));
66 let memo = Rc::new(Noun::from_bytes(b"memo"));
63 let mean = Rc::new(Noun::from_bytes(b"mean"));
67 let mean = Rc::new(Noun::from_bytes(b"mean"));
68+ let slog = Rc::new(Noun::from_bytes(b"slog"));
64 InterpreterContext {
69 InterpreterContext {
65 jets,
70 jets,
66 double_jets,
71 double_jets,
@@ -76,6 +81,7 @@ pub fn generate_interpreter_context() -> InterpreterContext {
76 two_three,
81 two_three,
77 memo,
82 memo,
78 mean,
83 mean,
84+ slog,
79 },
85 },
80 big_uints,
86 big_uints,
81 memo: BTreeMap::new(),
87 memo: BTreeMap::new(),
@@ -89,7 +95,7 @@ fn wut<'a>(ctx: &'a InterpreterContext, noun: &Noun) -> &'a Rc<Noun> {
89 }
95 }
90}
96}
91
97
92−fn lus(noun: &Noun) -> Result<Noun, Tanks> {
98+fn lus(noun: &Noun) -> Result<Noun, TTanks> {
93 match noun {
99 match noun {
94 Noun::Cell { .. } => Err(PersistentList::new()),
100 Noun::Cell { .. } => Err(PersistentList::new()),
95 Noun::Atom(atm) => Ok(Noun::Atom(atm + 1u32)),
101 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>
104 }
110 }
105}
111}
106
112
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> {
108 let mut addr_iter = addr.iter_u32_digits();
114 let mut addr_iter = addr.iter_u32_digits();
109
115
110 match (addr_iter.next(), addr_iter.next()) {
116 match (addr_iter.next(), addr_iter.next()) {
@@ -124,7 +130,7 @@ fn fas(ctx: &InterpreterContext, addr: &Atom, noun: &Noun) -> Result<Rc<Noun>, T
124 }
130 }
125}
131}
126
132
127−fn fas_u32(addr: u32, noun: &Noun) -> Result<Rc<Noun>, Tanks> {
133+fn fas_u32(addr: u32, noun: &Noun) -> Result<Rc<Noun>, TTanks> {
128 match addr {
134 match addr {
129 0 => Err(PersistentList::new()),
135 0 => Err(PersistentList::new()),
130 1 => Ok(Rc::new(noun.clone())),
136 1 => Ok(Rc::new(noun.clone())),
@@ -142,7 +148,7 @@ fn fas_u32(addr: u32, noun: &Noun) -> Result<Rc<Noun>, Tanks> {
142 }
148 }
143}
149}
144
150
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> {
146 match addr {
152 match addr {
147 0 => Err(PersistentList::new()),
153 0 => Err(PersistentList::new()),
148 1 => Ok(new_value.clone()),
154 1 => Ok(new_value.clone()),
@@ -164,11 +170,11 @@ fn hax(
164 addr: &Atom,
170 addr: &Atom,
165 new_value: &Rc<Noun>,
171 new_value: &Rc<Noun>,
166 target: &Rc<Noun>,
172 target: &Rc<Noun>,
167−) -> Result<Rc<Noun>, Tanks> {
173+) -> Result<Rc<Noun>, TTanks> {
168 let mut addr_iter = addr.iter_u32_digits();
174 let mut addr_iter = addr.iter_u32_digits();
169
175
170 match (addr_iter.next(), addr_iter.next()) {
176 match (addr_iter.next(), addr_iter.next()) {
171− (None, _) => Err(Tanks::new()),
177+ (None, _) => Err(TTanks::new()),
172 (Some(x), None) => hax_u32(x, new_value, target),
178 (Some(x), None) => hax_u32(x, new_value, target),
173 _ => hax(
179 _ => hax(
174 ctx,
180 ctx,
@@ -190,15 +196,15 @@ fn tar_u32<'a>(
190 subj: Rc<Noun>,
196 subj: Rc<Noun>,
191 op: u32,
197 op: u32,
192 formula: &'a Rc<Noun>,
198 formula: &'a Rc<Noun>,
193−) -> Result<Rc<Noun>, Tanks> {
199+) -> Result<Rc<Noun>, TTanks> {
194 match op {
200 match op {
195 0 => {
201 0 => {
196− let b = formula.as_atom().ok_or(Tanks::new())?;
202+ let b = formula.as_atom().ok_or(TTanks::new())?;
197 fas(ctx, b, &*subj)
203 fas(ctx, b, &*subj)
198 }
204 }
199 1 => Ok(formula.clone()),
205 1 => Ok(formula.clone()),
200 2 => {
206 2 => {
201− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
207+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
202
208
203 match c.borrow() {
209 match c.borrow() {
204 Noun::Cell { p, q, .. }
210 Noun::Cell { p, q, .. }
@@ -229,14 +235,14 @@ fn tar_u32<'a>(
229 }
235 }
230 4 => Ok(Rc::new(lus(&*tar(ctx, subj, &formula)?)?)),
236 4 => Ok(Rc::new(lus(&*tar(ctx, subj, &formula)?)?)),
231 5 => {
237 5 => {
232− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
238+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
233 let foo = tar(ctx, subj.clone(), &b)?;
239 let foo = tar(ctx, subj.clone(), &b)?;
234 let bar = tar(ctx, subj, &c)?;
240 let bar = tar(ctx, subj, &c)?;
235 Ok(tis(ctx, &foo, &bar).clone())
241 Ok(tis(ctx, &foo, &bar).clone())
236 }
242 }
237 6 => {
243 6 => {
238− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
244+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
239− let (c, d) = c.as_cell().ok_or(Tanks::new())?;
245+ let (c, d) = c.as_cell().ok_or(TTanks::new())?;
240
246
241 let bar = tar_u32(ctx, subj.clone(), 4, &cell(&ctx.nouns.four.clone(), &b))?;
247 let bar = tar_u32(ctx, subj.clone(), 4, &cell(&ctx.nouns.four.clone(), &b))?;
242
248
@@ -246,17 +252,17 @@ fn tar_u32<'a>(
246 tar(ctx, subj, &foo)
252 tar(ctx, subj, &foo)
247 }
253 }
248 7 => {
254 7 => {
249− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
255+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
250 let foo = tar(ctx, subj, &b)?;
256 let foo = tar(ctx, subj, &b)?;
251 tar(ctx, foo, &c)
257 tar(ctx, foo, &c)
252 }
258 }
253 8 => {
259 8 => {
254− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
260+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
255 let foo = tar(ctx, subj.clone(), &b)?;
261 let foo = tar(ctx, subj.clone(), &b)?;
256 tar(ctx, cell(&foo, &subj), &c)
262 tar(ctx, cell(&foo, &subj), &c)
257 }
263 }
258 9 => {
264 9 => {
259− let (b, c) = formula.as_cell().ok_or(Tanks::new())?;
265+ let (b, c) = formula.as_cell().ok_or(TTanks::new())?;
260 let foo = tar(ctx, subj, &c)?;
266 let foo = tar(ctx, subj, &c)?;
261 tar_u32(
267 tar_u32(
262 ctx,
268 ctx,
@@ -266,16 +272,16 @@ fn tar_u32<'a>(
266 )
272 )
267 }
273 }
268 10 => {
274 10 => {
269− let (b, d) = formula.as_cell().ok_or(Tanks::new())?;
275+ let (b, d) = formula.as_cell().ok_or(TTanks::new())?;
270− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
276+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
271− let b = b.as_atom().ok_or(Tanks::new())?;
277+ let b = b.as_atom().ok_or(TTanks::new())?;
272
278
273 let foo = tar(ctx, subj.clone(), &c)?;
279 let foo = tar(ctx, subj.clone(), &c)?;
274 let bar = tar(ctx, subj, &d)?;
280 let bar = tar(ctx, subj, &d)?;
275 hax(ctx, b, &foo, &bar)
281 hax(ctx, b, &foo, &bar)
276 }
282 }
277 11 => {
283 11 => {
278− let (b, d) = formula.as_cell().ok_or(Tanks::new())?;
284+ let (b, d) = formula.as_cell().ok_or(TTanks::new())?;
279 match b.borrow() {
285 match b.borrow() {
280 Noun::Atom(_) => tar(ctx, subj, &d),
286 Noun::Atom(_) => tar(ctx, subj, &d),
281 Noun::Cell { p, q, .. } => {
287 Noun::Cell { p, q, .. } => {
@@ -292,34 +298,155 @@ fn tar_u32<'a>(
292 }
298 }
293 } else if *p == ctx.nouns.mean {
299 } else if *p == ctx.nouns.mean {
294 with_trace((subj.clone(), q.clone()), eval(ctx))
300 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)
295 } else {
307 } else {
296 eval(ctx)
308 eval(ctx)
297 }
309 }
298 }
310 }
299 }
311 }
300 }
312 }
301− _ => Err(Tanks::new()),
313+ _ => Err(TTanks::new()),
302 }
314 }
303}
315}
304
316
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+
305−fn with_trace<T>(tank: (Rc<Noun>, Rc<Noun>), src: Result<T, Tanks>) -> Result<T, Tanks> {
431+fn with_trace<T>(tank: (Rc<Noun>, Rc<Noun>), src: Result<T, TTanks>) -> Result<T, TTanks> {
306 match src {
432 match src {
307 Ok(a) => Ok(a),
433 Ok(a) => Ok(a),
308 Err(tanks) => Err(cons(tank, tanks)),
434 Err(tanks) => Err(cons(tank, tanks)),
309 }
435 }
310}
436}
311
437
438+/// Not actually a tank, but rather a thunk (subject, formula) which calculates the tank.
312−pub type Tank = Rc<Noun>;
439+pub type TTank = (Rc<Noun>, Rc<Noun>);
313−pub type Tanks = PersistentList<(Rc<Noun>, Rc<Noun>)>;
440+pub type TTanks = PersistentList<TTank>;
314
441
315−pub const EMPTY_TANKS: Tanks = Tanks::new();
442+pub const EMPTY_TANKS: TTanks = TTanks::new();
316
443
317pub fn tar<'a>(
444pub fn tar<'a>(
318 ctx: &mut InterpreterContext,
445 ctx: &mut InterpreterContext,
319 subj: Rc<Noun>,
446 subj: Rc<Noun>,
320 formula: &'a Noun,
447 formula: &'a Noun,
321−) -> Result<Rc<Noun>, Tanks> {
448+) -> Result<Rc<Noun>, TTanks> {
322− let (op, formula) = formula.as_cell().ok_or(Tanks::new())?;
449+ let (op, formula) = formula.as_cell().ok_or(TTanks::new())?;
323 match op.borrow() {
450 match op.borrow() {
324 Noun::Cell { .. } => {
451 Noun::Cell { .. } => {
325 let foo = tar(ctx, subj.clone(), &op)?;
452 let foo = tar(ctx, subj.clone(), &op)?;
@@ -333,13 +460,16 @@ pub fn tar<'a>(
333 1 => Some(op_iter.next().unwrap()),
460 1 => Some(op_iter.next().unwrap()),
334 _ => None,
461 _ => None,
335 };
462 };
336− let op = op.ok_or(Tanks::new())?;
463+ let op = op.ok_or(TTanks::new())?;
337 stacker::maybe_grow(32 * 1024, 1024 * 1024, || tar_u32(ctx, subj, op, formula))
464 stacker::maybe_grow(32 * 1024, 1024 * 1024, || tar_u32(ctx, subj, op, formula))
338 }
465 }
339 }
466 }
340}
467}
341
468
469+pub fn eval_gate(
342−pub fn eval_gate(ctx: &mut InterpreterContext, gate_factory: &Rc<Noun>) -> Result<Rc<Noun>, Tanks> {
470+ ctx: &mut InterpreterContext,
471+ gate_factory: &Rc<Noun>,
472+) -> Result<Rc<Noun>, TTanks> {
343 let pulled_gate = tar(ctx, ctx.nouns.sig.clone(), &gate_factory)?;
473 let pulled_gate = tar(ctx, ctx.nouns.sig.clone(), &gate_factory)?;
344 eval_pulled_gate(ctx, pulled_gate)
474 eval_pulled_gate(ctx, pulled_gate)
345}
475}
@@ -348,7 +478,7 @@ pub fn slam(
348 ctx: &mut InterpreterContext,
478 ctx: &mut InterpreterContext,
349 gate_factory: &Rc<Noun>,
479 gate_factory: &Rc<Noun>,
350 sample: &Rc<Noun>,
480 sample: &Rc<Noun>,
351−) -> Result<Rc<Noun>, Tanks> {
481+) -> Result<Rc<Noun>, TTanks> {
352 let gate = tar(ctx, ctx.nouns.sig.clone(), &gate_factory)?;
482 let gate = tar(ctx, ctx.nouns.sig.clone(), &gate_factory)?;
353
483
354 eval_pulled_gate(ctx, replace_sample(&gate, sample)?)
484 eval_pulled_gate(ctx, replace_sample(&gate, sample)?)
@@ -356,7 +486,7 @@ pub fn slam(
356
486
357/// This is useful for evaluaing gates produced by running `.foo/nock gate-name` in the dojo.
487/// This is useful for evaluaing gates produced by running `.foo/nock gate-name` in the dojo.
358/// Also for calling gates from within jets.
488/// 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> {
360 tar(
490 tar(
361 ctx,
491 ctx,
362 gate,
492 gate,
@@ -373,13 +503,13 @@ pub fn slam_pulled_gate(
373 ctx: &mut InterpreterContext,
503 ctx: &mut InterpreterContext,
374 gate: &Rc<Noun>,
504 gate: &Rc<Noun>,
375 sample: &Rc<Noun>,
505 sample: &Rc<Noun>,
376−) -> Result<Rc<Noun>, Tanks> {
506+) -> Result<Rc<Noun>, TTanks> {
377 eval_pulled_gate(ctx, replace_sample(gate, sample)?)
507 eval_pulled_gate(ctx, replace_sample(gate, sample)?)
378}
508}
379
509
380−pub fn replace_sample(gate: &Rc<Noun>, sample: &Rc<Noun>) -> Result<Rc<Noun>, Tanks> {
510+pub fn replace_sample(gate: &Rc<Noun>, sample: &Rc<Noun>) -> Result<Rc<Noun>, TTanks> {
381− let (battery, payload) = gate.as_cell().ok_or(Tanks::new())?;
511+ let (battery, payload) = gate.as_cell().ok_or(TTanks::new())?;
382− let (_sample, context) = payload.as_cell().ok_or(Tanks::new())?;
512+ let (_sample, context) = payload.as_cell().ok_or(TTanks::new())?;
383
513
384 Ok(cell(battery, &cell(sample, context)))
514 Ok(cell(battery, &cell(sample, context)))
385}
515}
nock/src/jets.rs+134−128
@@ -8,7 +8,7 @@ use std::{
8};
8};
9
9
10use crate::{
10use crate::{
11− interpreter::{slam_pulled_gate, InterpreterContext, Tanks},
11+ interpreter::{slam_pulled_gate, InterpreterContext, TTanks},
12 noun::{self, cell, Atom, Edge, Hair, Nail, Noun},
12 noun::{self, cell, Atom, Edge, Hair, Nail, Noun},
13};
13};
14
14
@@ -110,15 +110,15 @@ pub fn generate_jets() -> Jets {
110 ])
110 ])
111}
111}
112
112
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>;
114pub type DoubleJet = fn(ctx: &mut InterpreterContext, &Rc<Noun>, &Rc<Noun>) -> Option<Rc<Noun>>;
114pub type DoubleJet = fn(ctx: &mut InterpreterContext, &Rc<Noun>, &Rc<Noun>) -> Option<Rc<Noun>>;
115
115
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> =
117 |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> Atom| {
117 |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())?;
119 Ok(Rc::new(Noun::Atom(f(
119 Ok(Rc::new(Noun::Atom(f(
120− p.as_atom().ok_or(Tanks::new())?,
120+ p.as_atom().ok_or(TTanks::new())?,
121− q.as_atom().ok_or(Tanks::new())?,
121+ q.as_atom().ok_or(TTanks::new())?,
122 ))))
122 ))))
123 };
123 };
124
124
@@ -126,13 +126,13 @@ static BINARY_ATOM_LOOB: fn(
126 &InterpreterContext,
126 &InterpreterContext,
127 &Rc<Noun>,
127 &Rc<Noun>,
128 fn(&Atom, &Atom) -> bool,
128 fn(&Atom, &Atom) -> bool,
129−) -> Result<Rc<Noun>, Tanks> =
129+) -> Result<Rc<Noun>, TTanks> =
130 |ctx: &InterpreterContext, n: &Rc<Noun>, f: fn(&Atom, &Atom) -> bool| {
130 |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())?;
132
132
133 if f(
133 if f(
134− p.as_atom().ok_or(Tanks::new())?,
134+ p.as_atom().ok_or(TTanks::new())?,
135− q.as_atom().ok_or(Tanks::new())?,
135+ q.as_atom().ok_or(TTanks::new())?,
136 ) {
136 ) {
137 Ok(ctx.nouns.sig.clone())
137 Ok(ctx.nouns.sig.clone())
138 } else {
138 } else {
@@ -143,18 +143,22 @@ static BINARY_ATOM_LOOB: fn(
143static BINARY_ATOM_PAIR: fn(
143static BINARY_ATOM_PAIR: fn(
144 &Rc<Noun>,
144 &Rc<Noun>,
145 fn(&Atom, &Atom) -> (Atom, Atom),
145 fn(&Atom, &Atom) -> (Atom, Atom),
146−) -> Result<Rc<Noun>, Tanks> = |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
146+) -> Result<Rc<Noun>, TTanks> = |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
147− let (p, q) = n.as_cell().ok_or(Tanks::new())?;
147+ let (p, q) = n.as_cell().ok_or(TTanks::new())?;
148
148
149 let (a, b) = f(
149 let (a, b) = f(
150− p.as_atom().ok_or(Tanks::new())?,
150+ p.as_atom().ok_or(TTanks::new())?,
151− q.as_atom().ok_or(Tanks::new())?,
151+ q.as_atom().ok_or(TTanks::new())?,
152 );
152 );
153 Ok(cell(&Rc::new(Noun::Atom(a)), &Rc::new(Noun::Atom(b))))
153 Ok(cell(&Rc::new(Noun::Atom(a)), &Rc::new(Noun::Atom(b))))
154};
154};
155
155
156static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
156static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
157+static DEC: Jet = |_ctx, n| {
158+ Ok(Rc::new(Noun::Atom(
157−static DEC: Jet = |_ctx, n| Ok(Rc::new(Noun::Atom(n.as_atom().ok_or(Tanks::new())? - 1u32)));
159+ n.as_atom().ok_or(TTanks::new())? - 1u32,
160+ )))
161+};
158static DVR: Jet = |_ctx, n| BINARY_ATOM_PAIR(n, |a, b| a.div_rem(&b));
162static DVR: Jet = |_ctx, n| BINARY_ATOM_PAIR(n, |a, b| a.div_rem(&b));
159static DIV: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a / b);
163static DIV: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a / b);
160static GTE: Jet = |ctx, n| BINARY_ATOM_LOOB(ctx, n, |a, b| a >= b);
164static 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);
168static SUB: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a - b);
172static SUB: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a - b);
169
173
170static CAP: Jet = |ctx, n| {
174static CAP: Jet = |ctx, n| {
171− let n = n.as_atom().ok_or(Tanks::new())?;
175+ let n = n.as_atom().ok_or(TTanks::new())?;
172 CAP_ATOM(ctx, n.clone())
176 CAP_ATOM(ctx, n.clone())
173};
177};
174
178
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| {
176 let mut n_iter = n.iter_u32_digits();
180 let mut n_iter = n.iter_u32_digits();
177
181
178 match n_iter.len() {
182 match n_iter.len() {
179− 0 => Err(Tanks::new()),
183+ 0 => Err(TTanks::new()),
180 1 => CAP_U32(ctx, n_iter.next().unwrap()),
184 1 => CAP_U32(ctx, n_iter.next().unwrap()),
181 _ => CAP_ATOM(ctx, n >> 1),
185 _ => CAP_ATOM(ctx, n >> 1),
182 }
186 }
183};
187};
184−static CAP_U32: fn(ctx: &InterpreterContext, u32) -> Result<Rc<Noun>, Tanks> = |ctx, n| match n {
188+static CAP_U32: fn(ctx: &InterpreterContext, u32) -> Result<Rc<Noun>, TTanks> = |ctx, n| match n {
185− 0 | 1 => Err(Tanks::new()),
189+ 0 | 1 => Err(TTanks::new()),
186 2 => Ok(ctx.nouns.two.clone()),
190 2 => Ok(ctx.nouns.two.clone()),
187 3 => Ok(ctx.nouns.three.clone()),
191 3 => Ok(ctx.nouns.three.clone()),
188 n => CAP_U32(ctx, n >> 1),
192 n => CAP_U32(ctx, n >> 1),
189};
193};
190
194
191static MAS: Jet = |ctx, n| {
195static MAS: Jet = |ctx, n| {
192− let n = n.as_atom().ok_or(Tanks::new())?;
196+ let n = n.as_atom().ok_or(TTanks::new())?;
193 Ok(Rc::new(Noun::Atom(
197 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())?,
195 )))
199 )))
196};
200};
197static MAS_ATOM: fn(&InterpreterContext, Atom) -> Option<Atom> = |ctx, n| {
201static MAS_ATOM: fn(&InterpreterContext, Atom) -> Option<Atom> = |ctx, n| {
@@ -213,22 +217,22 @@ static MAS_U32: fn(u32) -> u32 = |n| match n {
213};
217};
214
218
215static PEG: Jet = |ctx, n| {
219static 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())?;
217
221
218− let a = a.as_atom().ok_or(Tanks::new())?;
222+ let a = a.as_atom().ok_or(TTanks::new())?;
219− let b = b.as_atom().ok_or(Tanks::new())?;
223+ let b = b.as_atom().ok_or(TTanks::new())?;
220
224
221 if *a == Atom::ZERO {
225 if *a == Atom::ZERO {
222− return Err(Tanks::new());
226+ return Err(TTanks::new());
223 };
227 };
224
228
225 Ok(Rc::new(Noun::Atom(PEG_ATOM(ctx, a, b.clone())?)))
229 Ok(Rc::new(Noun::Atom(PEG_ATOM(ctx, a, b.clone())?)))
226};
230};
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| {
228 let mut b_iter = b.iter_u32_digits();
232 let mut b_iter = b.iter_u32_digits();
229
233
230 match b_iter.len() {
234 match b_iter.len() {
231− 0 => Err(Tanks::new()),
235+ 0 => Err(TTanks::new()),
232 1 => Ok(PEG_U32(a, b_iter.next().unwrap())),
236 1 => Ok(PEG_U32(a, b_iter.next().unwrap())),
233 _ => Ok((&b & &ctx.big_uints.one) + (PEG_ATOM(ctx, a, b >> 1)? << 1)),
237 _ => Ok((&b & &ctx.big_uints.one) + (PEG_ATOM(ctx, a, b >> 1)? << 1)),
234 }
238 }
@@ -242,7 +246,7 @@ static PEG_U32: fn(&Atom, u32) -> Atom = |a, b| match b {
242};
246};
243
247
244static FAND: Jet = |ctx, n| {
248static 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())?;
246 if nedl.is_sig() || hstk.is_sig() {
250 if nedl.is_sig() || hstk.is_sig() {
247 return Ok(ctx.nouns.sig.clone());
251 return Ok(ctx.nouns.sig.clone());
248 }
252 }
@@ -272,7 +276,7 @@ static FAND: Jet = |ctx, n| {
272};
276};
273
277
274static FIND: Jet = |ctx, n| {
278static 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())?;
276 if nedl.is_sig() || hstk.is_sig() {
280 if nedl.is_sig() || hstk.is_sig() {
277 return Ok(ctx.nouns.sig.clone());
281 return Ok(ctx.nouns.sig.clone());
278 }
282 }
@@ -305,13 +309,13 @@ static FLOP: Jet = |ctx, n| {
305};
309};
306
310
307static GULF: Jet = |_ctx, n| {
311static 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())?;
309
313
310− let mut from = (*from.as_atom().ok_or(Tanks::new())?).clone();
314+ let mut from = (*from.as_atom().ok_or(TTanks::new())?).clone();
311− let to = to.as_atom().ok_or(Tanks::new())?.clone();
315+ let to = to.as_atom().ok_or(TTanks::new())?.clone();
312
316
313 if from > to {
317 if from > to {
314− return Err(Tanks::new());
318+ return Err(TTanks::new());
315 }
319 }
316
320
317 let mut tmp = Vec::new();
321 let mut tmp = Vec::new();
@@ -325,10 +329,10 @@ static GULF: Jet = |_ctx, n| {
325};
329};
326
330
327static INTO: Jet = |_ctx, n| {
331static INTO: Jet = |_ctx, n| {
328− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
332+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
329− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
333+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
330
334
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();
332
336
333 match b_iter.len() {
337 match b_iter.len() {
334 0 => Ok(cell(&c, &a)),
338 0 => Ok(cell(&c, &a)),
@@ -358,7 +362,7 @@ static INTO: Jet = |_ctx, n| {
358};
362};
359
363
360static JOIN: Jet = |_ctx, n| {
364static 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())?;
362 Ok(Noun::list_refs(
366 Ok(Noun::list_refs(
363 list.list_iter()
367 list.list_iter()
364 .intersperse(sep)
368 .intersperse(sep)
@@ -376,7 +380,7 @@ static LENT: Jet = |_ctx, n| {
376};
380};
377
381
378static LEVY: Jet = |ctx, n| {
382static 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())?;
380 if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
384 if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
381 .iter()
385 .iter()
382 .all(|x| x.is_y())
386 .all(|x| x.is_y())
@@ -388,7 +392,7 @@ static LEVY: Jet = |ctx, n| {
388};
392};
389
393
390static LIEN: Jet = |ctx, n| {
394static 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())?;
392 if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
396 if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
393 .iter()
397 .iter()
394 .any(|x| x.is_y())
398 .any(|x| x.is_y())
@@ -400,7 +404,7 @@ static LIEN: Jet = |ctx, n| {
400};
404};
401
405
402static MURN: Jet = |ctx, n| {
406static 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())?;
404
408
405 Ok(Noun::list_refs(
409 Ok(Noun::list_refs(
406 traverse_iter_result(
410 traverse_iter_result(
@@ -413,7 +417,7 @@ static MURN: Jet = |ctx, n| {
413};
417};
414
418
415static REAP: Jet = |_ctx, n| {
419static 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())?;
417
421
418 Ok(Noun::list_refs(repeat_n(
422 Ok(Noun::list_refs(repeat_n(
419 b.clone(),
423 b.clone(),
@@ -421,17 +425,17 @@ static REAP: Jet = |_ctx, n| {
421 )))
425 )))
422};
426};
423
427
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();
425
429
426static REEL: Jet = |ctx, n| {
430static 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())?;
428
432
429 list.list_iter().collect::<Vec<_>>().iter().rfold(
433 list.list_iter().collect::<Vec<_>>().iter().rfold(
430 Ok(gate
434 Ok(gate
431 .gate_sample()
435 .gate_sample()
432− .ok_or(Tanks::new())?
436+ .ok_or(TTanks::new())?
433 .as_cell()
437 .as_cell()
434− .ok_or(Tanks::new())?
438+ .ok_or(TTanks::new())?
435 .1
439 .1
436 .clone()),
440 .clone()),
437 |acc, next| {
441 |acc, next| {
@@ -442,15 +446,15 @@ static REEL: Jet = |ctx, n| {
442};
446};
443
447
444static ROLL: Jet = |ctx, n| {
448static 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())?;
446
450
447 list.list_iter().fold(
451 list.list_iter().fold(
448 Ok(gate
452 Ok(gate
449 .clone()
453 .clone()
450 .gate_sample()
454 .gate_sample()
451− .ok_or(Tanks::new())?
455+ .ok_or(TTanks::new())?
452 .as_cell()
456 .as_cell()
453− .ok_or(Tanks::new())?
457+ .ok_or(TTanks::new())?
454 .1
458 .1
455 .clone()),
459 .clone()),
456 |acc, next| {
460 |acc, next| {
@@ -461,7 +465,7 @@ static ROLL: Jet = |ctx, n| {
461};
465};
462
466
463static SCAG: Jet = |_ctx, n| {
467static 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())?;
465
469
466 Ok(Noun::list_refs(
470 Ok(Noun::list_refs(
467 b.list_iter()
471 b.list_iter()
@@ -474,7 +478,7 @@ static SCAG: Jet = |_ctx, n| {
474};
478};
475
479
476static SKID: Jet = |ctx, n| {
480static 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())?;
478
482
479 let slammed_n = traverse_iter_result(
483 let slammed_n = traverse_iter_result(
480 list.list_iter()
484 list.list_iter()
@@ -489,7 +493,7 @@ static SKID: Jet = |ctx, n| {
489};
493};
490
494
491static SKIM: Jet = |ctx, n| {
495static 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())?;
493
497
494 Ok(Noun::list_refs(
498 Ok(Noun::list_refs(
495 traverse_iter_result(
499 traverse_iter_result(
@@ -503,7 +507,7 @@ static SKIM: Jet = |ctx, n| {
503};
507};
504
508
505static SKIP: Jet = |ctx, n| {
509static 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())?;
507
511
508 Ok(Noun::list_refs(
512 Ok(Noun::list_refs(
509 traverse_iter_result(
513 traverse_iter_result(
@@ -517,9 +521,9 @@ static SKIP: Jet = |ctx, n| {
517};
521};
518
522
519static SLAG: Jet = |ctx, n| {
523static 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())?;
521
525
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();
523
527
524 match a_iter.len() {
528 match a_iter.len() {
525 0 => Ok(list.clone()),
529 0 => Ok(list.clone()),
@@ -536,12 +540,12 @@ static SLAG: Jet = |ctx, n| {
536};
540};
537
541
538static SNAG: Jet = |_ctx, n| {
542static 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())?;
540
544
541 list.list_iter()
545 list.list_iter()
542 .nth(a.as_u32().unwrap() as usize)
546 .nth(a.as_u32().unwrap() as usize)
543 .cloned()
547 .cloned()
544− .ok_or(Tanks::new())
548+ .ok_or(TTanks::new())
545};
549};
546
550
547static SNIP: Jet = |_ctx, n| {
551static SNIP: Jet = |_ctx, n| {
@@ -558,7 +562,7 @@ static SNIP: Jet = |_ctx, n| {
558};
562};
559
563
560static SNOC: Jet = |_ctx, n| {
564static 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())?;
562
566
563 Ok(Noun::list_refs(
567 Ok(Noun::list_refs(
564 list.list_iter()
568 list.list_iter()
@@ -589,15 +593,15 @@ static SNOC: Jet = |_ctx, n| {
589// };
593// };
590
594
591static SPIN: Jet = |ctx, n| {
595static SPIN: Jet = |ctx, n| {
592− let (list, b) = n.as_cell().ok_or(Tanks::new())?;
596+ let (list, b) = n.as_cell().ok_or(TTanks::new())?;
593− let (acc, gate) = b.as_cell().ok_or(Tanks::new())?;
597+ let (acc, gate) = b.as_cell().ok_or(TTanks::new())?;
594
598
595 let mut res = Vec::new();
599 let mut res = Vec::new();
596 let mut acc = acc.clone();
600 let mut acc = acc.clone();
597
601
598 for n in list.list_iter() {
602 for n in list.list_iter() {
599 let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
603 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())?;
601 acc = new_acc.clone();
605 acc = new_acc.clone();
602 res.push(el.clone());
606 res.push(el.clone());
603 }
607 }
@@ -606,20 +610,20 @@ static SPIN: Jet = |ctx, n| {
606};
610};
607
611
608static SPUN: Jet = |ctx, n| {
612static 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())?;
610
614
611 let mut res = Vec::new();
615 let mut res = Vec::new();
612 let mut acc = gate
616 let mut acc = gate
613 .gate_sample()
617 .gate_sample()
614− .ok_or(Tanks::new())?
618+ .ok_or(TTanks::new())?
615 .as_cell()
619 .as_cell()
616− .ok_or(Tanks::new())?
620+ .ok_or(TTanks::new())?
617 .1
621 .1
618 .clone();
622 .clone();
619
623
620 for n in list.list_iter() {
624 for n in list.list_iter() {
621 let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
625 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())?;
623 acc = new_acc.clone();
627 acc = new_acc.clone();
624 res.push(el.clone());
628 res.push(el.clone());
625 }
629 }
@@ -628,7 +632,7 @@ static SPUN: Jet = |ctx, n| {
628};
632};
629
633
630static TURN: Jet = |ctx, n| {
634static 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())?;
632 Ok(Noun::list_refs(
636 Ok(Noun::list_refs(
633 traverse_iter_result(list.list_iter().map(|x| slam_pulled_gate(ctx, gate, x)))?
637 traverse_iter_result(list.list_iter().map(|x| slam_pulled_gate(ctx, gate, x)))?
634 .iter()
638 .iter()
@@ -637,7 +641,7 @@ static TURN: Jet = |ctx, n| {
637};
641};
638
642
639static WELD: Jet = |_ctx, n| {
643static 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())?;
641
645
642 Ok(Noun::list_refs(
646 Ok(Noun::list_refs(
643 a.list_iter()
647 a.list_iter()
@@ -670,18 +674,20 @@ static BEX: Jet = |ctx, n| {
670};
674};
671
675
672static END: Jet = |ctx, n| {
676static 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())?;
674 let bite = a.as_bite();
678 let bite = a.as_bite();
675
679
676 let bits = bite.bits();
680 let bits = bite.bits();
677
681
678 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
682 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
679
683
684+ Ok(Rc::new(Noun::Atom(
680− Ok(Rc::new(Noun::Atom(mask & b.as_atom().ok_or(Tanks::new())?)))
685+ mask & b.as_atom().ok_or(TTanks::new())?,
686+ )))
681};
687};
682
688
683static CAN: Jet = |ctx, n| {
689static 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())?;
685 let bloq = a.as_u32().unwrap();
691 let bloq = a.as_u32().unwrap();
686 let bloq_ = 2u32.pow(bloq);
692 let bloq_ = 2u32.pow(bloq);
687
693
@@ -696,16 +702,16 @@ static CAN: Jet = |ctx, n| {
696 Some((acc? << bits) | (mask & q.as_atom()?))
702 Some((acc? << bits) | (mask & q.as_atom()?))
697 },
703 },
698 );
704 );
699− Ok(Rc::new(Noun::Atom(atom.ok_or(Tanks::new())?)))
705+ Ok(Rc::new(Noun::Atom(atom.ok_or(TTanks::new())?)))
700};
706};
701
707
702static CAT: Jet = |_ctx, n| {
708static CAT: Jet = |_ctx, n| {
703− let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
709+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
704− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
710+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
705
711
706− let bloq = bloq.as_u32().ok_or(Tanks::new())?;
712+ let bloq = bloq.as_u32().ok_or(TTanks::new())?;
707− let b = b.as_atom().ok_or(Tanks::new())?;
713+ let b = b.as_atom().ok_or(TTanks::new())?;
708− let c = c.as_atom().ok_or(Tanks::new())?;
714+ let c = c.as_atom().ok_or(TTanks::new())?;
709
715
710 Ok(Rc::new(Noun::Atom(
716 Ok(Rc::new(Noun::Atom(
711 (c << (met(bloq, &b) * 2u32.pow(bloq))) | b,
717 (c << (met(bloq, &b) * 2u32.pow(bloq))) | b,
@@ -713,8 +719,8 @@ static CAT: Jet = |_ctx, n| {
713};
719};
714
720
715static MET: Jet = |_ctx, n| {
721static MET: Jet = |_ctx, n| {
716− let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
722+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
717− let b: Atom = b.as_atom().ok_or(Tanks::new())?.clone();
723+ let b: Atom = b.as_atom().ok_or(TTanks::new())?.clone();
718 let bloq = bloq.as_u32().unwrap();
724 let bloq = bloq.as_u32().unwrap();
719
725
720 Ok(Rc::new(Noun::from_u32(met(bloq, &b))))
726 Ok(Rc::new(Noun::from_u32(met(bloq, &b))))
@@ -725,28 +731,28 @@ fn met(bloq: u32, a: &Atom) -> u32 {
725}
731}
726
732
727static CUT: Jet = |ctx, n| {
733static CUT: Jet = |ctx, n| {
728− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
734+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
729− let (b, d) = b.as_cell().ok_or(Tanks::new())?;
735+ let (b, d) = b.as_cell().ok_or(TTanks::new())?;
730− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
736+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
731
737
732 let bits = 2u32.pow(a.as_u32().unwrap());
738 let bits = 2u32.pow(a.as_u32().unwrap());
733
739
734 let mask = (&ctx.big_uints.one << (bits * c.as_u32().unwrap())) - &ctx.big_uints.one;
740 let mask = (&ctx.big_uints.one << (bits * c.as_u32().unwrap())) - &ctx.big_uints.one;
735
741
736 Ok(Rc::new(Noun::Atom(
742 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,
738 )))
744 )))
739};
745};
740
746
741static FIL: Jet = |ctx, n| {
747static FIL: Jet = |ctx, n| {
742− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
748+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
743− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
749+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
744
750
745 let bits = 2u32.pow(a.as_u32().unwrap());
751 let bits = 2u32.pow(a.as_u32().unwrap());
746
752
747 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
753 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
748
754
749− let src = c.as_atom().ok_or(Tanks::new())? & mask;
755+ let src = c.as_atom().ok_or(TTanks::new())? & mask;
750
756
751 let mut target = ctx.big_uints.zero.clone();
757 let mut target = ctx.big_uints.zero.clone();
752
758
@@ -758,30 +764,30 @@ static FIL: Jet = |ctx, n| {
758};
764};
759
765
760static LSH: Jet = |_ctx, n| {
766static 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())?;
762 let a = a.as_bite();
768 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())?;
764
770
765 Ok(Rc::new(Noun::Atom(b << a.bits())))
771 Ok(Rc::new(Noun::Atom(b << a.bits())))
766};
772};
767
773
768static RSH: Jet = |_ctx, n| {
774static 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())?;
770 let a = a.as_bite();
776 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())?;
772
778
773 Ok(Rc::new(Noun::Atom(b >> a.bits())))
779 Ok(Rc::new(Noun::Atom(b >> a.bits())))
774};
780};
775
781
776−static RAP: Jet = |ctx, n| {
782+pub static RAP: Jet = |ctx, n| {
777− let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
783+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
778 let bloq = bloq.as_u32().unwrap();
784 let bloq = bloq.as_u32().unwrap();
779 let bits = 2u32.pow(bloq);
785 let bits = 2u32.pow(bloq);
780
786
781 let mut target = ctx.big_uints.zero.clone();
787 let mut target = ctx.big_uints.zero.clone();
782
788
783 for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
789 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())?;
785 if el != &ctx.big_uints.zero {
791 if el != &ctx.big_uints.zero {
786 target = (target << (bits * met(bloq, &el))) | el;
792 target = (target << (bits * met(bloq, &el))) | el;
787 }
793 }
@@ -791,7 +797,7 @@ static RAP: Jet = |ctx, n| {
791};
797};
792
798
793static REP: Jet = |ctx, n| {
799static 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())?;
795 let bite = bite.as_bite();
801 let bite = bite.as_bite();
796
802
797 let bits = bite.bits();
803 let bits = bite.bits();
@@ -800,18 +806,18 @@ static REP: Jet = |ctx, n| {
800 let mut target = ctx.big_uints.zero.clone();
806 let mut target = ctx.big_uints.zero.clone();
801
807
802 for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
808 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);
804 }
810 }
805
811
806 Ok(Rc::new(Noun::Atom(target)))
812 Ok(Rc::new(Noun::Atom(target)))
807};
813};
808
814
809static REV: Jet = |ctx, n| {
815static REV: Jet = |ctx, n| {
810− let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
816+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
811− let (len, dat) = b.as_cell().ok_or(Tanks::new())?;
817+ let (len, dat) = b.as_cell().ok_or(TTanks::new())?;
812 let bloq = bloq.as_u32().unwrap();
818 let bloq = bloq.as_u32().unwrap();
813 let len = len.as_u32().unwrap();
819 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();
815
821
816 let bits = 2u32.pow(bloq);
822 let bits = 2u32.pow(bloq);
817 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
823 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -827,9 +833,9 @@ static REV: Jet = |ctx, n| {
827};
833};
828
834
829static RIP: Jet = |ctx, n| {
835static 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())?;
831 let bite = bite.as_bite();
837 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();
833
839
834 let bits = bite.bits();
840 let bits = bite.bits();
835 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
841 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -845,11 +851,11 @@ static RIP: Jet = |ctx, n| {
845};
851};
846
852
847static RUN: Jet = |ctx, n| {
853static RUN: Jet = |ctx, n| {
848− let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
854+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
849− let (b, gate) = b.as_cell().ok_or(Tanks::new())?;
855+ let (b, gate) = b.as_cell().ok_or(TTanks::new())?;
850
856
851 let bite = bite.as_bite();
857 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();
853
859
854 let bits = bite.bits();
860 let bits = bite.bits();
855 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
861 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -860,7 +866,7 @@ static RUN: Jet = |ctx, n| {
860 target = (target << bits)
866 target = (target << bits)
861 | ((*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
867 | ((*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
862 .as_atom()
868 .as_atom()
863− .ok_or(Tanks::new())?
869+ .ok_or(TTanks::new())?
864 & &mask);
870 & &mask);
865 b = b >> bits;
871 b = b >> bits;
866 }
872 }
@@ -869,11 +875,11 @@ static RUN: Jet = |ctx, n| {
869};
875};
870
876
871static RUT: Jet = |ctx, n| {
877static RUT: Jet = |ctx, n| {
872− let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
878+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
873− let (b, gate) = b.as_cell().ok_or(Tanks::new())?;
879+ let (b, gate) = b.as_cell().ok_or(TTanks::new())?;
874
880
875 let bite = bite.as_bite();
881 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();
877
883
878 let bits = bite.bits();
884 let bits = bite.bits();
879 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
885 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -884,7 +890,7 @@ static RUT: Jet = |ctx, n| {
884 target.push(
890 target.push(
885 (*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
891 (*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
886 .as_atom()
892 .as_atom()
887− .ok_or(Tanks::new())?
893+ .ok_or(TTanks::new())?
888 & &mask,
894 & &mask,
889 );
895 );
890 b = b >> bits;
896 b = b >> bits;
@@ -894,12 +900,12 @@ static RUT: Jet = |ctx, n| {
894};
900};
895
901
896static SEW: Jet = |ctx, n| {
902static SEW: Jet = |ctx, n| {
897− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
903+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
898− let (b, recipient) = b.as_cell().ok_or(Tanks::new())?;
904+ let (b, recipient) = b.as_cell().ok_or(TTanks::new())?;
899− let (sew_start, c) = b.as_cell().ok_or(Tanks::new())?;
905+ let (sew_start, c) = b.as_cell().ok_or(TTanks::new())?;
900− let (number_of_blocks, donor) = c.as_cell().ok_or(Tanks::new())?;
906+ let (number_of_blocks, donor) = c.as_cell().ok_or(TTanks::new())?;
901− let recipient = recipient.as_atom().ok_or(Tanks::new())?;
907+ let recipient = recipient.as_atom().ok_or(TTanks::new())?;
902− let donor = donor.as_atom().ok_or(Tanks::new())?;
908+ let donor = donor.as_atom().ok_or(TTanks::new())?;
903
909
904 let bloq = a.as_u32().unwrap();
910 let bloq = a.as_u32().unwrap();
905 let bits = 2u32.pow(bloq);
911 let bits = 2u32.pow(bloq);
@@ -915,12 +921,12 @@ static SEW: Jet = |ctx, n| {
915};
921};
916
922
917static SWP: Jet = |ctx, n| {
923static 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())?;
919 let bloq = bloq.as_u32().unwrap();
925 let bloq = bloq.as_u32().unwrap();
920 let bits = 2u32.pow(bloq);
926 let bits = 2u32.pow(bloq);
921 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
927 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
922
928
923− let mut source = b.as_atom().ok_or(Tanks::new())?.clone();
929+ let mut source = b.as_atom().ok_or(TTanks::new())?.clone();
924 let mut target = ctx.big_uints.zero.clone();
930 let mut target = ctx.big_uints.zero.clone();
925
931
926 while source > ctx.big_uints.zero {
932 while source > ctx.big_uints.zero {
@@ -932,7 +938,7 @@ static SWP: Jet = |ctx, n| {
932};
938};
933
939
934static XEB: Jet = |_ctx, n| {
940static 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();
936
942
937 let mut c = 0;
943 let mut c = 0;
938
944
@@ -949,22 +955,22 @@ static DIS: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a & b);
949static MIX: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a ^ b);
955static MIX: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a ^ b);
950
956
951static NOT: Jet = |ctx, n| {
957static NOT: Jet = |ctx, n| {
952− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
958+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
953− let (b, c) = b.as_cell().ok_or(Tanks::new())?;
959+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
954
960
955 let bloq = a.as_u32().unwrap();
961 let bloq = a.as_u32().unwrap();
956 let bits = 2u32.pow(bloq);
962 let bits = 2u32.pow(bloq);
957 let mask = (&ctx.big_uints.one << (bits * b.as_u32().unwrap())) - &ctx.big_uints.one;
963 let mask = (&ctx.big_uints.one << (bits * b.as_u32().unwrap())) - &ctx.big_uints.one;
958
964
959− let target = c.as_atom().ok_or(Tanks::new())? ^ &mask;
965+ let target = c.as_atom().ok_or(TTanks::new())? ^ &mask;
960
966
961 Ok(Rc::new(Noun::Atom(target)))
967 Ok(Rc::new(Noun::Atom(target)))
962};
968};
963
969
964static LAST: Jet = |_ctx, n| {
970static LAST: Jet = |_ctx, n| {
965− let (a, b) = n.as_cell().ok_or(Tanks::new())?;
971+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
966− let a = a.as_hair().ok_or(Tanks::new())?;
972+ let a = a.as_hair().ok_or(TTanks::new())?;
967− let b = b.as_hair().ok_or(Tanks::new())?;
973+ let b = b.as_hair().ok_or(TTanks::new())?;
968 Ok(Noun::from_hair(last(&a, &b)))
974 Ok(Noun::from_hair(last(&a, &b)))
969};
975};
970
976
@@ -985,18 +991,18 @@ fn last<'a>(a: &'a Hair, b: &'a Hair) -> &'a Hair {
985}
991}
986
992
987static TRIP: Jet = |_ctx, n| {
993static TRIP: Jet = |_ctx, n| {
988− let a = n.as_atom().ok_or(Tanks::new())?;
994+ let a = n.as_atom().ok_or(TTanks::new())?;
989 Ok(Noun::list(
995 Ok(Noun::list(
990 a.to_bytes_le().iter().map(|b| Noun::from_u32(*b as u32)),
996 a.to_bytes_le().iter().map(|b| Noun::from_u32(*b as u32)),
991 ))
997 ))
992};
998};
993
999
994static MUK: Jet = |_ctx, n| {
1000static MUK: Jet = |_ctx, n| {
995− let (seed, len) = n.as_cell().ok_or(Tanks::new())?;
1001+ let (seed, len) = n.as_cell().ok_or(TTanks::new())?;
996− let (len, key) = len.as_cell().ok_or(Tanks::new())?;
1002+ let (len, key) = len.as_cell().ok_or(TTanks::new())?;
997− let seed = seed.as_u32().ok_or(Tanks::new())?;
1003+ let seed = seed.as_u32().ok_or(TTanks::new())?;
998− let len = len.as_u32().ok_or(Tanks::new())?;
1004+ let len = len.as_u32().ok_or(TTanks::new())?;
999− let key = key.as_atom().ok_or(Tanks::new())?;
1005+ let key = key.as_atom().ok_or(TTanks::new())?;
1000
1006
1001 Ok(Rc::new(Noun::from_u32(muk(seed, len, key))))
1007 Ok(Rc::new(Noun::from_u32(muk(seed, len, key))))
1002};
1008};
nock/src/lib.rs+1−34
@@ -4,7 +4,7 @@
4use core::str;
4use core::str;
5use std::{borrow::Borrow, rc::Rc};
5use std::{borrow::Borrow, rc::Rc};
6
6
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};
8use noun::{cell, Noun};
8use noun::{cell, Noun};
9pub mod cue;
9pub mod cue;
10pub mod interpreter;
10pub mod interpreter;
@@ -13,36 +13,3 @@ mod jets;
13pub mod noun;
13pub mod noun;
14
14
15pub type Vase = (Rc<Noun>, Rc<Noun>);
15pub 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 @@
1use clap::{command, error::Result, Parser, Subcommand};
1use clap::{command, error::Result, Parser, Subcommand};
2use core::str;
2use core::str;
3−use nock::interpreter::{eval_pulled_gate, slam_pulled_gate, tar, InterpreterContext, Tanks};
3+use nock::interpreter::{ram_ttanks, slam_pulled_gate, tar, InterpreterContext, TTanks};
4−use nock::wash;
5use nock::{
4use nock::{
6 cue::cue_bytes,
5 cue::cue_bytes,
7 interpreter::{generate_interpreter_context, slam},
6 interpreter::{generate_interpreter_context, slam},
@@ -9,7 +8,6 @@ use nock::{
9 noun::{cell, Atom, Noun},
8 noun::{cell, Atom, Noun},
10};
9};
11use spinoff::Spinner;
10use spinoff::Spinner;
12−use std::borrow::Borrow;
13use std::cell::LazyCell;
11use std::cell::LazyCell;
14use std::{
12use std::{
15 fs::File,
13 fs::File,
@@ -91,7 +89,7 @@ fn main() -> Result<(), std::io::Error> {
91 spinner.fail("Gate execution failed");
89 spinner.fail("Gate execution failed");
92
90
93 let mut spinner = new_spinner(String::from("Building trace"));
91 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);
95 spinner.success("Trace built");
93 spinner.success("Trace built");
96 println!("{trace}");
94 println!("{trace}");
97 exit(1);
95 exit(1);
@@ -182,13 +180,7 @@ fn compile_to_nock(
182 &urbit,
180 &urbit,
183 &cell(&Rc::new(Noun::from_bytes(b"hoon")), &ctx.nouns.sig),
181 &cell(&Rc::new(Noun::from_bytes(b"hoon")), &ctx.nouns.sig),
184 );
182 );
185− let hoon = or_wash_fail(
186− ctx,
187− urbit,
188− hoon,
189− spinner,
190− "Failed to read Hoon standard library",
183+ let hoon = or_wash_fail(ctx, hoon, spinner, "Failed to read Hoon standard library");
191− );
192 let (hoon_type, hoon) = hoon.as_cell().unwrap();
184 let (hoon_type, hoon) = hoon.as_cell().unwrap();
193
185
194 spinner.update_text(format!("Compiling {root:#?}"));
186 spinner.update_text(format!("Compiling {root:#?}"));
@@ -206,7 +198,7 @@ fn compile_to_nock(
206 ),
198 ),
207 ),
199 ),
208 );
200 );
209− let target = or_wash_fail(ctx, urbit, target, spinner, "Compilation failed");
201+ let target = or_wash_fail(ctx, target, spinner, "Compilation failed");
210
202
211 let (target_type, target_nock) = target.as_cell().unwrap();
203 let (target_type, target_nock) = target.as_cell().unwrap();
212
204
@@ -222,7 +214,7 @@ fn compile_to_nock(
222 );
214 );
223 let combined_nock = cell(
215 let combined_nock = cell(
224 target_type,
216 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"),
226 );
218 );
227 Ok(combined_nock)
219 Ok(combined_nock)
228}
220}
@@ -244,8 +236,7 @@ fn read_nock_or_compile(
244
236
245fn or_wash_fail(
237fn or_wash_fail(
246 ctx: &mut InterpreterContext,
238 ctx: &mut InterpreterContext,
247− urbit: &Rc<Noun>,
248− source: Result<Rc<Noun>, Tanks>,
239+ source: Result<Rc<Noun>, TTanks>,
249 spinner: &mut Spinner,
240 spinner: &mut Spinner,
250 fail_err: &str,
241 fail_err: &str,
251) -> Rc<Noun> {
242) -> Rc<Noun> {
@@ -253,7 +244,7 @@ fn or_wash_fail(
253 Ok(source) => source,
244 Ok(source) => source,
254 Err(tanks) => {
245 Err(tanks) => {
255 spinner.fail(fail_err);
246 spinner.fail(fail_err);
256− let washed_tanks = wash(ctx, urbit, tanks);
247+ let washed_tanks = ram_ttanks(ctx, tanks);
257 eprintln!("{}", washed_tanks);
248 eprintln!("{}", washed_tanks);
258 exit(1)
249 exit(1)
259 }
250 }