Skip to content

Commit

Permalink
feat(ecmascript): Implement JSON.stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen committed Jan 13, 2025
1 parent a358a0f commit 01c4882
Show file tree
Hide file tree
Showing 5 changed files with 668 additions and 8 deletions.
22 changes: 22 additions & 0 deletions nova_vm/src/ecmascript/builtins/primitive_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,28 @@ impl TryFrom<PrimitiveObjectData> for Symbol<'_> {
}
}

impl IntoValue for PrimitiveObjectData {
fn into_value(self) -> Value {
self.into()
}
}

impl From<PrimitiveObjectData> for Value {
fn from(value: PrimitiveObjectData) -> Self {
match value {
PrimitiveObjectData::Boolean(data) => Value::Boolean(data),
PrimitiveObjectData::String(data) => Value::String(data),
PrimitiveObjectData::SmallString(data) => Value::SmallString(data),
PrimitiveObjectData::Symbol(data) => Value::Symbol(data),
PrimitiveObjectData::Number(data) => Value::Number(data),
PrimitiveObjectData::Integer(data) => Value::Integer(data),
PrimitiveObjectData::Float(data) => Value::SmallF64(data),
PrimitiveObjectData::BigInt(data) => Value::BigInt(data),
PrimitiveObjectData::SmallBigInt(data) => Value::SmallBigInt(data),
}
}
}

#[derive(Debug, Clone, Copy)]
pub struct PrimitiveObjectHeapData {
pub(crate) object_index: Option<OrdinaryObject<'static>>,
Expand Down
Loading

0 comments on commit 01c4882

Please sign in to comment.