mirror of
https://github.com/urbit/ares.git
synced 2024-12-24 05:44:36 +03:00
Fix bug and call +zing on stack trace
This commit is contained in:
parent
463cd31eaf
commit
46918bcbf9
@ -24,7 +24,7 @@ pub mod util {
|
||||
use crate::jets;
|
||||
use crate::jets::JetErr;
|
||||
use crate::mem::NockStack;
|
||||
use crate::noun::{Noun, Cell, D};
|
||||
use crate::noun::{Cell, Noun, D};
|
||||
use std::result::Result;
|
||||
|
||||
pub fn lent(tape: Noun) -> Result<usize, JetErr> {
|
||||
@ -53,23 +53,23 @@ pub mod util {
|
||||
let (mut cell, mut memory) = (new_cell, new_memory);
|
||||
let mut res: Noun = D(0);
|
||||
let mut flag = false;
|
||||
|
||||
|
||||
loop {
|
||||
if list.raw_equals(D(0)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
let pair = list.as_cell()?;
|
||||
let mut sub_list = pair.head();
|
||||
|
||||
|
||||
loop {
|
||||
if sub_list.raw_equals(D(0)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
let elem = sub_list.as_cell()?;
|
||||
let head = elem.head();
|
||||
|
||||
|
||||
if flag {
|
||||
(new_cell, new_memory) = Cell::new_raw_mut(stack);
|
||||
(*memory).tail = new_cell.as_noun();
|
||||
@ -80,15 +80,15 @@ pub mod util {
|
||||
flag = true;
|
||||
}
|
||||
(*memory).head = head;
|
||||
|
||||
|
||||
sub_list = elem.tail();
|
||||
}
|
||||
|
||||
|
||||
list = pair.tail();
|
||||
}
|
||||
|
||||
|
||||
if flag {
|
||||
(*new_memory).tail = D(0);
|
||||
(*memory).tail = D(0);
|
||||
}
|
||||
Ok(res)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use crate::interpreter::{inc, interpret, Error};
|
||||
use crate::jets::cold::Cold;
|
||||
use crate::jets::hot::Hot;
|
||||
use crate::jets::nock::util::mook;
|
||||
use crate::jets::text::util::lent;
|
||||
use crate::jets::text::util::*;
|
||||
use crate::jets::warm::Warm;
|
||||
use crate::mem::NockStack;
|
||||
use crate::mug::mug_u32;
|
||||
@ -263,11 +263,9 @@ fn slam(context: &mut Context, axis: u64, ovo: Noun) -> Result<Noun, Error> {
|
||||
interpret(&mut context.nock_context, sub, fol)
|
||||
}
|
||||
|
||||
fn goof(context: &mut Context, trace: Noun) -> Noun {
|
||||
// XX: trace is a $tang with at least one $tank, which we pick off the top.
|
||||
// Actual input to +mook should be (roll trace weld) ( or (zing trace)).
|
||||
let head = trace.cell().unwrap().head();
|
||||
let tone = Cell::new(&mut context.nock_context.stack, D(2), head);
|
||||
fn goof(context: &mut Context, traces: Noun) -> Noun {
|
||||
let trace = zing(&mut context.nock_context.stack, traces).unwrap();
|
||||
let tone = Cell::new(&mut context.nock_context.stack, D(2), trace);
|
||||
let tang = mook(&mut context.nock_context, tone, false)
|
||||
.expect("serf: goof: +mook crashed on bail")
|
||||
.tail();
|
||||
|
Loading…
Reference in New Issue
Block a user