aboutsummaryrefslogtreecommitdiffstats
path: root/bytecode/src/stack.rs
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-07-29 22:41:17 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-07-29 22:41:17 -0700
commitc7ff0b98146693b60a3f075818f96764f646b2d5 (patch)
treeb8d2f409a934ae8c3858a30f42d1799b8abee5da /bytecode/src/stack.rs
parent762431b0f0a6ead18a93a05c0f3269dca5b8fef1 (diff)
downloadchromatopelma-c7ff0b98146693b60a3f075818f96764f646b2d5.tar.zst
Fix the bytecode interpreter.
I'm too scared to actually try to run it right now.
Diffstat (limited to 'bytecode/src/stack.rs')
-rw-r--r--bytecode/src/stack.rs33
1 files changed, 0 insertions, 33 deletions
diff --git a/bytecode/src/stack.rs b/bytecode/src/stack.rs
deleted file mode 100644
index 66d3f7c..0000000
--- a/bytecode/src/stack.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-struct Stack {
- v: Vec<u64>,
-}
-
-impl Stack {
- fn pop(&mut self) -> Result<u64, String> {
- self.v.pop().ok_or(String::from("stack underflow"))
- }
-
- fn pop_int(&mut self) -> Result<i64, String> {
- Ok(self.pop()? as i64 >> 1)
- }
-
- fn push_int(&mut self, i: i64) {
- self.v.push((i as u64) << 1 | 1);
- }
-
- fn pop_pointer(&mut self) -> Result<Pointer, String> {
- Ok(Pointer::from_bytes(self.pop()?))
- }
-
- fn push_pointer(&mut self, p: Pointer) {
- self.v.push(p.bytes());
- }
-
- fn pop_usize(&mut self) -> Result<usize, String> {
- Ok(usize::try_from(self.pop()?).unwrap() >> 1)
- }
-
- fn push_usize(&mut self, p: usize) {
- self.v.push(u64::try_from(p).unwrap() << 1 | 1);
- }
-}