1use super::*;
4use super::c_api::*;
5
6#[derive(Copy, Clone)]
8pub struct BasicBlock {
9 pub(crate) basic_block: LLVMBasicBlockRef
10}
11
12impl BasicBlock {
13 pub fn delete(self) {
15 unsafe {
16 LLVMDeleteBasicBlock(self.basic_block)
17 }
18 }
19
20 pub fn get_name(&self) -> Option<String> {
22 unsafe {
23 from_c(LLVMGetBasicBlockName(self.basic_block))
24 }
25 }
26
27 pub unsafe fn inner(&self) -> LLVMBasicBlockRef {
29 self.basic_block
30 }
31}
32
33impl Deref for BasicBlock {
34 type Target = LLVMBasicBlockRef;
35
36 fn deref(&self) -> &LLVMBasicBlockRef {
37 &self.basic_block
38 }
39}
40
41impl Debug for BasicBlock {
42 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
43 if let Some(name) = self.get_name() {
44 write!(f, "BasicBlock({})", name)
45 } else {
46 write!(f, "BasicBlock")
47 }
48 }
49}