chore: cargo fmt

This commit is contained in:
2025-07-17 16:28:43 +08:00
parent dedf84a1a9
commit 781f701891
3 changed files with 19 additions and 12 deletions

View File

@@ -14,7 +14,7 @@ pub trait JITCompile {
impl JITCompile for Attrs {
fn compile(&self, ctx: &mut JITContext, engine: ir::Value, env: ir::Value) -> StackSlot {
let attrs = ctx.create_attrs();
let attrs = ctx.create_attrs();
for (k, v) in self.stcs.iter() {
let v = v.compile(ctx, engine, env);
ctx.push_attr(attrs, k, v);

View File

@@ -130,7 +130,10 @@ pub unsafe extern "C" fn helper_push_attr(
}
}
pub unsafe extern "C" fn helper_finalize_attrs(attrs: NonNull<HashMap<String, Value>>, ret: &mut MaybeUninit<Value>) {
pub unsafe extern "C" fn helper_finalize_attrs(
attrs: NonNull<HashMap<String, Value>>,
ret: &mut MaybeUninit<Value>,
) {
ret.write(Value::AttrSet(Rc::new(unsafe { attrs.read() }.into())));
}
@@ -139,6 +142,5 @@ pub unsafe extern "C" fn helper_alloc_array(len: usize) -> *mut u8 {
}
pub extern "C" fn helper_dbg(value: &Value) {
// dbg!(value);
println!("{value:?}")
}

View File

@@ -139,9 +139,7 @@ impl<'comp, 'ctx> JITContext<'comp, 'ctx> {
self.free_slot(val);
let attrs = self.builder.ins().stack_addr(types::I64, attrs, 0);
let val = self.builder.ins().stack_addr(types::I64, val, 0);
let sym = self
.strings
.get_or_insert_with(sym, |_| sym.to_owned());
let sym = self.strings.get_or_insert_with(sym, |_| sym.to_owned());
let ptr = self
.builder
.ins()
@@ -566,7 +564,11 @@ impl JITCompiler {
}; 2],
);
let finalize_attrs = module
.declare_function("helper_finalize_attrs", Linkage::Import, &finalize_attrs_sig)
.declare_function(
"helper_finalize_attrs",
Linkage::Import,
&finalize_attrs_sig,
)
.unwrap();
let mut dbg_sig = module.make_signature();
@@ -647,9 +649,10 @@ impl JITCompiler {
ctx.builder.finalize();
let strings = ctx.strings;
println!("{:?}", ir);
println!("{}", func.display());
if cfg!(debug_assertions) {
println!("{:?}", ir);
println!("{}", func.display());
}
self.ctx.func = func;
self.module.define_function(func_id, &mut self.ctx).unwrap();
self.module.finalize_definitions().unwrap();
@@ -658,8 +661,10 @@ impl JITCompiler {
let _ = self.builder_ctx.insert(builder_ctx);
unsafe {
JITFunc {
func: std::mem::transmute::<*const u8, F>(self.module.get_finalized_function(func_id)),
strings
func: std::mem::transmute::<*const u8, F>(
self.module.get_finalized_function(func_id),
),
strings,
}
}
}