1- use crate :: core:: { ClassDefinition , DestructuringElement , Statement } ;
21use crate :: core:: { Collect , FunctionID , Gc , GcPtr , GcTrace } ;
32use crate :: unicode:: utf16_to_utf8;
43use indexmap:: IndexMap ;
54use num_bigint:: BigInt ;
5+
66/// VM Map storage (simple Vec of key-value pairs).
77#[ derive( Clone , Collect ) ]
88#[ collect( no_drop) ]
99pub struct VmMapData < ' gc > {
1010 pub entries : Vec < ( Value < ' gc > , Value < ' gc > ) > ,
1111 pub is_weak : bool ,
1212}
13+
1314/// VM Set storage (simple Vec of values).
1415#[ derive( Clone , Collect ) ]
1516#[ collect( no_drop) ]
1617pub struct VmSetData < ' gc > {
1718 pub values : Vec < Value < ' gc > > ,
1819 pub is_weak : bool ,
1920}
21+
2022/// Array storage with optional named properties (e.g. `arr.foo = "bar"`).
2123#[ derive( Clone , Collect ) ]
2224#[ collect( no_drop) ]
@@ -43,53 +45,6 @@ impl<'gc> std::ops::DerefMut for VmArrayData<'gc> {
4345 & mut self . elements
4446 }
4547}
46- use std:: sync:: { Arc , Mutex } ;
47-
48- #[ derive( Clone , Debug , Collect , Default ) ]
49- #[ collect( require_static) ]
50- pub struct JSArrayBuffer {
51- pub data : Arc < Mutex < Vec < u8 > > > ,
52- pub detached : bool ,
53- pub shared : bool ,
54- pub max_byte_length : Option < usize > ,
55- /// Whether this ArrayBuffer is immutable (frozen data, cannot be written to or transferred)
56- pub immutable : bool ,
57- }
58- #[ derive( Clone , Collect ) ]
59- #[ collect( no_drop) ]
60- pub struct JSDataView < ' gc > {
61- pub buffer : GcPtr < ' gc , JSArrayBuffer > ,
62- pub byte_offset : usize ,
63- pub byte_length : usize ,
64- /// Whether this DataView was constructed without an explicit byteLength
65- /// (i.e. it tracks the buffer's current size minus offset).
66- pub length_tracking : bool ,
67- }
68- #[ derive( Clone , Debug , PartialEq , Collect ) ]
69- #[ collect( require_static) ]
70- pub enum TypedArrayKind {
71- Int8 ,
72- Uint8 ,
73- Uint8Clamped ,
74- Int16 ,
75- Uint16 ,
76- Int32 ,
77- Uint32 ,
78- Float16 ,
79- Float32 ,
80- Float64 ,
81- BigInt64 ,
82- BigUint64 ,
83- }
84- #[ derive( Clone , Collect ) ]
85- #[ collect( no_drop) ]
86- pub struct JSTypedArray < ' gc > {
87- pub kind : TypedArrayKind ,
88- pub buffer : GcPtr < ' gc , JSArrayBuffer > ,
89- pub byte_offset : usize ,
90- pub length : usize ,
91- pub length_tracking : bool ,
92- }
9348
9449#[ derive( Clone , Debug , Collect ) ]
9550#[ collect( require_static) ]
@@ -116,17 +71,6 @@ impl SymbolData {
11671 self . description . as_deref ( )
11772 }
11873}
119- #[ derive( Clone , Collect ) ]
120- #[ collect( no_drop) ]
121- pub struct ClosureData < ' gc > {
122- pub params : Vec < DestructuringElement > ,
123- pub body : Vec < Statement > ,
124- pub bound_this : Option < Value < ' gc > > ,
125- pub is_arrow : bool ,
126- pub is_strict : bool ,
127- pub native_target : Option < String > ,
128- pub enforce_strictness_inheritance : bool ,
129- }
13074
13175#[ derive( Clone ) ]
13276pub enum Value < ' gc > {
@@ -144,13 +88,6 @@ pub enum Value<'gc> {
14488 VmNativeFunction ( FunctionID ) ,
14589 VmMap ( crate :: core:: VmMapHandle < ' gc > ) ,
14690 VmSet ( crate :: core:: VmSetHandle < ' gc > ) ,
147- AsyncClosure ( Gc < ' gc , ClosureData < ' gc > > ) ,
148- GeneratorFunction ( Option < String > , Gc < ' gc , ClosureData < ' gc > > ) ,
149- AsyncGeneratorFunction ( Option < String > , Gc < ' gc , ClosureData < ' gc > > ) ,
150- ClassDefinition ( Gc < ' gc , ClassDefinition > ) ,
151- ArrayBuffer ( GcPtr < ' gc , JSArrayBuffer > ) ,
152- DataView ( Gc < ' gc , JSDataView < ' gc > > ) ,
153- PrivateName ( String , u32 ) ,
15491 /// Internal property representation stored in an object's `properties` map.
15592 /// Contains either a concrete `value` or accessor `getter`/`setter` functions.
15693 /// Note: a `Value::Property` is not the same as a JS descriptor object
@@ -207,12 +144,6 @@ impl From<&String> for Value<'_> {
207144unsafe impl < ' gc > Collect < ' gc > for Value < ' gc > {
208145 fn trace < T : GcTrace < ' gc > > ( & self , cc : & mut T ) {
209146 match self {
210- Value :: AsyncClosure ( cl) => cl. trace ( cc) ,
211- Value :: GeneratorFunction ( _, cl) => cl. trace ( cc) ,
212- Value :: AsyncGeneratorFunction ( _, cl) => cl. trace ( cc) ,
213- Value :: ClassDefinition ( cl) => cl. trace ( cc) ,
214- Value :: ArrayBuffer ( b) => b. trace ( cc) ,
215- Value :: DataView ( d) => d. trace ( cc) ,
216147 Value :: Property { value, getter, setter } => {
217148 if let Some ( v) = value {
218149 v. trace ( cc) ;
@@ -295,17 +226,6 @@ pub fn value_to_string<'gc>(val: &Value<'gc>) -> String {
295226 format ! ( "function [{name}]() {{ [native code] }}" )
296227 }
297228 }
298- Value :: AsyncClosure ( ..) => "async function" . to_string ( ) ,
299- Value :: GeneratorFunction ( name, ..) => {
300- format ! ( "function* {}" , name. as_deref( ) . unwrap_or( "" ) )
301- }
302- Value :: AsyncGeneratorFunction ( name, ..) => {
303- format ! ( "async function* {}" , name. as_deref( ) . unwrap_or( "" ) )
304- }
305- Value :: ClassDefinition ( ..) => "class" . to_string ( ) ,
306- Value :: PrivateName ( n, _) => format ! ( "#{n}" ) ,
307- Value :: ArrayBuffer ( _) => "[object ArrayBuffer]" . to_string ( ) ,
308- Value :: DataView ( _) => "[object DataView]" . to_string ( ) ,
309229 Value :: Property { .. } => "[Property]" . to_string ( ) ,
310230 Value :: Symbol ( sym) => {
311231 if let Some ( desc) = & sym. description {
0 commit comments