forked from MightyPork/crsn
implement "lds" for objects (buffers, cin)
This commit is contained in:
@@ -10,6 +10,7 @@ use crsn::sexp::{atom_qs, Sexp};
|
||||
use crsn::utils::A;
|
||||
|
||||
use crate::defs::{BufIoMode, BufOps, BufValue};
|
||||
use crsn::asm::data::Wr;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
struct Buffer {
|
||||
@@ -318,6 +319,21 @@ pub(crate) fn read_obj(state: &mut RunState, handle: Value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Run-time method called to read all from an object (using the object handle syntax)
|
||||
pub(crate) fn read_obj_all(state: &mut RunState, whandle: Wr, rhandle: Value)
|
||||
-> Result<Option<()>, Fault>
|
||||
{
|
||||
let store: &mut ExtData = state.ext_mut();
|
||||
if let Some(buf) = store.buffers.get_mut(&rhandle) {
|
||||
for v in buf.data.clone() { // FIXME potentially needless clone (but allows "aliasing")
|
||||
state.write(whandle, v)?;
|
||||
}
|
||||
Ok(Some(()))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
/// Run-time method called to write an object (using the object handle syntax)
|
||||
pub(crate) fn write_obj(state: &mut RunState, handle: Value, value: Value) -> Result<Option<()>, Fault>
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ use crsn::runtime::fault::Fault;
|
||||
use crsn::runtime::run_thread::{RunState, ThreadInfo};
|
||||
use crsn::sexp::SourcePosition;
|
||||
use crate::parse::{BUF_IOMODE_STACK, BUF_IOMODE_REVERSE_STACK, BUF_IOMODE_QUEUE, BUF_IOMODE_REVERSE_QUEUE};
|
||||
use crsn::asm::data::Wr;
|
||||
|
||||
mod defs;
|
||||
mod parse;
|
||||
@@ -59,4 +60,11 @@ impl CrsnExtension for BufOps {
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
/// Run-time method called to read all values from an object ("lds" using the object handle syntax)
|
||||
fn read_obj_all(&self, state: &mut RunState, whandle: Wr, rhandle: Value)
|
||||
-> Result<Option<()>, Fault>
|
||||
{
|
||||
exec::read_obj_all(state, whandle, rhandle)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user