summaryrefslogtreecommitdiffstats
path: root/bytecode/src/encoding.rs
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2024-06-02 09:17:55 -0700
committerRose Hogenson <rosehogenson@posteo.net>2024-06-02 09:17:55 -0700
commit22b8b7e2478e3b205c89cc7a700058bfe39175f2 (patch)
treead6cf17b8729ab9af71d4d731162e738f3a7b057 /bytecode/src/encoding.rs
parent90c4eac546d2c950b27a84ef0e390ac33a1a347d (diff)
downloadsml-22b8b7e2478e3b205c89cc7a700058bfe39175f2.tar.zst
Add strings and IO.
Diffstat (limited to 'bytecode/src/encoding.rs')
-rw-r--r--bytecode/src/encoding.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/bytecode/src/encoding.rs b/bytecode/src/encoding.rs
index 80fcc58..92e6bf6 100644
--- a/bytecode/src/encoding.rs
+++ b/bytecode/src/encoding.rs
@@ -88,6 +88,28 @@ pub struct If {
}
#[derive(Debug, Clone, Copy)]
+pub struct Read {
+ pub out: u8,
+ pub ptr: u8,
+ pub off: Arg,
+ pub len: Arg,
+}
+
+#[derive(Debug, Clone, Copy)]
+pub struct Write {
+ pub ptr: u8,
+ pub off: Arg,
+ pub len: Arg,
+}
+
+#[derive(Debug, Clone, Copy)]
+pub struct WriteErr {
+ pub ptr: u8,
+ pub off: Arg,
+ pub len: Arg,
+}
+
+#[derive(Debug, Clone, Copy)]
pub enum Op {
Alloc(Alloc),
Call,
@@ -102,6 +124,9 @@ pub enum Op {
Less(Less),
Eq(Eq),
If(If),
+ Read(Read),
+ Write(Write),
+ WriteErr(WriteErr),
}
struct Reader<'a> {
@@ -241,6 +266,25 @@ impl Op {
let target = usize::try_from(itarget)?;
Op::If(If { test, target })
}
+ 14 => {
+ let out = r.parse_local()?;
+ let ptr = r.parse_local()?;
+ let off = r.parse_arg(arg1_const)?;
+ let len = r.parse_arg(arg2_const)?;
+ Op::Read(Read { out, ptr, off, len })
+ }
+ 15 => {
+ let ptr = r.parse_local()?;
+ let off = r.parse_arg(arg1_const)?;
+ let len = r.parse_arg(arg2_const)?;
+ Op::Write(Write { ptr, off, len })
+ }
+ 16 => {
+ let ptr = r.parse_local()?;
+ let off = r.parse_arg(arg1_const)?;
+ let len = r.parse_arg(arg2_const)?;
+ Op::WriteErr(WriteErr { ptr, off, len })
+ }
_ => {
return Err(Box::from(format!("invalid code {}", code)));
}