Skip to content

Commit

Permalink
Add GlobalVariable::ty and Type::to_ptr methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Nak committed Nov 26, 2024
1 parent 7f349e4 commit 69c8f76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/ir/src/global_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ impl GlobalVariableStore {
pub struct GlobalVariable(pub u32);
cranelift_entity::entity_impl!(GlobalVariable);

impl GlobalVariable {
pub fn ty(self, module: &ModuleCtx) -> Type {
module.with_gv_store(|s| s.ty(self))
}
}

impl WriteWithModule for GlobalVariable {
fn write(&self, module: &ModuleCtx, w: &mut impl io::Write) -> io::Result<()> {
module.with_gv_store(|s| s.gv_data(*self).write(module, w))
Expand Down
4 changes: 4 additions & 0 deletions crates/ir/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ impl Type {

Some(ctx.with_ty_store(|s| s.resolve_compound(cmpd).clone()))
}

pub fn to_ptr(self, ctx: &ModuleCtx) -> Type {
ctx.with_ty_store_mut(|s| s.make_ptr(self))
}
}

impl cmp::PartialOrd for Type {
Expand Down

0 comments on commit 69c8f76

Please sign in to comment.