types

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Invalid = &constant{"invalid", false}

	Bool   = &constant{"bool", false}
	I8     = &constant{"i8", true}
	I16    = &constant{"i16", true}
	I32    = &constant{"i32", true}
	I64    = &constant{"i64", true}
	U8     = &constant{"u8", true}
	U16    = &constant{"u16", true}
	U32    = &constant{"u32", true}
	U64    = &constant{"u64", true}
	F32    = &constant{"f32", true}
	F64    = &constant{"f64", true}
	Int    = New("int", I32)
	Uint   = New("uint", U8)
	Byte   = New("byte", U8)
	Rune   = New("rune", U32)
	String = New("string", NewList(Rune))
)

Functions

This section is empty.

Types

type Environment

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

func NewEnvironment

func NewEnvironment() *Environment

func (*Environment) Define

func (e *Environment) Define(name string, typ Type)

func (*Environment) Exports

func (e *Environment) Exports() map[string]Type

func (*Environment) Import

func (e *Environment) Import(name string, env *Environment)

func (*Environment) IsTypeRegistered

func (e *Environment) IsTypeRegistered(expr ast.TypeExpr) bool

func (*Environment) RegisterImport

func (e *Environment) RegisterImport(def *ast.IdentExpr) error

func (*Environment) RegisterType

func (e *Environment) RegisterType(def *ast.TypeDefStmt) error

func (Environment) ResolveType

func (e Environment) ResolveType(expr ast.TypeExpr) (Type, error)

type Fn

type Fn struct {
	In  []Type
	Out Type
}

func (*Fn) Assignable

func (t *Fn) Assignable(o Type) bool

func (*Fn) Base

func (t *Fn) Base() Type

func (*Fn) Comparable

func (t *Fn) Comparable(o Type) bool

func (*Fn) Convertible

func (t *Fn) Convertible(o Type) bool

func (*Fn) IsRoot

func (t *Fn) IsRoot() bool

func (*Fn) Operable

func (t *Fn) Operable(o Type, op Operation) bool

func (*Fn) String

func (t *Fn) String() string

type Indexer

type Indexer interface {
	Index(any) (Type, bool)
}

type List

type List struct {
	Type Type
}

func NewList

func NewList(t Type) *List

func (*List) Assignable

func (t *List) Assignable(o Type) bool

func (*List) Base

func (t *List) Base() Type

func (*List) Comparable

func (t *List) Comparable(o Type) bool

func (*List) Convertible

func (t *List) Convertible(o Type) bool

func (*List) Index

func (t *List) Index(v any) (Type, bool)

func (*List) IsRoot

func (t *List) IsRoot() bool

func (*List) Operable

func (t *List) Operable(o Type, op Operation) bool

func (*List) String

func (t *List) String() string

type Operation

type Operation int
const (
	Noop Operation = iota
	Addition
	Subtraction
	Division
	Multiplication
	Exponent
)

type Struct

type Struct []TypePair

func NewStruct

func NewStruct(pairs ...TypePair) *Struct

func (*Struct) Assignable

func (t *Struct) Assignable(o Type) bool

func (*Struct) Base

func (t *Struct) Base() Type

func (*Struct) Comparable

func (t *Struct) Comparable(o Type) bool

func (*Struct) Convertible

func (t *Struct) Convertible(o Type) bool

func (*Struct) Index

func (t *Struct) Index(v any) (Type, bool)

func (*Struct) IsRoot

func (t *Struct) IsRoot() bool

func (*Struct) Operable

func (t *Struct) Operable(o Type, op Operation) bool

func (*Struct) String

func (t *Struct) String() string

type Template

type Template struct {
	In []Type
}

func NewTemplate

func NewTemplate(in []Type) *Template

func (*Template) Assignable

func (t *Template) Assignable(o Type) bool

func (*Template) Base

func (t *Template) Base() Type

func (*Template) Comparable

func (t *Template) Comparable(o Type) bool

func (*Template) Convertible

func (t *Template) Convertible(o Type) bool

func (*Template) IsRoot

func (t *Template) IsRoot() bool

func (*Template) Operable

func (t *Template) Operable(o Type, op Operation) bool

func (*Template) String

func (t *Template) String() string

type Type

type Type interface {
	String() string
	IsRoot() bool
	Base() Type
	Assignable(Type) bool
	Comparable(Type) bool
	Convertible(Type) bool
	Operable(Type, Operation) bool
}

func New

func New(name string, base Type) Type

func RootOf

func RootOf(t Type) Type

type TypePair

type TypePair struct {
	Index int
	Name  string
	Type  Type
}

func NewPair

func NewPair(i int, name string, typ Type) TypePair

Jump to

Keyboard shortcuts

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