untyped

package
v0.0.0-...-f54e8e0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	None    = Kind(r.Invalid)
	Bool    = Kind(r.Bool)
	Int     = Kind(r.Int)
	Rune    = Kind(r.Int32)
	Float   = Kind(r.Float64)
	Complex = Kind(r.Complex128)
	String  = Kind(r.String)
)

Variables

This section is empty.

Functions

func ConvertLiteralCheckOverflow

func ConvertLiteralCheckOverflow(src interface{}, to xr.Type) interface{}

ConvertLiteralCheckOverflow converts a literal to type t and returns the converted value. panics if the conversion overflows the given type

func Marshal

func Marshal(kind Kind, val constant.Value) string

Types

type Kind

type Kind r.Kind

untyped kind. matches reflect.Kind except for rune literals, where Kind == reflect.Int32

func GoUntypedToKind

func GoUntypedToKind(gkind types.BasicKind) Kind

func MakeKind

func MakeKind(ckind constant.Kind) Kind

func Unmarshal

func Unmarshal(marshalled string) (Kind, constant.Value)

func (Kind) Category

func (k Kind) Category() r.Kind

func (Kind) Reflect

func (k Kind) Reflect() r.Kind

func (Kind) String

func (k Kind) String() string

type Lit

type Lit struct {
	Kind Kind // untyped constant's default type
	Val  constant.Value
	// contains filtered or unexported fields
}

Lit represents an untyped literal value, i.e. an untyped constant

func MakeLit

func MakeLit(kind Kind, val constant.Value, basicTypes *[]xr.Type) Lit

func (*Lit) BigFloat

func (untyp *Lit) BigFloat() *big.Float

func (*Lit) BigInt

func (untyp *Lit) BigInt() *big.Int

func (*Lit) BigRat

func (untyp *Lit) BigRat() *big.Rat

func (*Lit) Convert

func (untyp *Lit) Convert(t xr.Type) interface{}

Convert checks that an untyped.Lit can be converted exactly to the given type. performs actual untyped -> typed conversion and subsequent overflow checks. returns the constant.Value converted to given type

func (*Lit) DefaultType

func (untyp *Lit) DefaultType() xr.Type

DefaultType returns the default type of an untyped constant.

func (*Lit) EqualInt64

func (untyp *Lit) EqualInt64(i int64) bool

func (*Lit) Float64

func (untyp *Lit) Float64() (float64, bool)

func (*Lit) Int64

func (untyp *Lit) Int64() (int64, bool)

func (Lit) String

func (untyp Lit) String() string

pretty-print untyped constants

func (*Lit) Uint64

func (untyp *Lit) Uint64() (uint64, bool)

type Val

type Val struct {
	Kind Kind // default type
	Val  constant.Value
}

untyped value

func UnmarshalVal

func UnmarshalVal(marshalled string) *Val

func (*Val) BigInt

func (lit *Val) BigInt() (*big.Int, error)

func (*Val) BigRat

func (lit *Val) BigRat() (*big.Rat, error)

func (*Val) Marshal

func (val *Val) Marshal() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL