github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/value.go (about)

     1  package jit
     2  
     3  import (
     4  	"github.com/goccy/go-jit/internal/ccall"
     5  )
     6  
     7  type Value struct {
     8  	*ccall.Value
     9  }
    10  
    11  type Values []*Value
    12  
    13  func (v Values) raw() ccall.Values {
    14  	values := ccall.Values{}
    15  	for _, vv := range v {
    16  		values = append(values, vv.Value)
    17  	}
    18  	return values
    19  }
    20  
    21  func toValues(v ccall.Values) Values {
    22  	values := Values{}
    23  	for _, vv := range v {
    24  		values = append(values, toValue(vv))
    25  	}
    26  	return values
    27  }
    28  
    29  func toValue(c *ccall.Value) *Value {
    30  	return &Value{c}
    31  }
    32  
    33  func (v *Value) IsTemporary() bool {
    34  	return v.Value.IsTemporary()
    35  }
    36  
    37  func (v *Value) IsLocal() bool {
    38  	return v.Value.IsLocal()
    39  }
    40  
    41  func (v *Value) IsConstant() bool {
    42  	return v.Value.IsConstant()
    43  }
    44  
    45  func (v *Value) IsParameter() bool {
    46  	return v.Value.IsParameter()
    47  }
    48  
    49  func (v *Value) SetVolatile() {
    50  	v.Value.SetVolatile()
    51  }
    52  
    53  func (v *Value) IsVolatile() bool {
    54  	return v.Value.IsVolatile()
    55  }
    56  
    57  func (v *Value) SetAddressable() {
    58  	v.Value.SetAddressable()
    59  }
    60  
    61  func (v *Value) IsAddressable() bool {
    62  	return v.Value.IsAddressable()
    63  }
    64  
    65  func (v *Value) Type() *Type {
    66  	return toType(v.Value.Type())
    67  }
    68  
    69  func (v *Value) Function() *Function {
    70  	return toFunction(v.Value.Function())
    71  }
    72  
    73  func (v *Value) Block() *Block {
    74  	return toBlock(v.Value.Block())
    75  }
    76  
    77  func (v *Value) Context() *Context {
    78  	return toContext(v.Value.Context())
    79  }
    80  
    81  //func (v *Value) Constant() *Constant {
    82  //	return toConstant(C.jit_value_get_constant(v.c))
    83  //}
    84  
    85  func (v *Value) Int() int {
    86  	return v.Value.Int()
    87  }
    88  
    89  func (v *Value) Float32() float32 {
    90  	return v.Value.Float32()
    91  }
    92  
    93  func (v *Value) Float64() float64 {
    94  	return v.Value.Float64()
    95  }
    96  
    97  func (v *Value) IsTrue() bool {
    98  	return v.Value.IsTrue()
    99  }