Skip to content

Commit

Permalink
move PropertyKey
Browse files Browse the repository at this point in the history
  • Loading branch information
y21 committed Dec 29, 2024
1 parent 39e42fe commit 76bdcf4
Show file tree
Hide file tree
Showing 25 changed files with 138 additions and 160 deletions.
3 changes: 2 additions & 1 deletion crates/dash_rt/src/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ use dash_vm::util::intern_f64;
use dash_vm::value::array::{Array, ArrayIterator};
use dash_vm::value::arraybuffer::ArrayBuffer;
use dash_vm::value::error::Error;
use dash_vm::value::propertykey::PropertyKey;
use dash_vm::value::typedarray::TypedArray;
use dash_vm::value::{Typeof, Unpack, ValueKind};

use dash_vm::value::object::{Object, PropertyDataDescriptor, PropertyKey, PropertyValueKind};
use dash_vm::value::object::{Object, PropertyDataDescriptor, PropertyValueKind};
use dash_vm::value::ops::conversions::ValueConversion;
use dash_vm::value::primitive::Number;
use dash_vm::value::root_ext::RootErrExt;
Expand Down
7 changes: 4 additions & 3 deletions crates/dash_rt_net/src/listener/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use dash_vm::value::function::{Function, FunctionKind};
use dash_vm::value::object::{NamedObject, Object, PropertyValue};
use dash_vm::value::ops::conversions::ValueConversion;
use dash_vm::value::promise::Promise;
use dash_vm::value::propertykey::PropertyKey;
use dash_vm::value::{Unpack, Unrooted, Value};
use dash_vm::{PromiseAction, delegate, extract, throw};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
Expand All @@ -29,15 +30,15 @@ impl Object for TcpListenerConstructor {
fn get_own_property_descriptor(
&self,
_sc: &mut dash_vm::localscope::LocalScope,
_key: dash_vm::value::object::PropertyKey,
_key: PropertyKey,
) -> Result<Option<dash_vm::value::object::PropertyValue>, dash_vm::value::Unrooted> {
Ok(None)
}

fn set_property(
&self,
_sc: &mut dash_vm::localscope::LocalScope,
_key: dash_vm::value::object::PropertyKey,
_key: PropertyKey,
_value: dash_vm::value::object::PropertyValue,
) -> Result<(), dash_vm::value::Value> {
Ok(())
Expand All @@ -46,7 +47,7 @@ impl Object for TcpListenerConstructor {
fn delete_property(
&self,
_sc: &mut dash_vm::localscope::LocalScope,
_key: dash_vm::value::object::PropertyKey,
_key: PropertyKey,
) -> Result<dash_vm::value::Unrooted, dash_vm::value::Value> {
Ok(Unrooted::new(Value::undefined()))
}
Expand Down
6 changes: 4 additions & 2 deletions crates/dash_vm/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ mod extract {
use dash_middle::iterator_with::IteratorWith;

use crate::gc::ObjectId;
use crate::value::object::{PropertyKey, PropertyValue};
use crate::value::object::PropertyValue;
use crate::value::ops::conversions::ValueConversion;
use crate::value::propertykey::PropertyKey;
use crate::value::string::JsString;
use crate::value::{Unpack, Unrooted, Value, ValueKind};

Expand Down Expand Up @@ -576,10 +577,11 @@ mod handlers {
use crate::value::function::generator::GeneratorFunction;
use crate::value::function::user::UserFunction;
use crate::value::function::{Function, FunctionKind, adjust_stack_from_flat_call, this_for_new_target};
use crate::value::object::{NamedObject, Object, ObjectMap, PropertyKey, PropertyValue, PropertyValueKind};
use crate::value::object::{NamedObject, Object, ObjectMap, PropertyValue, PropertyValueKind};
use crate::value::ops::conversions::ValueConversion;
use crate::value::ops::equality;
use crate::value::primitive::Number;
use crate::value::propertykey::PropertyKey;
use crate::value::regex::RegExp;
use crate::value::{Unpack, ValueKind};

Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/gc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ use crate::Vm;
use crate::frame::This;
use crate::localscope::LocalScope;
use crate::value::function::args::CallArgs;
use crate::value::object::{PropertyKey, PropertyValue};
use crate::value::object::PropertyValue;
use crate::value::primitive::InternalSlots;
use crate::value::propertykey::PropertyKey;
use crate::value::{Typeof, Unrooted, Value};

pub mod persistent;
Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/js_std/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use crate::throw;
use crate::value::array::{Array, ArrayIterator, require_valid_array_length};
use crate::value::function::args::CallArgs;
use crate::value::function::native::CallContext;
use crate::value::object::{NamedObject, Object as _, PropertyKey, PropertyValue};
use crate::value::object::{NamedObject, Object as _, PropertyValue};
use crate::value::ops::conversions::ValueConversion;
use crate::value::ops::equality::strict_eq;
use crate::value::propertykey::PropertyKey;
use crate::value::root_ext::RootErrExt;
use crate::value::string::JsString;
use crate::value::{Root, Unpack, Value, ValueContext, array};
Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/js_std/map.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::throw;
use crate::value::function::native::CallContext;
use crate::value::map::Map;
use crate::value::object::{NamedObject, PropertyKey};
use crate::value::object::NamedObject;
use crate::value::ops::conversions::ValueConversion;
use crate::value::propertykey::PropertyKey;
use crate::value::{Root, Value, ValueContext};
use dash_middle::interner::sym;

Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/js_std/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use crate::localscope::LocalScope;
use crate::throw;
use crate::value::array::Array;
use crate::value::function::native::CallContext;
use crate::value::object::{IntegrityLevel, NamedObject, Object, PropertyDataDescriptor, PropertyKey, PropertyValue};
use crate::value::object::{IntegrityLevel, NamedObject, Object, PropertyDataDescriptor, PropertyValue};
use crate::value::ops::conversions::ValueConversion;
use crate::value::propertykey::PropertyKey;
use crate::value::root_ext::RootErrExt;
use crate::value::{Root, Typeof, Unpack, Value, ValueContext, ValueKind};
use dash_middle::interner::sym;
Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/js_std/promise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use crate::gc::ObjectId;
use crate::value::function::args::CallArgs;
use crate::value::function::bound::BoundFunction;
use crate::value::function::native::CallContext;
use crate::value::object::{NamedObject, Object, PropertyKey};
use crate::value::object::{NamedObject, Object};
use crate::value::promise::{Promise, PromiseRejecter, PromiseResolver, PromiseState};
use crate::value::propertykey::PropertyKey;
use crate::value::root_ext::RootErrExt;
use crate::value::{Root, Typeof, Unpack, Unrooted, Value, ValueContext, ValueKind};
use crate::{Vm, delegate, extract, throw};
Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/js_std/set.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::throw;
use crate::value::function::native::CallContext;
use crate::value::object::{NamedObject, PropertyKey};
use crate::value::object::NamedObject;
use crate::value::ops::conversions::ValueConversion;
use crate::value::propertykey::PropertyKey;
use crate::value::set::Set;
use crate::value::{Root, Value, ValueContext};

Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/js_std/weakmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use dash_middle::interner::sym;

use crate::throw;
use crate::value::function::native::CallContext;
use crate::value::object::{NamedObject, PropertyKey};
use crate::value::object::NamedObject;
use crate::value::ops::conversions::ValueConversion;
use crate::value::propertykey::PropertyKey;
use crate::value::weakmap::WeakMap;
use crate::value::{Root, Value, ValueContext};

Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/js_std/weakset.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::throw;
use crate::value::function::native::CallContext;
use crate::value::object::{NamedObject, PropertyKey};
use crate::value::object::NamedObject;
use crate::value::ops::conversions::ValueConversion;
use crate::value::propertykey::PropertyKey;
use crate::value::weakset::WeakSet;
use crate::value::{Root, Value, ValueContext};

Expand Down
42 changes: 3 additions & 39 deletions crates/dash_vm/src/json/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use std::str::Utf8Error;
use dash_middle::util;

use crate::localscope::LocalScope;
use crate::value::array::Array;
use crate::value::object::{NamedObject, ObjectMap, PropertyKey, PropertyValue};
use crate::value::Value;
use crate::value::array::Array;
use crate::value::object::{NamedObject, ObjectMap, PropertyValue};
use crate::value::propertykey::PropertyKey;

/// An error that occurred during parsing JSON
///
Expand Down Expand Up @@ -61,43 +62,6 @@ impl From<Utf8Error> for ConversionError {
}
}

// impl<'a> Value<'a> {
// /// Attempts to convert a JSON value to a JavaScript value
// pub(crate) fn into_js_value(self, vm: &VM) -> Result<JsValue, ConversionError> {
// match self {
// Self::String(s) => std::str::from_utf8(s)
// .map(String::from)
// .map(|s| vm.create_js_value(s))
// .map_err(Into::into),
// Self::Number(n) => Ok(vm.create_js_value(n)),
// Self::Bool(b) => Ok(vm.create_js_value(b)),
// Self::Array(arr) => Ok(vm.create_js_value(Array::new({
// let mut js_arr = Vec::with_capacity(arr.len());

// for value in arr {
// js_arr.push(value.into_js_value(vm).map(|v| v.into_handle(vm))?);
// }

// js_arr
// }))),
// Self::Object(obj) => {
// let mut js_obj = vm.create_object();

// for (key, value) in obj {
// let key = std::str::from_utf8(key)?;
// js_obj.set_property(
// String::from(key).into_boxed_str(),
// value.into_js_value(vm)?.into_handle(vm),
// );
// }

// Ok(js_obj)
// }
// Self::Null => Ok(JsValue::new(ValueKind::Null)),
// }
// }
// }

/// A tiny, zero-copy JSON parser that borrows from the input string
pub struct Parser<'a, 'sc, 'vm> {
source: &'a [u8],
Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/value/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use dash_proc_macro::Trace;
use crate::localscope::LocalScope;
use crate::{delegate, extract};

use super::object::{NamedObject, Object, PropertyKey, PropertyValue};
use super::Value;
use super::object::{NamedObject, Object, PropertyValue};
use super::propertykey::PropertyKey;

#[derive(Debug, Clone, Trace)]
pub struct Arguments {
Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/value/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ use crate::{Vm, delegate, extract, throw};
use dash_middle::interner::sym;

use super::function::args::CallArgs;
use super::object::{NamedObject, Object, PropertyKey, PropertyValue, PropertyValueKind};
use super::object::{NamedObject, Object, PropertyValue, PropertyValueKind};
use super::ops::conversions::ValueConversion;
use super::primitive::array_like_keys;
use super::propertykey::PropertyKey;
use super::root_ext::RootErrExt;
use super::{Root, Unpack, Unrooted, Value};

Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/value/boxed.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use super::ops::conversions::{PreferredType, ValueConversion};
use crate::gc::ObjectId;
use crate::localscope::LocalScope;
use crate::value::{JsString, PropertyKey, Unrooted};
use crate::value::propertykey::PropertyKey;
use crate::value::{JsString, Unrooted};
use crate::{PropertyValue, Vm, delegate, extract};
use dash_proc_macro::Trace;

Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/value/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use crate::localscope::LocalScope;
use crate::{delegate, extract};

use super::function::args::CallArgs;
use super::object::{NamedObject, Object, PropertyKey, PropertyValue};
use super::object::{NamedObject, Object, PropertyValue};
use super::string::JsString;
use super::{Unrooted, Value};
use crate::value::propertykey::PropertyKey;

#[derive(Debug, Trace)]
pub struct Error {
Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/value/function/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use dash_proc_macro::Trace;
use crate::frame::This;
use crate::gc::ObjectId;
use crate::localscope::LocalScope;
use crate::value::object::{NamedObject, Object, PropertyKey};
use crate::value::object::{NamedObject, Object};
use crate::value::promise::{Promise, wrap_promise};
use crate::value::propertykey::PropertyKey;
use crate::value::root_ext::RootErrExt;
use crate::value::{Root, Typeof, Unpack, Unrooted, Value, ValueContext};
use crate::{PromiseAction, Vm, delegate, extract, throw};
Expand Down
3 changes: 2 additions & 1 deletion crates/dash_vm/src/value/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ use self::native::{CallContext, NativeFunction};
use self::user::UserFunction;

use super::array::Array;
use super::object::{NamedObject, Object, PropertyDataDescriptor, PropertyKey, PropertyValue, PropertyValueKind};
use super::object::{NamedObject, Object, PropertyDataDescriptor, PropertyValue, PropertyValueKind};
use super::ops::conversions::ValueConversion;
use super::propertykey::PropertyKey;
use super::string::JsString;
use super::{Root, Typeof, Unpack, Unrooted, Value, ValueKind};

Expand Down
4 changes: 3 additions & 1 deletion crates/dash_vm/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod object;
pub mod ops;
pub mod primitive;
pub mod promise;
pub mod propertykey;
pub mod regex;
pub mod set;
pub mod typedarray;
Expand All @@ -34,10 +35,11 @@ use crate::util::cold_path;
use crate::value::primitive::{Null, Undefined};
use crate::{Vm, delegate, throw};

use self::object::{Object, PropertyKey, PropertyValue};
use self::object::{Object, PropertyValue};
use self::primitive::{InternalSlots, Number, Symbol};
use self::string::JsString;
use super::localscope::LocalScope;
use crate::value::propertykey::PropertyKey;

/// Implements the `Object::extract_type_raw` function by checking the type id of the implementer and the provided fields
#[macro_export]
Expand Down
Loading

0 comments on commit 76bdcf4

Please sign in to comment.