mirror of
https://github.com/urbit/ares.git
synced 2024-11-23 00:25:49 +03:00
[ares] rename new_tuple -> T, make D const
This commit is contained in:
parent
dd4dc625bd
commit
ff59ca8ba9
@ -51,7 +51,7 @@
|
||||
* It's important to not use io::Stdin and io::Stdout directly. All printfs should use stderr.
|
||||
*/
|
||||
use crate::mem::NockStack;
|
||||
use crate::noun::{Cell, IndirectAtom, Noun, D};
|
||||
use crate::noun::{T, IndirectAtom, Noun, D};
|
||||
use crate::serialization::{cue, jam};
|
||||
use ares_macros::tas;
|
||||
use either::Either;
|
||||
@ -107,88 +107,84 @@ impl Newt {
|
||||
|
||||
/** Send %ripe, the first event. */
|
||||
pub fn ripe(&mut self, stack: &mut NockStack, eve: u64, mug: u64) {
|
||||
let version = Cell::new_tuple(
|
||||
let version = T(
|
||||
stack,
|
||||
&[
|
||||
D(1), // newt protocol
|
||||
D(139), // hoon kelvin
|
||||
D(4), // nock kelvin
|
||||
],
|
||||
)
|
||||
.as_noun();
|
||||
let ripe = Cell::new_tuple(stack, &[D(tas!(b"ripe")), version, D(eve), D(mug)]).as_noun();
|
||||
);
|
||||
let ripe = T(stack, &[D(tas!(b"ripe")), version, D(eve), D(mug)]);
|
||||
self.write_noun(stack, ripe);
|
||||
}
|
||||
|
||||
/** Send %live, acknowledging. */
|
||||
pub fn live(&mut self, stack: &mut NockStack) {
|
||||
let live = Cell::new_tuple(stack, &[D(tas!(b"live")), D(0)]).as_noun();
|
||||
let live = T(stack, &[D(tas!(b"live")), D(0)]);
|
||||
self.write_noun(stack, live);
|
||||
}
|
||||
|
||||
/** Send %slog, pretty-printed debug output. */
|
||||
pub fn slog(&mut self, stack: &mut NockStack, pri: u64, tank: Noun) {
|
||||
let slog = Cell::new_tuple(stack, &[D(tas!(b"slog")), D(pri), tank]).as_noun();
|
||||
let slog = T(stack, &[D(tas!(b"slog")), D(pri), tank]);
|
||||
self.write_noun(stack, slog);
|
||||
}
|
||||
|
||||
/** Send %flog, raw debug output. */
|
||||
pub fn flog(&mut self, stack: &mut NockStack, cord: Noun) {
|
||||
let flog = Cell::new_tuple(stack, &[D(tas!(b"flog")), cord]).as_noun();
|
||||
let flog = T(stack, &[D(tas!(b"flog")), cord]);
|
||||
self.write_noun(stack, flog);
|
||||
}
|
||||
|
||||
/** Send %peek %done, successfully scried. */
|
||||
pub fn peek_done(&mut self, stack: &mut NockStack, dat: Noun) {
|
||||
let peek = Cell::new_tuple(stack, &[D(tas!(b"peek")), D(tas!(b"done")), dat]).as_noun();
|
||||
let peek = T(stack, &[D(tas!(b"peek")), D(tas!(b"done")), dat]);
|
||||
self.write_noun(stack, peek);
|
||||
}
|
||||
|
||||
/** Send %peek %bail, unsuccessfully scried. */
|
||||
pub fn peek_bail(&mut self, stack: &mut NockStack, dud: Noun) {
|
||||
let peek = Cell::new_tuple(stack, &[D(tas!(b"peek")), D(tas!(b"bail")), dud]).as_noun();
|
||||
let peek = T(stack, &[D(tas!(b"peek")), D(tas!(b"bail")), dud]);
|
||||
self.write_noun(stack, peek);
|
||||
}
|
||||
|
||||
/** Send %play %done, successfully replayed events. */
|
||||
pub fn play_done(&mut self, stack: &mut NockStack, mug: u64) {
|
||||
let play = Cell::new_tuple(stack, &[D(tas!(b"play")), D(tas!(b"done")), D(mug)]).as_noun();
|
||||
let play = T(stack, &[D(tas!(b"play")), D(tas!(b"done")), D(mug)]);
|
||||
self.write_noun(stack, play);
|
||||
}
|
||||
|
||||
/** Send %play %bail, failed to replay events. */
|
||||
pub fn play_bail(&mut self, stack: &mut NockStack, eve: u64, mug: u64, dud: Noun) {
|
||||
let play = Cell::new_tuple(
|
||||
let play = T(
|
||||
stack,
|
||||
&[D(tas!(b"play")), D(tas!(b"bail")), D(eve), D(mug), dud],
|
||||
)
|
||||
.as_noun();
|
||||
);
|
||||
self.write_noun(stack, play);
|
||||
}
|
||||
|
||||
/** Send %work %done, successfully ran event. */
|
||||
pub fn work_done(&mut self, stack: &mut NockStack, eve: u64, mug: u64, fec: Noun) {
|
||||
let work = Cell::new_tuple(
|
||||
let work = T(
|
||||
stack,
|
||||
&[D(tas!(b"work")), D(tas!(b"done")), D(eve), D(mug), fec],
|
||||
)
|
||||
.as_noun();
|
||||
);
|
||||
self.write_noun(stack, work);
|
||||
}
|
||||
|
||||
/** Send %work %swap, successfully replaced failed event. */
|
||||
pub fn work_swap(&mut self, stack: &mut NockStack, eve: u64, mug: u64, job: Noun, fec: Noun) {
|
||||
let work = Cell::new_tuple(
|
||||
let work = T(
|
||||
stack,
|
||||
&[D(tas!(b"work")), D(tas!(b"swap")), D(eve), D(mug), job, fec],
|
||||
)
|
||||
.as_noun();
|
||||
);
|
||||
self.write_noun(stack, work);
|
||||
}
|
||||
|
||||
/** Send %work %bail, failed to run event. */
|
||||
pub fn work_bail(&mut self, stack: &mut NockStack, lud: Noun) {
|
||||
let work = Cell::new_tuple(stack, &[D(tas!(b"work")), D(tas!(b"bail")), lud]).as_noun();
|
||||
let work = T(stack, &[D(tas!(b"work")), D(tas!(b"bail")), lud]);
|
||||
self.write_noun(stack, work);
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ impl DirectAtom {
|
||||
Atom { direct: self }
|
||||
}
|
||||
|
||||
pub fn as_noun(self) -> Noun {
|
||||
pub const fn as_noun(self) -> Noun {
|
||||
Noun { direct: self }
|
||||
}
|
||||
|
||||
@ -151,10 +151,15 @@ impl fmt::Debug for DirectAtom {
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn D(n: u64) -> Noun {
|
||||
pub const fn D(n: u64) -> Noun {
|
||||
DirectAtom::new_panic(n).as_noun()
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn T(allocator: &mut dyn NounAllocator, tup: &[Noun]) -> Noun {
|
||||
Cell::new_tuple(allocator, tup).as_noun()
|
||||
}
|
||||
|
||||
/** An indirect atom.
|
||||
*
|
||||
* Indirect atoms represent atoms above DIRECT_MAX as a tagged pointer to a memory buffer
|
||||
|
@ -2,7 +2,7 @@ use crate::interpreter::{interpret, raw_slot};
|
||||
use crate::mem::NockStack;
|
||||
use crate::mug::mug_u32;
|
||||
use crate::newt::Newt;
|
||||
use crate::noun::{Cell, Noun, D};
|
||||
use crate::noun::{T, Noun, D};
|
||||
use crate::snapshot::{load, save};
|
||||
use ares_macros::tas;
|
||||
use std::fs::create_dir_all;
|
||||
@ -74,8 +74,8 @@ pub fn serf() -> io::Result<()> {
|
||||
let run = if event_number == 0 {
|
||||
// apply lifecycle to first batch
|
||||
let lit = raw_slot(writ, 7);
|
||||
let sub = Cell::new_tuple(stack, &[D(0), D(3)]).as_noun();
|
||||
let lyf = Cell::new_tuple(stack, &[D(2), sub, D(0), D(2)]).as_noun();
|
||||
let sub = T(stack, &[D(0), D(3)]);
|
||||
let lyf = T(stack, &[D(2), sub, D(0), D(2)]);
|
||||
let gat = interpret(stack, &mut Some(newt), lit, lyf);
|
||||
arvo = raw_slot(gat, 7);
|
||||
false
|
||||
@ -120,9 +120,9 @@ pub fn serf() -> io::Result<()> {
|
||||
}
|
||||
|
||||
pub fn slam(stack: &mut NockStack, newt: &mut Newt, core: Noun, axis: u64, ovo: Noun) -> Noun {
|
||||
let pul = Cell::new_tuple(stack, &[D(9), D(axis), D(0), D(2)]).as_noun();
|
||||
let sam = Cell::new_tuple(stack, &[D(6), D(0), D(7)]).as_noun();
|
||||
let fol = Cell::new_tuple(stack, &[D(8), pul, D(9), D(2), D(10), sam, D(0), D(2)]).as_noun();
|
||||
let sub = Cell::new_tuple(stack, &[core, ovo]).as_noun();
|
||||
let pul = T(stack, &[D(9), D(axis), D(0), D(2)]);
|
||||
let sam = T(stack, &[D(6), D(0), D(7)]);
|
||||
let fol = T(stack, &[D(8), pul, D(9), D(2), D(10), sam, D(0), D(2)]);
|
||||
let sub = T(stack, &[core, ovo]);
|
||||
interpret(stack, &mut Some(newt), sub, fol)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user