From d7bbcea1aa2a08381c5d70921fb202406a870de6 Mon Sep 17 00:00:00 2001 From: apache Date: Sun, 27 Oct 2024 22:19:31 -0500 Subject: [PATCH] start on the actual execution part --- src/executor.rs | 0 src/lib.rs | 2 ++ src/opcodes.rs | 20 ++++++++++++++++++++ src/value.rs | 10 ++++++++++ 4 files changed, 32 insertions(+) create mode 100644 src/executor.rs create mode 100644 src/opcodes.rs diff --git a/src/executor.rs b/src/executor.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/lib.rs b/src/lib.rs index ffe9f45..451d410 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,6 @@ mod value; +mod executor; +mod opcodes; #[cfg(test)] mod tests { diff --git a/src/opcodes.rs b/src/opcodes.rs new file mode 100644 index 0000000..ee3a091 --- /dev/null +++ b/src/opcodes.rs @@ -0,0 +1,20 @@ +use crate::value::Value; + +type StackLocation = usize; +#[derive(PartialEq, Debug)] +pub enum OpValue { + Literal(Value), + Ref(StackLocation) +} + +#[derive(PartialEq, Debug)] +pub enum OpCode { + // Function, arguments + Call(OpValue, Option>), + // Return Values + Return(Option>), + // Table, index + Index(OpValue, OpValue), + // Table, index, value + SetIndex(OpValue, OpValue, OpValue), +} \ No newline at end of file diff --git a/src/value.rs b/src/value.rs index 6d59348..3b51881 100644 --- a/src/value.rs +++ b/src/value.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use crate::opcodes::OpCode; #[derive(PartialEq, Debug)] pub enum Value { @@ -10,6 +11,15 @@ pub enum Value { Table { arr: Vec, map: HashMap, + }, + VmFunction { + name: String, + args: Vec, + func: Vec + }, + NativeFunction { + name: String, + func: fn(Vec) -> Option> } }