chore: cargo fmt
This commit is contained in:
@@ -91,11 +91,7 @@ impl<'ctx> Helpers<'ctx> {
|
|||||||
let call = module.add_function(
|
let call = module.add_function(
|
||||||
"call",
|
"call",
|
||||||
value_type.fn_type(
|
value_type.fn_type(
|
||||||
&[
|
&[value_type.into(), value_type.into(), ptr_type.into()],
|
||||||
value_type.into(),
|
|
||||||
value_type.into(),
|
|
||||||
ptr_type.into(),
|
|
||||||
],
|
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
@@ -142,7 +138,7 @@ impl<'ctx> Helpers<'ctx> {
|
|||||||
or,
|
or,
|
||||||
call,
|
call,
|
||||||
lookup,
|
lookup,
|
||||||
force
|
force,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +279,7 @@ extern "C" fn helper_eq(lhs: JITValue, rhs: JITValue) -> JITValue {
|
|||||||
(Int, Int) => JITValue {
|
(Int, Int) => JITValue {
|
||||||
tag: Bool,
|
tag: Bool,
|
||||||
data: JITValueData {
|
data: JITValueData {
|
||||||
bool: unsafe { lhs.data.int == rhs.data.int }
|
bool: unsafe { lhs.data.int == rhs.data.int },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
_ => todo!(
|
_ => todo!(
|
||||||
@@ -322,7 +318,9 @@ extern "C" fn helper_call<'jit, 'vm>(
|
|||||||
match func.tag {
|
match func.tag {
|
||||||
Function => {
|
Function => {
|
||||||
let func: Value = func.into();
|
let func: Value = func.into();
|
||||||
func.call(unsafe { vm.as_ref() }.unwrap(), vec![arg.into()]).unwrap().into()
|
func.call(unsafe { vm.as_ref() }.unwrap(), vec![arg.into()])
|
||||||
|
.unwrap()
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
@@ -332,7 +330,6 @@ extern "C" fn helper_call<'jit, 'vm>(
|
|||||||
extern "C" fn helper_lookup<'jit, 'vm>(sym: usize, env: *const LetEnv<'jit, 'vm>) -> JITValue {
|
extern "C" fn helper_lookup<'jit, 'vm>(sym: usize, env: *const LetEnv<'jit, 'vm>) -> JITValue {
|
||||||
let env = unsafe { env.as_ref() }.unwrap();
|
let env = unsafe { env.as_ref() }.unwrap();
|
||||||
let val = env.lookup(sym);
|
let val = env.lookup(sym);
|
||||||
dbg!(val.as_ref().unwrap().typename());
|
|
||||||
val.unwrap().into()
|
val.unwrap().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,14 +76,14 @@ impl From<Value<'_, '_>> for JITValue {
|
|||||||
Value::Func(func) => JITValue {
|
Value::Func(func) => JITValue {
|
||||||
tag: ValueTag::Function,
|
tag: ValueTag::Function,
|
||||||
data: JITValueData {
|
data: JITValueData {
|
||||||
ptr: Rc::into_raw(func) as *const _
|
ptr: Rc::into_raw(func) as *const _,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
Value::Thunk(thunk) => JITValue {
|
Value::Thunk(thunk) => JITValue {
|
||||||
tag: ValueTag::Thunk,
|
tag: ValueTag::Thunk,
|
||||||
data: JITValueData {
|
data: JITValueData {
|
||||||
ptr: Rc::into_raw(thunk) as *const _
|
ptr: Rc::into_raw(thunk) as *const _,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
@@ -371,13 +371,23 @@ impl<'vm, 'ctx: 'vm> JITContext<'ctx> {
|
|||||||
for _ in 0..arity {
|
for _ in 0..arity {
|
||||||
args.insert(0, stack.pop());
|
args.insert(0, stack.pop());
|
||||||
}
|
}
|
||||||
let func = self.builder
|
let func = self
|
||||||
.build_direct_call(self.helpers.force, &[stack.pop().into(), self.new_ptr(vm).into()], "force")?
|
.builder
|
||||||
|
.build_direct_call(
|
||||||
|
self.helpers.force,
|
||||||
|
&[stack.pop().into(), self.new_ptr(vm).into()],
|
||||||
|
"force",
|
||||||
|
)?
|
||||||
.try_as_basic_value()
|
.try_as_basic_value()
|
||||||
.left()
|
.left()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let ret = self.builder
|
let ret = self
|
||||||
.build_direct_call(self.helpers.call, &[func.into(), args[0].into(), self.new_ptr(vm).into()], "call")?
|
.builder
|
||||||
|
.build_direct_call(
|
||||||
|
self.helpers.call,
|
||||||
|
&[func.into(), args[0].into(), self.new_ptr(vm).into()],
|
||||||
|
"call",
|
||||||
|
)?
|
||||||
.try_as_basic_value()
|
.try_as_basic_value()
|
||||||
.left()
|
.left()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
|
|||||||
use Param::*;
|
use Param::*;
|
||||||
|
|
||||||
let env = match self.func.param.clone() {
|
let env = match self.func.param.clone() {
|
||||||
Ident(ident) => self.env.clone().enter_let([(ident.into(), arg)].into_iter()),
|
Ident(ident) => self
|
||||||
|
.env
|
||||||
|
.clone()
|
||||||
|
.enter_let([(ident.into(), arg)].into_iter()),
|
||||||
Formals {
|
Formals {
|
||||||
formals,
|
formals,
|
||||||
ellipsis,
|
ellipsis,
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ impl<'jit, 'vm> WithEnv<'jit, 'vm> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn enter_with(self, new: Rc<AttrSet<'jit, 'vm>>) -> Self {
|
pub fn enter_with(self, new: Rc<AttrSet<'jit, 'vm>>) -> Self {
|
||||||
let map = Rc::new(new
|
let map = Rc::new(
|
||||||
.as_inner()
|
new.as_inner()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(&k, v)| {
|
.map(|(&k, v)| {
|
||||||
(
|
(
|
||||||
@@ -81,7 +81,8 @@ impl<'jit, 'vm> WithEnv<'jit, 'vm> {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<HashMap<_, _>>()
|
.collect::<HashMap<_, _>>()
|
||||||
.into());
|
.into(),
|
||||||
|
);
|
||||||
let last = Some(self.into());
|
let last = Some(self.into());
|
||||||
WithEnv { last, map }
|
WithEnv { last, map }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user