@@ -89,7 +89,7 @@ fn tis(ctx: &InterpreterContext, lhs: Rc<Noun>, rhs: Rc<Noun>) -> Rc<Noun> {
92−fn fas(ctx: &InterpreterContext, addr: Atom, noun: Rc<Noun>) -> Option<Rc<Noun>> {
92+fn fas(ctx: &InterpreterContext, addr: Atom, noun: &Noun) -> Option<Rc<Noun>> {
93 let mut addr_iter = addr.iter_u32_digits();
93 let mut addr_iter = addr.iter_u32_digits();
95 match addr_iter.len() {
95 match addr_iter.len() {
@@ -103,24 +103,24 @@ fn fas(ctx: &InterpreterContext, addr: Atom, noun: Rc<Noun>) -> Option<Rc<Noun>>
112−fn fas_u32(addr: u32, noun: Rc<Noun>) -> Option<Rc<Noun>> {
112+fn fas_u32(addr: u32, noun: &Noun) -> Option<Rc<Noun>> {
113 match addr {
113 match addr {
114 0 => None,
114 0 => None,
115− 1 => Some(noun),
115+ 1 => Some(Rc::new(noun.clone())),
116− n => match (*noun).clone() {
116+ n => match noun {
117 Noun::Atom(_) => None,
117 Noun::Atom(_) => None,
118 Noun::Cell { p, q, .. } => match n {
118 Noun::Cell { p, q, .. } => match n {
119− 2 => Some(p),
119+ 2 => Some(p.clone()),
120− 3 => Some(q),
120+ 3 => Some(q.clone()),
122− let rest = fas_u32(n >> 1, cell(p, q))?;
122+ let rest = fas_u32(n >> 1, &naked_cell(p.clone(), q.clone()))?;
123− fas_u32(if (n & 1) == 1 { 3 } else { 2 }, rest)
123+ fas_u32(if (n & 1) == 1 { 3 } else { 2 }, &rest)
@@ -134,9 +134,9 @@ fn hax_u32(addr: u32, new_value: Rc<Noun>, target: Rc<Noun>) -> Option<Rc<Noun>>
134 _ => hax_u32(
134 _ => hax_u32(
135 addr >> 1,
135 addr >> 1,
136 if (addr & 1) == 1 {
136 if (addr & 1) == 1 {
137− cell(fas_u32(addr - 1, target.clone())?, new_value)
137+ cell(fas_u32(addr - 1, &target)?, new_value)
139− cell(new_value, fas_u32(addr + 1, target.clone())?)
139+ cell(new_value, fas_u32(addr + 1, &target)?)
@@ -158,27 +158,16 @@ fn hax(
159 &addr >> 1u32,
159 &addr >> 1u32,
160 if (&addr & &ctx.big_uints.one) == ctx.big_uints.one {
160 if (&addr & &ctx.big_uints.one) == ctx.big_uints.one {
162− fas(ctx, addr - &ctx.big_uints.one, target.clone())?,
161+ cell(fas(ctx, addr - &ctx.big_uints.one, &target)?, new_value)
168− fas(ctx, addr + &ctx.big_uints.one, target.clone())?,
163+ cell(new_value, fas(ctx, addr + &ctx.big_uints.one, &target)?)
177− ctx: &InterpreterContext,
170+fn tar_u32(ctx: &InterpreterContext, subj: &Noun, op: u32, formula: Rc<Noun>) -> Option<Rc<Noun>> {
181−) -> Option<Rc<Noun>> {
182 match op {
171 match op {
184 let b = formula.as_atom()?.clone();
173 let b = formula.as_atom()?.clone();
@@ -203,53 +192,62 @@ fn tar_u32(
203 let (hash, sample_1, sample_2) = subj.hash_double_gate();
192 let (hash, sample_1, sample_2) = subj.hash_double_gate();
204 match ctx.double_jets.get(&hash) {
193 match ctx.double_jets.get(&hash) {
205 Some(f) => f(ctx, sample_1, sample_2),
194 Some(f) => f(ctx, sample_1, sample_2),
206− None => tar(ctx, tar(ctx, subj.clone(), b)?, tar(ctx, subj, c)?),
196+ let foo = tar(ctx, subj, &b)?;
197+ let bar = tar(ctx, subj, &c)?;
198+ tar(ctx, &foo, &bar)
211− _ => tar(ctx, tar(ctx, subj.clone(), b)?, tar(ctx, subj, c)?),
205+ let foo = tar(ctx, &subj, &b)?;
206+ let bar = tar(ctx, &subj, &c)?;
207+ tar(ctx, &foo, &bar)
214− 3 => Some(wut(ctx, tar(ctx, subj, formula)?)),
211+ 3 => Some(wut(ctx, tar(ctx, subj, &formula)?)),
215− 4 => Some(Rc::new(lus(tar(ctx, subj, formula)?)?)),
212+ 4 => Some(Rc::new(lus(tar(ctx, subj, &formula)?)?)),
217 let (b, c) = formula.as_cell()?;
214 let (b, c) = formula.as_cell()?;
215+ let foo = tar(ctx, &subj, &b)?;
218− Some(tis(ctx, tar(ctx, subj.clone(), b)?, tar(ctx, subj, c)?))
216+ Some(tis(ctx, foo, tar(ctx, subj, &c)?))
221 let (b, c) = formula.as_cell()?;
219 let (b, c) = formula.as_cell()?;
222 let (c, d) = c.as_cell()?;
220 let (c, d) = c.as_cell()?;
224− tar(
222+ let foo = tar_u32(
226− subj.clone(),
224+ &cell(c, d),
229− cell(c, d),
228+ &ctx.nouns.two_three,
233− ctx.nouns.two_three.clone(),
235− tar_u32(ctx, subj, 4, cell(ctx.nouns.four.clone(), b))?,
230+ tar_u32(ctx, subj, 4, cell(ctx.nouns.four.clone(), b))?,
234+ tar(ctx, &subj, &foo)
241 let (b, c) = formula.as_cell()?;
237 let (b, c) = formula.as_cell()?;
242− tar(ctx, tar(ctx, subj, b)?, c)
238+ let foo = tar(ctx, subj, &b)?;
245 let (b, c) = formula.as_cell()?;
242 let (b, c) = formula.as_cell()?;
246− tar(ctx, cell(tar(ctx, subj.clone(), b)?, subj), c)
243+ tar(ctx, &cell(tar(ctx, &subj, &b)?, Rc::new(subj.clone())), &c)
249 let (b, c) = formula.as_cell()?;
246 let (b, c) = formula.as_cell()?;
247+ let foo = tar(ctx, &subj, &c)?;
252− tar(ctx, subj, c)?,
250+ &foo,
254 cell(ctx.nouns.sig_one.clone(), cell(ctx.nouns.sig.clone(), b)),
252 cell(ctx.nouns.sig_one.clone(), cell(ctx.nouns.sig.clone(), b)),
@@ -259,21 +257,16 @@ fn tar_u32(
259 let (b, c) = b.as_cell()?;
257 let (b, c) = b.as_cell()?;
260 let b = b.as_atom()?;
258 let b = b.as_atom()?;
265− tar(ctx, subj.clone(), c)?,
266− tar(ctx, subj, d)?,
260+ hax(ctx, b.clone(), tar(ctx, subj, &c)?, tar(ctx, subj, &d)?)
270 let (b, d) = formula.as_cell()?;
263 let (b, d) = formula.as_cell()?;
271 // println!("{b}");
264 // println!("{b}");
272 match (*b).clone() {
265 match (*b).clone() {
273− Noun::Atom(_) => tar(ctx, subj, d),
266+ Noun::Atom(_) => tar(ctx, subj, &d),
274 Noun::Cell { q: c, .. } => tar_u32(
267 Noun::Cell { q: c, .. } => tar_u32(
276− cell(tar(ctx, subj.clone(), c)?, tar(ctx, subj, d)?),
269+ &cell(tar(ctx, subj, &c)?, tar(ctx, subj, &d)?),
278 ctx.nouns.three.clone(),
271 ctx.nouns.three.clone(),
@@ -283,10 +276,10 @@ fn tar_u32(
286−pub fn tar(ctx: &InterpreterContext, subj: Rc<Noun>, formula: Rc<Noun>) -> Option<Rc<Noun>> {
279+pub fn tar(ctx: &InterpreterContext, subj: &Noun, formula: &Noun) -> Option<Rc<Noun>> {
287 let (op, formula) = formula.as_cell()?;
280 let (op, formula) = formula.as_cell()?;
288 match *op {
281 match *op {
289− Noun::Cell { .. } => Some(cell(tar(ctx, subj.clone(), op)?, tar(ctx, subj, formula)?)),
282+ Noun::Cell { .. } => Some(cell(tar(ctx, subj, &op)?, tar(ctx, subj, &formula)?)),
290 Noun::Atom(ref op) => {
283 Noun::Atom(ref op) => {
291 let mut op_iter = op.iter_u32_digits();
284 let mut op_iter = op.iter_u32_digits();
292 let op = match op_iter.len() {
285 let op = match op_iter.len() {
@@ -295,7 +288,7 @@ pub fn tar(ctx: &InterpreterContext, subj: Rc<Noun>, formula: Rc<Noun>) -> Optio
295 _ => None,
288 _ => None,
297 let op = op?;
290 let op = op?;
298− stacker::maybe_grow(32 * 1024, 1024 * 1024, || tar_u32(ctx, subj, op, formula))
291+ stacker::maybe_grow(32 * 1024, 1024 * 1024, || tar_u32(ctx, &subj, op, formula))
@@ -303,8 +296,8 @@ pub fn tar(ctx: &InterpreterContext, subj: Rc<Noun>, formula: Rc<Noun>) -> Optio
303pub fn eval_gate(ctx: &InterpreterContext, gate: Rc<Noun>) -> Option<Rc<Noun>> {
296pub fn eval_gate(ctx: &InterpreterContext, gate: Rc<Noun>) -> Option<Rc<Noun>> {
308 Rc::new(Noun::Atom(BigUint::new(vec![9]))),
301 Rc::new(Noun::Atom(BigUint::new(vec![9]))),
310 ctx.nouns.two.clone(),
303 ctx.nouns.two.clone(),