mirror of
https://github.com/urbit/ares.git
synced 2024-11-22 15:08:54 +03:00
Merge pull request #10 from urbit/philip/dec
add decrement test and make it pass
This commit is contained in:
commit
ea5e538d10
28
rust/ares/Cargo.lock
generated
28
rust/ares/Cargo.lock
generated
@ -2,6 +2,20 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "ares"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"either",
|
||||
"intmap",
|
||||
"libc",
|
||||
"memmap",
|
||||
"murmur3",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
@ -38,20 +52,6 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b357564d111300f8a33b79e06795235529a627a1f7078d2b1db7f7dcdf032874"
|
||||
|
||||
[[package]]
|
||||
name = "iron-planet"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"either",
|
||||
"intmap",
|
||||
"libc",
|
||||
"memmap",
|
||||
"murmur3",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.126"
|
||||
|
@ -262,7 +262,7 @@ pub fn interpret(stack: &mut NockStack, mut subject: Noun, formula: Noun) -> Nou
|
||||
}
|
||||
Nock8RestoreSubject => {
|
||||
unsafe {
|
||||
subject = *(stack.local_noun_pointer(2));
|
||||
subject = *(stack.local_noun_pointer(1));
|
||||
stack.pop(&mut res);
|
||||
};
|
||||
}
|
||||
@ -305,6 +305,8 @@ pub fn interpret(stack: &mut NockStack, mut subject: Noun, formula: Noun) -> Nou
|
||||
let tree = *stack.local_noun_pointer(3);
|
||||
res = edit(stack, edit_axis.as_bitslice(), res, tree);
|
||||
stack.pop(&mut res);
|
||||
} else {
|
||||
panic!("Axis into tree must be atom");
|
||||
}
|
||||
},
|
||||
Nock11ComputeHint => unsafe {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use iron_planet::interpreter::interpret;
|
||||
use iron_planet::mem::NockStack;
|
||||
use iron_planet::noun::IndirectAtom;
|
||||
use iron_planet::serialization::{cue, jam};
|
||||
use ares::interpreter::interpret;
|
||||
use ares::mem::NockStack;
|
||||
use ares::noun::IndirectAtom;
|
||||
use ares::serialization::{cue, jam};
|
||||
use memmap::Mmap;
|
||||
use memmap::MmapMut;
|
||||
use std::env;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::noun::{CellMemory, IndirectAtom, Noun, NounAllocator};
|
||||
use crate::noun::{CellMemory, IndirectAtom, Noun, NounAllocator, Cell};
|
||||
use either::Either::{self, Left, Right};
|
||||
use libc::{c_void, memcmp};
|
||||
use memmap::MmapMut;
|
||||
@ -328,7 +328,7 @@ impl NockStack {
|
||||
*next_dest = new_allocated.as_noun();
|
||||
}
|
||||
Option::None => {
|
||||
if (allocated.to_raw_pointer() as *const u64) > work_start
|
||||
if (allocated.to_raw_pointer() as *const u64) >= work_start
|
||||
&& (allocated.to_raw_pointer() as *const u64) < self.frame_pointer
|
||||
{
|
||||
match allocated.as_either() {
|
||||
@ -363,9 +363,6 @@ impl NockStack {
|
||||
(*new_cell_alloc).metadata =
|
||||
(*cell.to_raw_pointer()).metadata;
|
||||
|
||||
// Set the forwarding pointer
|
||||
cell.set_forwarding_pointer(new_cell_alloc);
|
||||
|
||||
// Push the tail and the head to the work stack
|
||||
self.stack_pointer = self.stack_pointer.sub(4);
|
||||
*(self.stack_pointer as *mut Noun) = cell.tail();
|
||||
@ -374,6 +371,12 @@ impl NockStack {
|
||||
*(self.stack_pointer.add(2) as *mut Noun) = cell.head();
|
||||
*(self.stack_pointer.add(3) as *mut *mut Noun) =
|
||||
&mut (*new_cell_alloc).head;
|
||||
|
||||
// Set the forwarding pointer
|
||||
cell.set_forwarding_pointer(new_cell_alloc);
|
||||
|
||||
*next_dest =
|
||||
Cell::from_raw_pointer(new_cell_alloc).as_noun();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -437,7 +440,7 @@ impl NockStack {
|
||||
}
|
||||
Option::None => {
|
||||
if (allocated.to_raw_pointer() as *const u64) < work_start
|
||||
&& (allocated.to_raw_pointer() as *const u64) > self.frame_pointer
|
||||
&& (allocated.to_raw_pointer() as *const u64) >= self.frame_pointer
|
||||
{
|
||||
match allocated.as_either() {
|
||||
Either::Left(mut indirect) => {
|
||||
@ -471,9 +474,6 @@ impl NockStack {
|
||||
(*new_cell_alloc).metadata =
|
||||
(*cell.to_raw_pointer()).metadata;
|
||||
|
||||
// Set the forwarding pointer
|
||||
cell.set_forwarding_pointer(new_cell_alloc);
|
||||
|
||||
*(self.stack_pointer as *mut Noun) = cell.tail();
|
||||
*(self.stack_pointer.add(1) as *mut *mut Noun) =
|
||||
&mut (*new_cell_alloc).tail;
|
||||
@ -481,6 +481,12 @@ impl NockStack {
|
||||
*(self.stack_pointer.add(3) as *mut *mut Noun) =
|
||||
&mut (*new_cell_alloc).head;
|
||||
self.stack_pointer = self.stack_pointer.add(4);
|
||||
|
||||
// Set the forwarding pointer
|
||||
cell.set_forwarding_pointer(new_cell_alloc);
|
||||
|
||||
*next_dest =
|
||||
Cell::from_raw_pointer(new_cell_alloc).as_noun();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
BIN
rust/ares/test_data/decrement.jam
Normal file
BIN
rust/ares/test_data/decrement.jam
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user