brahmaputra 4

This commit is contained in:
mlokr 2024-07-07 14:52:31 +02:00
parent bd7384123c
commit efa7271a59
No known key found for this signature in database
GPG key ID: DEA147DDEE644993
3 changed files with 10 additions and 13 deletions

View file

@ -1629,18 +1629,13 @@ impl Codegen {
self.ci.free_loc(tal.loc);
self.pop_local_snap(checkpoint);
match ty::Kind::from_ty(self.ty(target)) {
ty::Kind::Module(idx) => Some(Value::ty(
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(),
))
})),
ty::Kind::Module(idx) => {
match self.find_or_declare(target.pos(), idx, Err(field), "") {
ty::Kind::Global(idx) => self.handle_global(idx),
e => Some(Value::ty(e.compress())),
}
}
ty::Kind::Global(idx) => self.handle_global(idx),
e => unimplemented!("{e:?}"),
}
}

View file

@ -1,5 +1,5 @@
pkg := @use("pkg.hb");
main := fn(a: int): int {
return pkg.fib(10);
return pkg.fib(pkg.global);
}

View file

@ -1,3 +1,5 @@
global := 10;
fib := fn(n: int): int {
return n + 1;
}