mirror of
https://github.com/urbit/ares.git
synced 2024-11-27 13:46:55 +03:00
Merge pull request #140 from urbit/as/mook
jets: fix `+mook` jet mismatches and simplify logic
This commit is contained in:
commit
d7173bf7ec
@ -1390,8 +1390,10 @@ mod hint {
|
|||||||
}
|
}
|
||||||
tas!(b"hela") => {
|
tas!(b"hela") => {
|
||||||
// XX: This only prints the trace down to the bottom of THIS
|
// XX: This only prints the trace down to the bottom of THIS
|
||||||
// interpret call. We'll need to recursively work down
|
// interpret call, making this neither a %nara nor a %hela
|
||||||
// frames to get the stack trace all the way to the root.
|
// hint, as Vere understands them. We'll need to
|
||||||
|
// recursively work down frames to get the stack trace all
|
||||||
|
// the way to the root.
|
||||||
let mean = unsafe { *(context.stack.local_noun_pointer(0)) };
|
let mean = unsafe { *(context.stack.local_noun_pointer(0)) };
|
||||||
let tone = Cell::new(&mut context.stack, D(2), mean);
|
let tone = Cell::new(&mut context.stack, D(2), mean);
|
||||||
|
|
||||||
@ -1401,6 +1403,9 @@ mod hint {
|
|||||||
let newt = &mut context.newt;
|
let newt = &mut context.newt;
|
||||||
|
|
||||||
if unsafe { !toon.head().raw_equals(D(2)) } {
|
if unsafe { !toon.head().raw_equals(D(2)) } {
|
||||||
|
// +mook will only ever return a $toon with non-%2 head if that's what it was given as
|
||||||
|
// input. Since we control the input for this call exactly, there must exist a programming
|
||||||
|
// error in Ares if this occurs.
|
||||||
panic!("serf: %hela: mook returned invalid tone");
|
panic!("serf: %hela: mook returned invalid tone");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1422,9 +1427,9 @@ mod hint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let stack = &mut context.stack;
|
// +mook should only ever bail if the input is not [%2 (list)]. Since we control the input
|
||||||
let tape = tape(stack, "serf: %hela: mook error");
|
// for this call exactly, there must exist a programming error in Ares if this occurs.
|
||||||
slog_leaf(stack, &mut context.newt, tape);
|
panic!("serf: unrecoverable stack trace error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,13 +194,7 @@ pub mod util {
|
|||||||
let tag = tone.head().as_direct()?;
|
let tag = tone.head().as_direct()?;
|
||||||
let original_list = tone.tail();
|
let original_list = tone.tail();
|
||||||
|
|
||||||
match tag.data() {
|
if (tag.data() != 2) | unsafe { original_list.raw_equals(D(0)) } {
|
||||||
x if x < 2 => return Ok(tone),
|
|
||||||
x if x > 2 => return Err(JetErr::Fail(Error::Deterministic(D(0)))),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if unsafe { original_list.raw_equals(D(0)) } {
|
|
||||||
return Ok(tone);
|
return Ok(tone);
|
||||||
} else if original_list.atom().is_some() {
|
} else if original_list.atom().is_some() {
|
||||||
return Err(JetErr::Fail(Error::Deterministic(D(0))));
|
return Err(JetErr::Fail(Error::Deterministic(D(0))));
|
||||||
@ -210,23 +204,10 @@ pub mod util {
|
|||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut res = D(0);
|
let mut res = D(0);
|
||||||
|
let mut dest = &mut res as *mut Noun;
|
||||||
|
|
||||||
let mut list = original_list;
|
let mut list = original_list;
|
||||||
// Unused if flopping
|
while !list.raw_equals(D(0)) {
|
||||||
let (mut new_cell, mut new_memory) = Cell::new_raw_mut(&mut context.stack);
|
|
||||||
let mut memory = new_memory;
|
|
||||||
|
|
||||||
// loop guaranteed to run at least once
|
|
||||||
loop {
|
|
||||||
if list.raw_equals(D(0)) {
|
|
||||||
break;
|
|
||||||
} else if !flop && res.raw_equals(D(0)) {
|
|
||||||
res = new_cell.as_noun();
|
|
||||||
} else if !flop {
|
|
||||||
(new_cell, new_memory) = Cell::new_raw_mut(&mut context.stack);
|
|
||||||
(*memory).tail = new_cell.as_noun();
|
|
||||||
memory = new_memory
|
|
||||||
}
|
|
||||||
|
|
||||||
let cell = list.as_cell()?;
|
let cell = list.as_cell()?;
|
||||||
let trace = cell.head().as_cell()?;
|
let trace = cell.head().as_cell()?;
|
||||||
let tag = trace.head().as_direct()?;
|
let tag = trace.head().as_direct()?;
|
||||||
@ -366,15 +347,16 @@ pub mod util {
|
|||||||
if flop {
|
if flop {
|
||||||
res = T(&mut context.stack, &[tank, res]);
|
res = T(&mut context.stack, &[tank, res]);
|
||||||
} else {
|
} else {
|
||||||
(*memory).head = tank;
|
let (new_cell, new_memory) = Cell::new_raw_mut(&mut context.stack);
|
||||||
|
(*new_memory).head = tank;
|
||||||
|
*dest = new_cell.as_noun();
|
||||||
|
dest = &mut (*new_memory).tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = cell.tail();
|
list = cell.tail();
|
||||||
}
|
}
|
||||||
|
|
||||||
if !flop {
|
*dest = D(0);
|
||||||
(*memory).tail = D(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
let toon = Cell::new(&mut context.stack, D(2), res);
|
let toon = Cell::new(&mut context.stack, D(2), res);
|
||||||
Ok(toon)
|
Ok(toon)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user