github.com/llir/llvm@v0.3.6/ir/constant/const_zeroinitializer.go (about)

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