mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
VsFunctionMetadata
This commit is contained in:
@@ -10,6 +10,7 @@ use crate::builtins::BUILTIN_VALS;
|
||||
use crate::bytecode::Bytecode;
|
||||
use crate::vs_class::VsClass;
|
||||
use crate::vs_function::VsFunction;
|
||||
use crate::vs_function_metadata::VsFunctionMetadata;
|
||||
use crate::vs_object::VsObject;
|
||||
use crate::vs_symbol::VsSymbol;
|
||||
use crate::vs_value::ToVal;
|
||||
@@ -292,7 +293,10 @@ impl BytecodeDecoder {
|
||||
|
||||
VsFunction {
|
||||
bytecode: self.bytecode.clone(),
|
||||
hash,
|
||||
metadata: VsFunctionMetadata {
|
||||
name: Rc::from(""),
|
||||
hash,
|
||||
},
|
||||
is_generator,
|
||||
register_count,
|
||||
parameter_count,
|
||||
|
||||
@@ -23,6 +23,7 @@ mod virtual_machine;
|
||||
pub mod vs_array;
|
||||
pub mod vs_class;
|
||||
mod vs_function;
|
||||
mod vs_function_metadata;
|
||||
pub mod vs_object;
|
||||
mod vs_symbol;
|
||||
pub mod vs_value;
|
||||
|
||||
@@ -194,7 +194,7 @@ pub fn op_eq_impl(left: &Val, right: &Val) -> Result<bool, Val> {
|
||||
}
|
||||
}
|
||||
|
||||
left.hash == right.hash
|
||||
left.metadata.hash == right.metadata.hash
|
||||
}
|
||||
_ => {
|
||||
if left.is_truthy() != right.is_truthy() {
|
||||
@@ -316,7 +316,7 @@ pub fn op_triple_eq_impl(left: &Val, right: &Val) -> Result<bool, Val> {
|
||||
}
|
||||
}
|
||||
|
||||
left.hash == right.hash
|
||||
left.metadata.hash == right.metadata.hash
|
||||
}
|
||||
#[allow(clippy::vtable_address_comparisons)] // TODO: Is this ok?
|
||||
(Val::Static(left), Val::Static(right)) => std::ptr::eq(&**left, &**right),
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::rc::Rc;
|
||||
|
||||
use crate::bytecode::Bytecode;
|
||||
use crate::make_generator_frame::MakeGeneratorFrame;
|
||||
use crate::vs_function_metadata::VsFunctionMetadata;
|
||||
use crate::vs_value::ToVal;
|
||||
|
||||
use super::bytecode_decoder::BytecodeDecoder;
|
||||
@@ -12,7 +13,7 @@ use super::vs_value::Val;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VsFunction {
|
||||
pub bytecode: Rc<Bytecode>,
|
||||
pub hash: [u8; 32],
|
||||
pub metadata: VsFunctionMetadata,
|
||||
pub is_generator: bool,
|
||||
pub register_count: usize,
|
||||
pub parameter_count: usize,
|
||||
@@ -30,7 +31,7 @@ impl VsFunction {
|
||||
|
||||
VsFunction {
|
||||
bytecode: self.bytecode.clone(),
|
||||
hash: self.hash,
|
||||
metadata: self.metadata.clone(),
|
||||
is_generator: self.is_generator,
|
||||
register_count: self.register_count,
|
||||
parameter_count: self.parameter_count,
|
||||
|
||||
7
valuescript_vm/src/vs_function_metadata.rs
Normal file
7
valuescript_vm/src/vs_function_metadata.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VsFunctionMetadata {
|
||||
pub name: Rc<str>,
|
||||
pub hash: [u8; 32],
|
||||
}
|
||||
Reference in New Issue
Block a user