feat: better builtins implementaion
get rid of circular references
This commit is contained in:
@@ -2,8 +2,8 @@ use std::rc::Rc;
|
||||
|
||||
use derive_more::Constructor;
|
||||
|
||||
use crate::vm::VM;
|
||||
use crate::error::Result;
|
||||
use crate::vm::VM;
|
||||
|
||||
use super::Value;
|
||||
|
||||
@@ -23,12 +23,16 @@ impl PartialEq for PrimOp<'_> {
|
||||
impl<'vm> PrimOp<'vm> {
|
||||
pub fn call(&self, vm: &'vm VM<'_>, args: Vec<Value<'vm>>) -> Result<Value<'vm>> {
|
||||
if (args.len()) < self.arity {
|
||||
Value::PartialPrimOp(PartialPrimOp {
|
||||
name: self.name,
|
||||
arity: self.arity - args.len(),
|
||||
args,
|
||||
func: self.func,
|
||||
}.into()).ok()
|
||||
Value::PartialPrimOp(
|
||||
PartialPrimOp {
|
||||
name: self.name,
|
||||
arity: self.arity - args.len(),
|
||||
args,
|
||||
func: self.func,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
.ok()
|
||||
} else if args.len() == self.arity {
|
||||
(self.func)(vm, args)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user