brahmaputra

This commit is contained in:
mlokr 2024-07-07 14:26:43 +02:00
parent 22f925b3f5
commit e9589ebcae
No known key found for this signature in database
GPG key ID: DEA147DDEE644993
2 changed files with 25 additions and 1 deletions

View file

@ -1639,6 +1639,14 @@ impl Codegen {
self.find_or_declare(target.pos(), idx, Err(field), "")
.compress(),
)),
ty::Kind::Global(idx) => Some(Value::ty({
let global = &self.tys.globals[idx as usize];
ty::Id::from(u32::from_ne_bytes(
self.output.code[global.offset as usize..][..4]
.try_into()
.unwrap(),
))
})),
e => unimplemented!("{e:?}"),
}
}

View file

@ -876,7 +876,23 @@ impl<'a> std::fmt::Display for Expr<'a> {
Self::Ident { name, .. } => write!(f, "{name}"),
Self::Block { stmts, .. } => {
write!(f, "{{")?;
fmt_trailing_list(f, "}", stmts, std::fmt::Display::fmt)
writeln!(f)?;
INDENT.with(|i| i.set(i.get() + 1));
let res = (|| {
for stmt in list {
for _ in 0..INDENT.with(|i| i.get()) {
write!(f, "\t")?;
}
fmt(stmt, f)?;
}
Ok(())
})();
INDENT.with(|i| i.set(i.get() - 1));
for _ in 0..INDENT.with(|i| i.get()) {
write!(f, "\t")?;
}
write!(f, "{end}")?;
res
}
Self::Number { value, .. } => write!(f, "{value}"),
Self::Bool { value, .. } => write!(f, "{value}"),