frgot to transition @nameof to slices

Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
Jakub Doka 2024-12-21 23:55:02 +01:00
parent 5275a7e0fd
commit 888b38ad4c
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
3 changed files with 12 additions and 8 deletions

View file

@ -127,7 +127,7 @@ pub mod backend {
mod utils;
mod debug {
use {core::fmt::Debug, std::string::String};
use core::fmt::Debug;
pub fn panicking() -> bool {
#[cfg(feature = "std")]
@ -141,7 +141,7 @@ mod debug {
}
#[cfg(all(debug_assertions, feature = "std"))]
pub type Trace = std::rc::Rc<(std::backtrace::Backtrace, String)>;
pub type Trace = std::rc::Rc<(std::backtrace::Backtrace, std::string::String)>;
#[cfg(not(all(debug_assertions, feature = "std")))]
pub type Trace = ();

View file

@ -17,7 +17,6 @@ use {
ptr::NonNull,
sync::atomic::AtomicUsize,
},
std::panic,
};
pub type Pos = u32;

View file

@ -31,7 +31,6 @@ use {
format_args as fa, mem,
},
hbbytecode::DisasmError,
std::panic,
};
const DEFAULT_ACLASS: usize = 0;
@ -1350,7 +1349,7 @@ impl<'a> Codegen<'a> {
let elem = self.tys.ins.slices[s].elem;
let off = self.offset(bs.id, 0);
let base = self.tys.make_ptr(elem);
let bs = std::dbg!(self.load_mem(off, base));
let bs = self.load_mem(off, base);
Some(self.offset_ptr(bs, elem, idx.id))
}
ty::Kind::Struct(s) => {
@ -1426,18 +1425,24 @@ impl<'a> Codegen<'a> {
let ty = self.ty(ty);
self.gen_inferred_const(ctx, ty::Id::U8, ty.kind())
}
Expr::Directive { name: "nameof", args: [ty], .. } => {
Expr::Directive { pos, name: "nameof", args: [ty], .. } => {
let ty = self.ty(ty);
let mut data = core::mem::take(&mut self.pool.lit_buf);
self.tys.name_of(ty, self.files, &mut data);
data.push(0);
let (global, ty) = self.create_string_global(&data);
let len = self.ci.nodes.new_const_lit(ty, data.len() as i64);
data.clear();
self.pool.lit_buf = data;
Some(Value::new(global).ty(ty))
let slc = self.tys.make_array(ty::Id::U8, ArrayLen::MAX);
let mem = self.new_stack(pos, slc);
for (off, value) in [(0u32, Value::ptr(global).ty(ty)), (8, len)] {
let region = self.offset(mem, off);
self.store_mem(region, value.ty, value.id);
}
Some(Value::ptr(mem).ty(slc))
}
Expr::Directive { name: "sizeof", args: [ty], .. } => {
let ty = self.ty(ty);