feat: initial parallel impl

This commit is contained in:
2025-06-08 17:27:43 +08:00
parent 3797544fc2
commit 7293cb9f75
18 changed files with 529 additions and 934 deletions

View File

@@ -11,7 +11,7 @@ use super::Value;
pub struct PrimOp {
pub name: &'static str,
arity: usize,
func: for<'gc> fn(Vec<Value<'gc>>, &Engine) -> Result<Value<'gc>>,
func: fn(Vec<Value>, &Engine) -> Result<Value>,
}
impl PartialEq for PrimOp {
@@ -21,7 +21,7 @@ impl PartialEq for PrimOp {
}
impl PrimOp {
pub fn call<'gc>(&self, arg: Value<'gc>, ctx: &Engine) -> Result<Value<'gc>> {
pub fn call(&self, arg: Value, ctx: &Engine) -> Result<Value> {
let mut args = Vec::with_capacity(self.arity);
args.push(arg);
if self.arity > 1 {
@@ -39,21 +39,21 @@ impl PrimOp {
}
#[derive(Clone)]
pub struct PartialPrimOp<'gc> {
pub struct PartialPrimOp {
pub name: &'static str,
arity: usize,
args: Vec<Value<'gc>>,
func: fn(Vec<Value<'gc>>, &Engine) -> Result<Value<'gc>>,
args: Vec<Value>,
func: fn(Vec<Value>, &Engine) -> Result<Value>,
}
impl PartialEq for PartialPrimOp<'_> {
impl PartialEq for PartialPrimOp {
fn eq(&self, _: &Self) -> bool {
false
}
}
impl<'gc> PartialPrimOp<'gc> {
pub fn call(self: &mut Rc<Self>, arg: Value<'gc>, ctx: &Engine) -> Result<Value<'gc>> {
impl PartialPrimOp {
pub fn call(self: &mut Rc<Self>, arg: Value, ctx: &Engine) -> Result<Value> {
let func = self.func;
let Some(ret) = ({
let self_mut = Rc::make_mut(self);