github.com/llir/llvm@v0.3.6/ir/constant/const_null.go (about) 1 package constant 2 3 import ( 4 "fmt" 5 6 "github.com/llir/llvm/ir/types" 7 ) 8 9 // --- [ Null pointer constants ] ---------------------------------------------- 10 11 // Null is an LLVM IR null pointer constant. 12 type Null struct { 13 // Pointer type. 14 Typ *types.PointerType 15 } 16 17 // NewNull returns a new null pointer constant based on the given pointer type. 18 func NewNull(typ *types.PointerType) *Null { 19 return &Null{Typ: typ} 20 } 21 22 // String returns the LLVM syntax representation of the constant as a type-value 23 // pair. 24 func (c *Null) String() string { 25 return fmt.Sprintf("%v %v", c.Type(), c.Ident()) 26 } 27 28 // Type returns the type of the constant. 29 func (c *Null) Type() types.Type { 30 return c.Typ 31 } 32 33 // Ident returns the identifier associated with the constant. 34 func (*Null) Ident() string { 35 // NullLit 36 return "null" 37 }