mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Implement direct class comparison
This commit is contained in:
@@ -197,6 +197,7 @@ impl Assembler {
|
||||
|
||||
fn class(&mut self, class: &Class) {
|
||||
self.output.push(ValueType::Class as u8);
|
||||
self.meta(&class.meta);
|
||||
self.value(&class.constructor);
|
||||
self.value(&class.prototype);
|
||||
self.value(&class.static_);
|
||||
|
||||
@@ -256,6 +256,11 @@ impl Kal {
|
||||
}
|
||||
Kal::Function(_) => return None,
|
||||
Kal::Class(class) => VsClass {
|
||||
name: class.meta.name,
|
||||
content_hash: match class.meta.content_hashable {
|
||||
asm::ContentHashable::Empty | asm::ContentHashable::Src(_, _) => None,
|
||||
asm::ContentHashable::Content(hash) => Some(hash.0),
|
||||
},
|
||||
constructor: class.constructor.try_to_val()?,
|
||||
prototype: class.prototype.try_to_val()?,
|
||||
static_: class.static_.try_to_val()?,
|
||||
|
||||
@@ -6,7 +6,7 @@ use valuescript_vm::{
|
||||
vs_value::{ToVal, Val},
|
||||
};
|
||||
|
||||
use crate::asm::{Number, Value};
|
||||
use crate::asm::{ContentHashable, Number, Value};
|
||||
|
||||
pub trait TryToVal {
|
||||
fn try_to_val(self) -> Result<Val, Val>;
|
||||
@@ -45,6 +45,11 @@ impl TryToVal for Value {
|
||||
.to_val()
|
||||
}
|
||||
Value::Class(class) => VsClass {
|
||||
name: class.meta.name,
|
||||
content_hash: match class.meta.content_hashable {
|
||||
ContentHashable::Empty | ContentHashable::Src(_, _) => None,
|
||||
ContentHashable::Content(hash) => Some(hash.0),
|
||||
},
|
||||
constructor: class.constructor.try_to_val()?,
|
||||
prototype: class.prototype.try_to_val()?,
|
||||
static_: class.static_.try_to_val()?,
|
||||
|
||||
Reference in New Issue
Block a user