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

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