use crate::JsValue;
use boa_gc::{Finalize, GcRefCell, Trace};
#[derive(Debug, Trace, Finalize)]
pub(crate) struct GlobalEnvironment {
bindings: GcRefCell<Vec<Option<JsValue>>>,
}
impl GlobalEnvironment {
pub(crate) fn new() -> Self {
Self {
bindings: GcRefCell::new(Vec::new()),
}
}
#[track_caller]
pub(crate) fn get(&self, index: u32) -> Option<JsValue> {
self.bindings.borrow()[index as usize].clone()
}
#[track_caller]
pub(crate) fn set(&self, index: u32, value: JsValue) {
self.bindings.borrow_mut()[index as usize] = Some(value);
}
pub(crate) const fn bindings(&self) -> &GcRefCell<Vec<Option<JsValue>>> {
&self.bindings
}
}