start on the actual execution part
This commit is contained in:
parent
f5de0ea259
commit
d7bbcea1aa
4 changed files with 32 additions and 0 deletions
0
src/executor.rs
Normal file
0
src/executor.rs
Normal file
|
@ -1,4 +1,6 @@
|
|||
mod value;
|
||||
mod executor;
|
||||
mod opcodes;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
20
src/opcodes.rs
Normal file
20
src/opcodes.rs
Normal file
|
@ -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<Vec<OpValue>>),
|
||||
// Return Values
|
||||
Return(Option<Vec<OpValue>>),
|
||||
// Table, index
|
||||
Index(OpValue, OpValue),
|
||||
// Table, index, value
|
||||
SetIndex(OpValue, OpValue, OpValue),
|
||||
}
|
10
src/value.rs
10
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<Value>,
|
||||
map: HashMap<String, Value>,
|
||||
},
|
||||
VmFunction {
|
||||
name: String,
|
||||
args: Vec<String>,
|
||||
func: Vec<OpCode>
|
||||
},
|
||||
NativeFunction {
|
||||
name: String,
|
||||
func: fn(Vec<Value>) -> Option<Vec<Value>>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue