feat: ref
This commit is contained in:
@@ -5,20 +5,20 @@ use crate::vm::VM;
|
||||
use super::Value;
|
||||
|
||||
#[derive(Debug, Clone, Constructor)]
|
||||
pub struct PrimOp {
|
||||
pub struct PrimOp<'vm> {
|
||||
pub name: &'static str,
|
||||
arity: u8,
|
||||
func: fn(&VM, Vec<Value>) -> Value,
|
||||
func: fn(&VM<'vm>, Vec<Value<'vm>>) -> Value<'vm>,
|
||||
}
|
||||
|
||||
impl PartialEq for PrimOp {
|
||||
impl PartialEq for PrimOp<'_> {
|
||||
fn eq(&self, _: &Self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl PrimOp {
|
||||
pub fn call(self, vm: &VM, args: Vec<Value>) -> Value {
|
||||
impl<'vm> PrimOp<'vm> {
|
||||
pub fn call(self, vm: &VM<'vm>, args: Vec<Value<'vm>>) -> Value<'vm> {
|
||||
if (args.len() as u8) < self.arity {
|
||||
Value::PartialPrimOp(PartialPrimOp {
|
||||
name: self.name,
|
||||
@@ -35,21 +35,21 @@ impl PrimOp {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PartialPrimOp {
|
||||
pub struct PartialPrimOp<'vm> {
|
||||
pub name: &'static str,
|
||||
arity: u8,
|
||||
args: Vec<Value>,
|
||||
func: fn(&VM, Vec<Value>) -> Value,
|
||||
args: Vec<Value<'vm>>,
|
||||
func: fn(&VM<'vm>, Vec<Value<'vm>>) -> Value<'vm>,
|
||||
}
|
||||
|
||||
impl PartialEq for PartialPrimOp {
|
||||
impl PartialEq for PartialPrimOp<'_> {
|
||||
fn eq(&self, _: &Self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialPrimOp {
|
||||
pub fn call(mut self, vm: &VM, args: Vec<Value>) -> Value {
|
||||
impl<'vm> PartialPrimOp<'vm> {
|
||||
pub fn call(mut self, vm: &VM<'vm>, args: Vec<Value<'vm>>) -> Value<'vm> {
|
||||
let len = args.len() as u8;
|
||||
self.args.extend(args);
|
||||
if len < self.arity {
|
||||
|
||||
Reference in New Issue
Block a user