mirror of
https://github.com/urbit/ares.git
synced 2024-12-24 13:55:23 +03:00
jets: naive, non-cached stir
implementation
This commit is contained in:
parent
17bebbdde6
commit
bd45da99f8
@ -440,6 +440,20 @@ pub const URBIT_HOT_STATE: &[HotEntry] = &[
|
||||
jet_stag,
|
||||
),
|
||||
//
|
||||
(
|
||||
&[
|
||||
K_139,
|
||||
Left(b"one"),
|
||||
Left(b"two"),
|
||||
Left(b"tri"),
|
||||
Left(b"qua"),
|
||||
Left(b"stir"),
|
||||
Left(b"fun"),
|
||||
],
|
||||
1,
|
||||
jet_stir,
|
||||
),
|
||||
//
|
||||
(
|
||||
&[
|
||||
K_139,
|
||||
|
@ -225,6 +225,60 @@ pub fn jet_sfix(context: &mut Context, subject: Noun) -> Result {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn jet_stir(context: &mut Context, subject: Noun) -> Result {
|
||||
context.stack.frame_push(0);
|
||||
|
||||
let mut tub = slot(subject, 6)?;
|
||||
let van = slot(subject, 7)?;
|
||||
let rud = slot(van, 12)?;
|
||||
let raq = slot(van, 26)?;
|
||||
let fel = slot(van, 27)?;
|
||||
|
||||
// +$ edge [p=hair q=(unit [p=* q=nail])]
|
||||
let hair = T(&mut context.stack, &[D(1), D(1)]);
|
||||
let mut par_u = T(&mut context.stack, &[hair, D(0)]);
|
||||
|
||||
// initial accumulator (deconstructed)
|
||||
let mut p_wag: Noun;
|
||||
let mut puq_wag: Noun;
|
||||
let quq_wag: Noun;
|
||||
|
||||
// push incremental, succesful [fel] parse results onto stack
|
||||
{
|
||||
let mut vex = slam(context, fel, tub)?.as_cell()?;
|
||||
let mut p_vex = vex.head();
|
||||
let mut q_vex = vex.tail();
|
||||
while !unsafe { q_vex.raw_equals(D(0)) } {
|
||||
let puq_vex = q_vex.as_cell()?.head();
|
||||
let quq_vex = q_vex.as_cell()?.tail();
|
||||
|
||||
par_u = T(&mut context.stack, &[p_vex, puq_vex]);
|
||||
unsafe { *(context.stack.push()) = par_u };
|
||||
|
||||
tub = quq_vex;
|
||||
|
||||
vex = slam(context, fel, tub)?.as_cell()?;
|
||||
p_vex = vex.head();
|
||||
q_vex = vex.tail();
|
||||
}
|
||||
|
||||
p_wag = p_vex;
|
||||
puq_wag = rud;
|
||||
quq_wag = tub;
|
||||
}
|
||||
|
||||
// unwind the stack, folding parse results into [wag] by way of [raq]
|
||||
while !context.stack.stack_is_empty() {
|
||||
p_wag = util::last(p_wag, puq_wag)?;
|
||||
let sam = T(&mut context.stack, &[par_u.as_cell()?.tail(), puq_wag]);
|
||||
puq_wag = slam(context, raq, sam)?;
|
||||
par_u = unsafe { *(context.stack.top()) };
|
||||
unsafe { context.stack.pop::<Noun>(); };
|
||||
}
|
||||
|
||||
Ok(T(&mut context.stack, &[p_wag, D(0), puq_wag, quq_wag]))
|
||||
}
|
||||
|
||||
//
|
||||
// Rule Builders
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user