feat: JIT (WIP)

This commit is contained in:
2025-05-11 14:57:05 +08:00
parent cfed44ebf4
commit d664d433dc
10 changed files with 38 additions and 22 deletions

View File

@@ -8,7 +8,7 @@ use super::Value;
pub struct PrimOp<'vm> {
pub name: &'static str,
arity: u8,
func: fn(&VM<'vm>, Vec<Value<'vm>>) -> Value<'vm>,
func: fn(&VM<'vm, '_>, Vec<Value<'vm>>) -> Value<'vm>,
}
impl PartialEq for PrimOp<'_> {
@@ -18,7 +18,7 @@ impl PartialEq for PrimOp<'_> {
}
impl<'vm> PrimOp<'vm> {
pub fn call(self, vm: &VM<'vm>, args: Vec<Value<'vm>>) -> Value<'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,
@@ -39,7 +39,7 @@ pub struct PartialPrimOp<'vm> {
pub name: &'static str,
arity: u8,
args: Vec<Value<'vm>>,
func: fn(&VM<'vm>, Vec<Value<'vm>>) -> Value<'vm>,
func: fn(&VM<'vm, '_>, Vec<Value<'vm>>) -> Value<'vm>,
}
impl PartialEq for PartialPrimOp<'_> {
@@ -49,7 +49,7 @@ impl PartialEq for PartialPrimOp<'_> {
}
impl<'vm> PartialPrimOp<'vm> {
pub fn call(mut self, vm: &VM<'vm>, args: Vec<Value<'vm>>) -> Value<'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 {