feat: initial parallel impl
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
use std::ops::Deref;
|
||||
use std::rc::Weak;
|
||||
|
||||
use ecow::EcoVec;
|
||||
use hashbrown::HashSet;
|
||||
|
||||
use crate::env::VmEnv;
|
||||
@@ -9,50 +11,64 @@ use crate::engine::Engine;
|
||||
use super::Value;
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct List<'gc> {
|
||||
data: Vec<Value<'gc>>,
|
||||
pub struct List {
|
||||
data: EcoVec<Value>,
|
||||
}
|
||||
|
||||
impl<'gc> Default for List<'gc> {
|
||||
impl Default for List {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'gc> List<'gc> {
|
||||
impl<'gc, T: Into<EcoVec<Value>>> From<T> for List {
|
||||
fn from(value: T) -> Self {
|
||||
Self { data: value.into() }
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for List {
|
||||
type Target = [Value];
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.data
|
||||
}
|
||||
}
|
||||
|
||||
impl List {
|
||||
pub fn new() -> Self {
|
||||
List { data: Vec::new() }
|
||||
List { data: EcoVec::new() }
|
||||
}
|
||||
|
||||
pub fn with_capacity(cap: usize) -> Self {
|
||||
List {
|
||||
data: Vec::with_capacity(cap),
|
||||
data: EcoVec::with_capacity(cap),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push(&mut self, elem: Value<'gc>) {
|
||||
pub fn push(&mut self, elem: Value) {
|
||||
self.data.push(elem);
|
||||
}
|
||||
|
||||
pub fn concat(&mut self, other: &List<'gc>) {
|
||||
pub fn concat(&mut self, other: &List) {
|
||||
for elem in other.data.iter() {
|
||||
self.data.push(elem.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn capture(&mut self, env: &Weak<VmEnv<'gc>>) {
|
||||
pub fn capture(&mut self, env: &Weak<VmEnv>) {
|
||||
self.data.iter().for_each(|v| {
|
||||
if let Value::Thunk(ref thunk) = v.clone() {
|
||||
thunk.capture_env_weak(env.clone());
|
||||
todo!()
|
||||
// thunk.capture_env_weak(env.clone());
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> Vec<Value<'gc>> {
|
||||
pub fn into_inner(self) -> EcoVec<Value> {
|
||||
self.data
|
||||
}
|
||||
|
||||
pub fn to_public(&self, engine: &'gc Engine, seen: &mut HashSet<Value<'gc>>) -> p::Value {
|
||||
pub fn to_public(&self, engine: &Engine, seen: &mut HashSet<Value>) -> p::Value {
|
||||
p::Value::List(p::List::new(
|
||||
self.data
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user