Move value to vm/value
This commit is contained in:
parent
139887fd73
commit
2710a43bb2
@ -1,14 +1,13 @@
|
||||
use ferrite_lua::{
|
||||
compile,
|
||||
value::{self, RustFunction},
|
||||
vm::{self, RuntimeError, VirtualMachine},
|
||||
vm::{RuntimeError, VirtualMachine, value},
|
||||
};
|
||||
|
||||
static TEST: &str = include_str!("../examples/test.lua");
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Max;
|
||||
impl RustFunction for Max {
|
||||
impl value::RustFunction for Max {
|
||||
fn execute(&self, parameters: Vec<value::Value>) -> Result<Vec<value::Value>, RuntimeError> {
|
||||
let lhs = parameters.get(0).cloned().unwrap_or(value::Value::Nil);
|
||||
let rhs = parameters.get(1).cloned().unwrap_or(value::Value::Nil);
|
||||
@ -24,7 +23,7 @@ impl RustFunction for Max {
|
||||
}
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Print;
|
||||
impl RustFunction for Print {
|
||||
impl value::RustFunction for Print {
|
||||
fn execute(&self, parameters: Vec<value::Value>) -> Result<Vec<value::Value>, RuntimeError> {
|
||||
println!("{:?}", parameters);
|
||||
Ok(Vec::new())
|
||||
|
||||
@ -5,7 +5,7 @@ use crate::{
|
||||
Parse, TokenRange, TokenStream, TokenStreamError,
|
||||
lexer::{Keyword, Position, Token},
|
||||
},
|
||||
value::{LuaFloat, LuaInteger},
|
||||
vm::value::{LuaFloat, LuaInteger},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@ -8,8 +8,10 @@ use crate::{
|
||||
AccessModifier, BinaryOperator, Block, Expression, ExpressionList, IdentOrEllipsis,
|
||||
Literal, Node, Statement, UnaryOperator,
|
||||
},
|
||||
value::{LuaBool, LuaInteger},
|
||||
vm::{Constant, Instruction, Prototype},
|
||||
vm::{
|
||||
Constant, Instruction, Prototype,
|
||||
value::{LuaBool, LuaInteger},
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Usage example:
|
||||
//! ```rust
|
||||
//! use ferrite_lua::{compile, vm, value};
|
||||
//! use ferrite_lua::{compile, vm::{self, value}};
|
||||
//!
|
||||
//! #[derive(Debug, PartialEq, Eq)]
|
||||
//! pub struct Print;
|
||||
@ -42,7 +42,6 @@ use crate::{
|
||||
mod ast;
|
||||
mod compile;
|
||||
mod token_stream;
|
||||
pub mod value;
|
||||
pub mod vm;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
||||
@ -5,9 +5,11 @@ use std::{cell::RefCell, collections::HashMap, fmt::Debug, hash::Hash, rc::Rc};
|
||||
use crate::{
|
||||
CompilationUnit,
|
||||
ast::{BinaryOperator, UnaryOperator},
|
||||
value::{IndexableValue, LuaBool, LuaInteger, VMFloat, Value},
|
||||
vm::value::{IndexableValue, LuaBool, LuaInteger, VMFloat, Value},
|
||||
};
|
||||
|
||||
pub mod value;
|
||||
|
||||
#[derive(Clone, Hash, PartialEq, Eq)]
|
||||
pub enum Constant {
|
||||
String(String),
|
||||
Loading…
Reference in New Issue
Block a user