mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-11 06:27:56 -05:00
Move Vallish into file
This commit is contained in:
@@ -13,6 +13,7 @@ use crate::vs_object::VsObject;
|
||||
use crate::vs_symbol::VsSymbol;
|
||||
use crate::vs_value::ToVal;
|
||||
use crate::vs_value::Val;
|
||||
use crate::Vallish;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct BytecodeDecoder {
|
||||
@@ -308,24 +309,3 @@ impl BytecodeDecoder {
|
||||
return InstructionByte::from_byte(self.decode_byte());
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Vallish<'a> {
|
||||
Own(Val),
|
||||
Ref(&'a Val),
|
||||
}
|
||||
|
||||
impl<'a> Vallish<'a> {
|
||||
pub fn get_own(self) -> Val {
|
||||
match self {
|
||||
Vallish::Own(val) => val,
|
||||
Vallish::Ref(val) => val.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_ref(&self) -> &Val {
|
||||
match self {
|
||||
Vallish::Own(val) => val,
|
||||
Vallish::Ref(val) => val,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ use valuescript_common::InstructionByte;
|
||||
use crate::builtins::type_error_builtin::ToTypeError;
|
||||
use crate::bytecode_decoder::BytecodeDecoder;
|
||||
use crate::bytecode_decoder::BytecodeType;
|
||||
use crate::bytecode_decoder::Vallish;
|
||||
use crate::cat_stack_frame::CatStackFrame;
|
||||
use crate::native_function::ThisWrapper;
|
||||
use crate::operations;
|
||||
use crate::stack_frame::FrameStepOk;
|
||||
use crate::stack_frame::FrameStepResult;
|
||||
use crate::stack_frame::{CallResult, StackFrame, StackFrameTrait};
|
||||
use crate::vallish::Vallish;
|
||||
use crate::vs_object::VsObject;
|
||||
use crate::vs_value::ToVal;
|
||||
use crate::vs_value::{LoadFunctionResult, Val, ValTrait};
|
||||
|
||||
@@ -2,10 +2,10 @@ use std::{mem::take, rc::Rc};
|
||||
|
||||
use crate::{
|
||||
builtins::type_error_builtin::ToTypeError,
|
||||
bytecode_decoder::Vallish,
|
||||
native_function::ThisWrapper,
|
||||
operations::op_sub,
|
||||
stack_frame::{CallResult, FrameStepOk, FrameStepResult, StackFrame, StackFrameTrait},
|
||||
vallish::Vallish,
|
||||
vs_symbol::VsSymbol,
|
||||
vs_value::{ToVal, Val},
|
||||
LoadFunctionResult, ValTrait,
|
||||
|
||||
@@ -18,6 +18,7 @@ pub mod operations;
|
||||
mod stack_frame;
|
||||
mod string_methods;
|
||||
mod todo_fn;
|
||||
mod vallish;
|
||||
mod virtual_machine;
|
||||
pub mod vs_array;
|
||||
mod vs_class;
|
||||
@@ -27,6 +28,6 @@ mod vs_symbol;
|
||||
pub mod vs_value;
|
||||
|
||||
pub use bytecode::Bytecode;
|
||||
pub use bytecode_decoder::Vallish;
|
||||
pub use vallish::Vallish;
|
||||
pub use virtual_machine::VirtualMachine;
|
||||
pub use vs_value::{LoadFunctionResult, ValTrait};
|
||||
|
||||
@@ -7,11 +7,11 @@ use crate::bigint_methods::op_sub_bigint;
|
||||
use crate::builtins::error_builtin::ToError;
|
||||
use crate::builtins::range_error_builtin::ToRangeError;
|
||||
use crate::builtins::type_error_builtin::ToTypeError;
|
||||
use crate::bytecode_decoder::Vallish;
|
||||
use crate::native_function::native_fn;
|
||||
use crate::native_function::NativeFunction;
|
||||
use crate::number_methods::op_sub_number;
|
||||
use crate::string_methods::op_sub_string;
|
||||
use crate::vallish::Vallish;
|
||||
use crate::vs_value::ToVal;
|
||||
use crate::vs_value::Val;
|
||||
use crate::vs_value::ValTrait;
|
||||
|
||||
22
valuescript_vm/src/vallish.rs
Normal file
22
valuescript_vm/src/vallish.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use crate::vs_value::Val;
|
||||
|
||||
pub enum Vallish<'a> {
|
||||
Own(Val),
|
||||
Ref(&'a Val),
|
||||
}
|
||||
|
||||
impl<'a> Vallish<'a> {
|
||||
pub fn get_own(self) -> Val {
|
||||
match self {
|
||||
Vallish::Own(val) => val,
|
||||
Vallish::Ref(val) => val.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_ref(&self) -> &Val {
|
||||
match self {
|
||||
Vallish::Own(val) => val,
|
||||
Vallish::Ref(val) => val,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,13 @@ use crate::array_higher_functions::{
|
||||
};
|
||||
use crate::builtins::error_builtin::ToError;
|
||||
use crate::builtins::type_error_builtin::ToTypeError;
|
||||
use crate::bytecode_decoder::Vallish;
|
||||
use crate::helpers::{to_wrapping_index, to_wrapping_index_clamped};
|
||||
use crate::iteration::array_entries_iterator::ArrayEntriesIterator;
|
||||
use crate::iteration::array_iterator::ArrayIterator;
|
||||
use crate::native_function::{native_fn, NativeFunction};
|
||||
use crate::operations::op_triple_eq_impl;
|
||||
use crate::todo_fn::TODO;
|
||||
use crate::vallish::Vallish;
|
||||
use crate::vs_class::VsClass;
|
||||
use crate::vs_object::VsObject;
|
||||
use crate::vs_symbol::VsSymbol;
|
||||
|
||||
@@ -7,11 +7,11 @@ use num_bigint::BigInt;
|
||||
use num_traits::cast::ToPrimitive;
|
||||
use num_traits::Zero;
|
||||
|
||||
use crate::bytecode_decoder::Vallish;
|
||||
use crate::copy_counter::CopyCounter;
|
||||
use crate::native_function::ThisWrapper;
|
||||
use crate::operations::{op_sub, op_submov};
|
||||
use crate::stack_frame::StackFrame;
|
||||
use crate::vallish::Vallish;
|
||||
use crate::vs_array::VsArray;
|
||||
use crate::vs_class::VsClass;
|
||||
use crate::vs_function::VsFunction;
|
||||
|
||||
Reference in New Issue
Block a user