typesystem

package
v0.0.0-...-5c07768 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidType = errors.New("invalid type")

Functions

func Implements

func Implements[T any](typ reflect.Type) bool

func TryCast

func TryCast[T any](v reflect.Value) (def T, ok bool)

func TryUnwrap

func TryUnwrap[T any](v ipld.Node) (def T, ok bool)

func Unwrap

func Unwrap(v ipld.Node) any

func Wrap

func Wrap(v any) ipld.Node

Types

type BinaryOperator

type BinaryOperator interface {
	Operator

	Left() Type
	Right() Type
}

type Field

type Field interface {
	Name() string
	Type() Type
	DeclaringType() StructType
	IsVirtual() bool

	Resolve(v Value) Value
}

type ListType

type ListType interface {
	Type

	Elem() Type
}

type MapType

type MapType interface {
	Type

	Key() Type
	Value() Type
}

type Operator

type Operator interface {
	Name() OperatorName

	Commutator() OperatorName
	Negator() OperatorName

	ReceiverType() Type
	Parameters() []Type

	Call(args ...Value) (Value, error)
}

type OperatorName

type OperatorName string
const (
	OperatorInvalid OperatorName = ""
	OperatorAdd     OperatorName = "+"
	OperatorSub     OperatorName = "-"
	OperatorMul     OperatorName = "*"
	OperatorDiv     OperatorName = "/"
	OperatorRem     OperatorName = "%"
	OperatorAnd     OperatorName = "&&"
	OperatorOr      OperatorName = "||"
	OperatorNot     OperatorName = "!"
	OperatorEq      OperatorName = "=="
	OperatorNeq     OperatorName = "!="
	OperatorNe      OperatorName = "!="
	OperatorLt      OperatorName = "<"
	OperatorGt      OperatorName = ">"
	OperatorLe      OperatorName = "<="
	OperatorGe      OperatorName = ">="
)

type PrimitiveKind

type PrimitiveKind int
const (
	PrimitiveKindInvalid PrimitiveKind = iota
	PrimitiveKindBoolean
	PrimitiveKindBytes
	PrimitiveKindString
	PrimitiveKindInt
	PrimitiveKindUnsignedInt
	PrimitiveKindFloat
	PrimitiveKindList
	PrimitiveKindMap
	PrimitiveKindStruct
	PrimitiveKindInterface
	PrimitiveKindLink
)

type StructType

type StructType interface {
	Type

	NumField() int
	Field(name string) Field
	FieldByIndex(index int) Field
}

type Type

type Type interface {
	Name() TypeName
	PrimitiveKind() PrimitiveKind
	RuntimeType() reflect.Type

	IpldType() schema.Type
	IpldPrimitive() ipld.NodePrototype
	IpldPrototype() schema.TypedPrototype
	IpldRepresentationKind() datamodel.Kind

	Struct() StructType
	List() ListType
	Map() MapType
}

func TypeFrom

func TypeFrom(t reflect.Type) Type

func TypeOf

func TypeOf(v interface{}) Type

type TypeName

type TypeName struct {
	Package    string
	Name       string
	Plural     string
	Parameters []TypeName
}

func (TypeName) FullName

func (n TypeName) FullName() string

func (TypeName) GoString

func (n TypeName) GoString() string

func (TypeName) NormalizedFullNameWithArguments

func (n TypeName) NormalizedFullNameWithArguments() string

func (TypeName) String

func (n TypeName) String() string

func (TypeName) ToTitle

func (n TypeName) ToTitle() string

func (TypeName) ToTitlePlural

func (n TypeName) ToTitlePlural() string

func (TypeName) WithParameters

func (n TypeName) WithParameters(parameters ...TypeName) TypeName

type TypeSystem

type TypeSystem struct {
	// contains filtered or unexported fields
}

func Universe

func Universe() *TypeSystem

func (*TypeSystem) LookupByName

func (ts *TypeSystem) LookupByName(name string) Type

func (*TypeSystem) LookupByType

func (ts *TypeSystem) LookupByType(typ reflect.Type) Type

func (*TypeSystem) Register

func (ts *TypeSystem) Register(t Type)
type TypedLink interface {
	ipld.Link

	LinkedObjectType() Type
}

type UnaryOperator

type UnaryOperator interface {
	Operator

	Operand() Type
}

type Value

type Value struct {
	// contains filtered or unexported fields
}

func MakeList

func MakeList(t Type, length, cap int) Value

func MakeMap

func MakeMap(k, v Type, length int) Value

func New

func New(t Type) Value

func ValueFrom

func ValueFrom(v reflect.Value) Value

func ValueOf

func ValueOf(v interface{}) Value

func (Value) As

func (v Value) As(typ Type) Value

func (Value) AsNode

func (v Value) AsNode() ipld.Node

func (Value) GetField

func (v Value) GetField(f Field) Value

func (Value) Indirect

func (v Value) Indirect() reflect.Value

func (Value) RuntimeType

func (v Value) RuntimeType() reflect.Type

func (Value) Type

func (v Value) Type() Type

func (Value) Value

func (v Value) Value() reflect.Value

Jump to

Keyboard shortcuts

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