fix: PartialFunc

This commit is contained in:
2025-06-22 01:19:16 +08:00
parent 75e8705098
commit 20b5516101
13 changed files with 207 additions and 219 deletions

View File

@@ -30,8 +30,8 @@ impl JITCompile for HasAttr {
impl JITCompile for BinOp {
fn compile<'gc>(&self, ctx: &JITContext<'gc>, func: FunctionValue<'gc>) -> StructValue<'gc> {
use ValueTag::*;
use BinOpKind::*;
use ValueTag::*;
let lhs = self.lhs.compile(ctx, func);
let rhs = self.rhs.compile(ctx, func);
let lhs_tag = ctx.get_tag(lhs);
@@ -165,12 +165,10 @@ impl JITCompile for BinOp {
.build_switch(
tag,
fallback,
&[
(
ctx.helpers.const_int(((Bool as i64) << 8) + Bool as i64),
bool_bool,
),
],
&[(
ctx.helpers.const_int(((Bool as i64) << 8) + Bool as i64),
bool_bool,
)],
)
.unwrap();
ctx.builder.position_at_end(bool_bool);
@@ -189,7 +187,7 @@ impl JITCompile for BinOp {
.unwrap();
ctx.builder.position_at_end(fallback);
}
_ => todo!()
_ => todo!(),
}
ctx.builder.position_at_end(ret);
ctx.builder

View File

@@ -103,7 +103,12 @@ impl<'ctx> Helpers<'ctx> {
let call = module.add_function(
"call",
value_type.fn_type(
&[value_type.into(), ptr_type.into(), ptr_type.into(), ptr_type.into()],
&[
value_type.into(),
ptr_type.into(),
ptr_type.into(),
ptr_type.into(),
],
false,
),
None,
@@ -339,7 +344,12 @@ extern "C" fn helper_or(lhs: JITValue, rhs: JITValue) -> JITValue {
}
}
extern "C" fn helper_call(func: JITValue, args: Box<[JITValue]>, engine: NonNull<Engine>, env: NonNull<Env>) -> JITValue {
extern "C" fn helper_call(
func: JITValue,
args: Box<[JITValue]>,
engine: NonNull<Engine>,
env: NonNull<Env>,
) -> JITValue {
let func = Value::from(func);
todo!()
}

View File

@@ -6,9 +6,7 @@ use inkwell::builder::Builder;
use inkwell::context::Context;
use inkwell::execution_engine::ExecutionEngine;
use inkwell::module::Module;
use inkwell::values::{
AnyValue, BasicMetadataValueEnum, FloatValue, IntValue, StructValue
};
use inkwell::values::{AnyValue, BasicMetadataValueEnum, FloatValue, IntValue, StructValue};
use crate::env::Env;
use crate::ir::Ir;
@@ -60,10 +58,8 @@ impl From<JITValue> for Value {
match value.tag {
Int => Value::Int(unsafe { value.data.int }),
Null => Value::Null,
Function => Value::Func(unsafe { value.data.int as usize}),
Thunk => Value::Thunk(unsafe {
value.data.int as usize
}),
Function => Value::Func(unsafe { value.data.int as usize }),
Thunk => Value::Thunk(unsafe { value.data.int as usize }),
_ => todo!("not implemented for {:?}", value.tag),
}
}