]> rethought.computer Git - sorel-lang.git/commitdiff
remove unused interpreter keep/99a2bf854128909de4e3f0c5c28428d638ab8c63
authorBryan English <bryan@rethought.computer>
Tue, 10 Feb 2026 03:57:20 +0000 (22:57 -0500)
committerBryan English <bryan@rethought.computer>
Tue, 10 Feb 2026 04:08:55 +0000 (04:08 +0000)
rel-lang/Cargo.lock
rel-lang/Cargo.toml
rel-lang/sorel-interpret/Cargo.toml [deleted file]
rel-lang/sorel-interpret/src/lib.rs [deleted file]
rel-lang/sorelc/Cargo.toml
rel-lang/sorelc/src/main.rs

index 4280816d990ccfff843818129e8ae3f284e2b29c..47524a9e84c6ed0ab8308315dd53419ca4ba2435 100644 (file)
@@ -67,7 +67,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
 dependencies = [
  "serde_core",
- "serde_derive",
 ]
 
 [[package]]
@@ -90,17 +89,6 @@ dependencies = [
  "syn",
 ]
 
-[[package]]
-name = "serde_repr"
-version = "0.1.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
 [[package]]
 name = "serde_yaml"
 version = "0.9.34+deprecated"
@@ -114,15 +102,6 @@ dependencies = [
  "unsafe-libyaml",
 ]
 
-[[package]]
-name = "sorel-interpret"
-version = "0.1.0"
-dependencies = [
- "anyhow",
- "sorel-ir",
- "syscalls",
-]
-
 [[package]]
 name = "sorel-ir"
 version = "0.1.0"
@@ -137,7 +116,6 @@ name = "sorelc"
 version = "0.1.0"
 dependencies = [
  "anyhow",
- "sorel-interpret",
  "sorel-ir",
 ]
 
@@ -152,16 +130,6 @@ dependencies = [
  "unicode-ident",
 ]
 
-[[package]]
-name = "syscalls"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90db46b5b4962319605d435986c775ea45a0ad2561c09e1d5372b89afeb49cf4"
-dependencies = [
- "serde",
- "serde_repr",
-]
-
 [[package]]
 name = "unicode-ident"
 version = "1.0.22"
index 19da6a84d8907bff4729a43a2de6daa4292be828..fae2a7825f17527d6075e1929991b67c7faa2b6e 100644 (file)
@@ -1,9 +1,8 @@
 [workspace]
 
 resolver = "3"
-members = ["sorel-ir","sorelc", "sorel-interpret"]
+members = ["sorel-ir","sorelc"]
 
 
 [workspace.dependencies]
 sorel-ir = { path = "./sorel-ir", version = "0.1.0" }
-sorel-interpret = { path = "./sorel-interpret", version = "0.1.0" }
diff --git a/rel-lang/sorel-interpret/Cargo.toml b/rel-lang/sorel-interpret/Cargo.toml
deleted file mode 100644 (file)
index 6afe8a9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[package]
-name = "sorel-interpret"
-version = "0.1.0"
-edition = "2024"
-
-[dependencies]
-anyhow = "1.0.100"
-sorel-ir = { workspace = true }
-syscalls = "0.7.0"
diff --git a/rel-lang/sorel-interpret/src/lib.rs b/rel-lang/sorel-interpret/src/lib.rs
deleted file mode 100644 (file)
index b637594..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-use sorel_ir::*;
-
-use std::collections::HashMap;
-
-use syscalls::*;
-use anyhow::{Result, anyhow};
-
-pub struct Interpreter<'a> {
-    module: &'a IRObject,
-    data_stack: Vec<u64>,
-    instruction_pointer: usize,
-    return_stack: Vec<usize>,
-    labels: HashMap<String, usize>,
-    strings: HashMap<String, String>,
-}
-
-impl<'a> Interpreter<'a> {
-    pub fn new(ir_mod: &'a IRObject) -> Result<Self> {
-        let mut index = 0;
-        let mut labels = HashMap::new();
-        for token in ir_mod.text.iter() {
-            if let IR::Label(name) = token {
-                labels.insert(name.clone(), index);
-            }
-            index += 1;
-        }
-        let instruction_pointer = *labels.get("main").ok_or(anyhow!("no main word found!"))?;
-
-        let mut strings = HashMap::new();
-        ir_mod.data.iter().for_each(|s| {
-            match s {
-                IR::StringDef(label, string) => {
-                    strings.insert(label.clone(), string.clone());
-                },
-                _ => {}
-            }
-        });
-
-        Ok(Self {
-            module: ir_mod,
-            data_stack: vec![],
-            instruction_pointer,
-            return_stack: vec![],
-            labels,
-            strings
-        })
-    }
-
-    fn process_syscall_result(&mut self, result: Result<usize, Errno>) {
-        match result {
-            Ok(result) => {
-                self.data_stack.push(result as u64);
-                self.data_stack.push(0);
-            }
-            Err(err) => {
-                self.data_stack.push(0);
-                self.data_stack.push(err.into_raw() as u64);
-            }
-        }
-    }
-
-    fn ds_pop(&mut self) -> Result<u64> {
-        self.data_stack.pop().ok_or(anyhow!("popping from empty data stack"))
-    }
-
-    pub fn run(&mut self) -> Result<()> {
-        let mut looking_for_endif = false;
-        loop {
-            if looking_for_endif {
-                match &self.module.text[self.instruction_pointer] {
-                    IR::EndIf => {
-                        looking_for_endif = false;
-                    },
-                    IR::Else => {
-                        looking_for_endif = false;
-                    }
-                    _ => {}
-                }
-            } else {
-                match &self.module.text[self.instruction_pointer] {
-                    IR::Label(_) => {},
-                    IR::Call(name) => {
-                        self.return_stack.push(self.instruction_pointer);
-                        self.instruction_pointer = *self.labels.get(name).ok_or(anyhow!("calling undefined word `{}`", name))?;
-                    },
-                    IR::Ret => {
-                        if self.return_stack.len() == 0 {
-                            return Ok(());
-                        }
-                        self.instruction_pointer = self.return_stack.pop().ok_or(anyhow!("returning from top level"))?;
-                    },
-                    IR::StackPush(num) => {
-                        self.data_stack.push(*num);
-                    },
-                    IR::AddU64 => {
-                        let a = self.ds_pop()?;
-                        let b = self.ds_pop()?;
-                        self.data_stack.push(a + b);
-                    },
-                    IR::SubtractU64 => {
-                        let b = self.ds_pop()?;
-                        let a = self.ds_pop()?;
-                        self.data_stack.push(a - b);
-                    },
-                    IR::Dup => {
-                        self.data_stack.push(*self.data_stack.last().ok_or(anyhow!("empty data stack"))?);
-                    },
-                    IR::Swap => {
-                        let a = self.ds_pop()?;
-                        let b = self.ds_pop()?;
-                        self.data_stack.push(a);
-                        self.data_stack.push(b);
-                    },
-                    IR::Drop => {
-                        self.data_stack.pop();
-                    },
-                    IR::Equals => {
-                        let a = self.ds_pop()?;
-                        let b = self.ds_pop()?;
-                        self.data_stack.push(if a == b {
-                            0
-                        } else {
-                            -1 as i64 as u64
-                        });
-                    },
-                    IR::GreaterThan => {
-                        let b = self.ds_pop()?;
-                        let a = self.ds_pop()?;
-                        self.data_stack.push(if a > b {
-                            0
-                        } else {
-                            -1 as i64 as u64
-                        });
-
-                    },
-                    IR::BitwiseOr => {
-                        let b = self.ds_pop()?;
-                        let a = self.ds_pop()?;
-                        self.data_stack.push(a | b);
-                    }
-                    IR::If => {
-                        if self.ds_pop()? != 0 {
-                            looking_for_endif = true;
-                        }
-                    },
-                    IR::EndIf => {},
-                    IR::Sys0 => {
-                        let call_num = Sysno::from(self.ds_pop()? as i32);
-                        self.process_syscall_result(unsafe { syscall!(call_num) });
-                    },
-                    IR::Sys1 => {
-                        let call_num = Sysno::from(self.ds_pop()? as i32);
-                        let a1 = self.ds_pop()?;
-                        self.process_syscall_result(unsafe { syscall!(call_num, a1) });
-                    },
-                    IR::Sys2 => {
-                        let call_num = Sysno::from(self.ds_pop()? as i32);
-                        let a2 = self.ds_pop()?;
-                        let a1 = self.ds_pop()?;
-                        self.process_syscall_result(unsafe { syscall!(call_num, a1, a2) });
-                    },
-                    IR::Sys3 => {
-                        let call_num = Sysno::from(self.ds_pop()? as i32);
-                        let a3 = self.ds_pop()?;
-                        let a2 = self.ds_pop()?;
-                        let a1 = self.ds_pop()?;
-                        self.process_syscall_result(unsafe { syscall!(call_num, a1, a2, a3) });
-                    },
-                    IR::Sys4 => {
-                        let call_num = Sysno::from(self.ds_pop()? as i32);
-                        let a4 = self.ds_pop()?;
-                        let a3 = self.ds_pop()?;
-                        let a2 = self.ds_pop()?;
-                        let a1 = self.ds_pop()?;
-                        self.process_syscall_result(unsafe { syscall!(call_num, a1, a2, a3, a4) });
-                    },
-                    IR::Sys5 => {
-                        let call_num = Sysno::from(self.ds_pop()? as i32);
-                        let a5 = self.ds_pop()?;
-                        let a4 = self.ds_pop()?;
-                        let a3 = self.ds_pop()?;
-                        let a2 = self.ds_pop()?;
-                        let a1 = self.ds_pop()?;
-                        self.process_syscall_result(unsafe { syscall!(call_num, a1, a2, a3, a4, a5) });
-                    },
-                    IR::Sys6 => {
-                        println!("stack: {:?}", self.data_stack);
-                        let call_num = Sysno::from(self.ds_pop()? as i32);
-                        let a6 = self.ds_pop()?;
-                        let a5 = self.ds_pop()?;
-                        let a4 = self.ds_pop()?;
-                        let a3 = self.ds_pop()?;
-                        let a2 = self.ds_pop()?;
-                        let a1 = self.ds_pop()?;
-                        self.process_syscall_result(unsafe { syscall!(call_num, a1, a2, a3, a4, a5, a6) });
-                    },
-                    _ => {
-                        println!("Instruction not implemented.");
-                    },
-                }
-            }
-            self.instruction_pointer += 1;
-        }
-    }
-}
index dc3b9bcc28d10e76a50a426a1912f0ba1e8f3c0b..7859ecf01b0a860f9ac63fd70ea5c1833929f68d 100644 (file)
@@ -5,5 +5,4 @@ edition = "2024"
 
 [dependencies]
 sorel-ir = { workspace = true }
-sorel-interpret = { workspace = true }
 anyhow = "1.0.100"
index 89f1d7a1ee8b802d1ed23d5b75159cf25e5bf2d8..724df8474f3bf6dcc1e3208a142128b642817807 100644 (file)
@@ -3,8 +3,6 @@ mod parser;
 mod ir;
 mod riscv_asm_codegen;
 
-use sorel_interpret::Interpreter;
-
 use anyhow::Result;
 
 use std::fs::File;
@@ -14,8 +12,6 @@ use std::path::PathBuf;
 fn main() -> Result<()> {
     let filename = std::env::args().nth(1).expect("must provide a file to compile");
     let module = ir::compile(&filename)?;
-    // let mut interp = Interpreter::new(&module)?;
-    // interp.run()?;
     let mut generator = riscv_asm_codegen::CodeGen::new(&module, 4096);
     let mut asm_path = PathBuf::from(filename);
     asm_path.set_extension("asm");