Version: v0.0.0-...-89480e5 Latest Latest

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

Go to latest
Published: Jan 17, 2018 License: BSD-2-Clause Imports: 3 Imported by: 0



Package tipe defines data structures representing Neugram types.

Go took the usual spelling of type.



This section is empty.


View Source
var (
	Byte = &Alias{Name: "byte", Type: Uint8}
	Rune = &Alias{Name: "rune", Type: Int32}


func Equal

func Equal(x, y Type) bool

func EqualUnresolved

func EqualUnresolved(x, y Type) bool

func IsNumeric

func IsNumeric(t Type) bool

func IsUntypedNil

func IsUntypedNil(t Type) bool

func UsesNum

func UsesNum(t Type) bool


type Alias

type Alias struct {
	Name string
	Type Type

type Array

type Array struct {
	Len      int64
	Elem     Type
	Ellipsis bool // array was defined as [...]T

type Basic

type Basic string
const (
	Invalid Basic = "invalid"
	Num     Basic = "num" // type parameter
	Bool    Basic = "bool"
	Integer Basic = "integer"
	Float   Basic = "float"
	Complex Basic = "cmplx"
	String  Basic = "string"

	Int   Basic = "int"
	Int8  Basic = "int8"
	Int16 Basic = "int16"
	Int32 Basic = "int32"
	Int64 Basic = "int64"

	Uint    Basic = "uint"
	Uint8   Basic = "uint8"
	Uint16  Basic = "uint16"
	Uint32  Basic = "uint32"
	Uint64  Basic = "uint64"
	Uintptr Basic = "uintptr"

	Float32 Basic = "float32"
	Float64 Basic = "float64"

	Complex64  Basic = "complex64"
	Complex128 Basic = "complex128"

	UnsafePointer Basic = "unsafe pointer"

	UntypedNil     Basic = "untyped nil" // nil pointer or nil interface
	UntypedString  Basic = "untyped string"
	UntypedBool    Basic = "untyped bool"
	UntypedInteger Basic = "untyped integer"
	UntypedFloat   Basic = "untyped float"
	UntypedRune    Basic = "untyped rune"
	UntypedComplex Basic = "untyped complex"

type Builtin

type Builtin string
const (
	Append      Builtin = "builtin append"
	Cap         Builtin = "builtin cap"
	Close       Builtin = "builtin close"
	ComplexFunc Builtin = "builtin complex"
	Copy        Builtin = "builtin copy"
	Delete      Builtin = "builtin delete"
	Imag        Builtin = "builtin imag"
	Len         Builtin = "builtin len"
	Make        Builtin = "builtin make"
	New         Builtin = "builtin new"
	Panic       Builtin = "builtin panic"
	Real        Builtin = "builtin real"
	Recover     Builtin = "builtin recover"

type Chan

type Chan struct {
	Direction ChanDirection
	Elem      Type

type ChanDirection

type ChanDirection int
const (
	ChanBoth ChanDirection = iota

type Ellipsis

type Ellipsis struct {
	Elem Type

type Func

type Func struct {
	Spec     Specialization
	Params   *Tuple
	Results  *Tuple
	Variadic bool // last value of Params is a slice
	FreeVars []string
	FreeMdik []*Named

type Interface

type Interface struct {
	Methods map[string]*Func

func (Interface) String

func (t Interface) String() string

type Map

type Map struct {
	Key   Type
	Value Type

type Memory

type Memory struct {
	// contains filtered or unexported fields

func NewMemory

func NewMemory() *Memory

func (*Memory) Method

func (m *Memory) Method(t Type, name string) *Func

func (*Memory) Methods

func (m *Memory) Methods(t Type) ([]string, []Type)

type Named

type Named struct {
	// TODO: need to track the definition package so the evaluator can
	// extract the mscope from the right place. Is this the only
	// instance of needing the source package? What about debug printing?
	Spec Specialization
	Type Type

	PkgName string
	PkgPath string
	Name    string

	MethodNames []string
	Methods     []*Func

Named is a named type. A named type is declared either using a type declaration:

type S struct{}

or the methodik declaration:

methodik S struct{} {}

As in Go, a named type has an underlying type. A named type can also have methods associated with it.

type Package

type Package struct {
	GoPkg   interface{} // *gotypes.Package
	Path    string
	Exports map[string]Type

type Pointer

type Pointer struct {
	Elem Type

type Slice

type Slice struct {
	Elem Type

type Specialization

type Specialization struct {
	// Num is the specialization of the type parameter num in
	Num Basic

Specialization carries any type specialization data particular to this type.

*Func, *Struct, *Named can be parameterized over the name num, which can take any of:

integer, int64, float, float32, float64, complex, complex128

At the defnition of a class or function, the matching Type will have the Num filed set to Invalid if it is not parameterized, or Num if it is.

On a value of a parameterized class or a Call of a parameterized function, Num will either Num or one of the basic numeric types (if specialized).

type Struct

type Struct struct {
	Spec   Specialization
	Fields []StructField

type StructField

type StructField struct {
	Name     string
	Type     Type
	Tag      StructTag
	Embedded bool

StructField is a field of a Struct. It is not an ng type.

type StructTag

type StructTag string

StructTag is the tag string in a struct field.

type Table

type Table struct {
	Type Type

type Tuple

type Tuple struct {
	Elems []Type

type Type

type Type interface {
	// contains filtered or unexported methods

func Unalias

func Unalias(t Type) Type

func Underlying

func Underlying(t Type) Type

type Unresolved

type Unresolved struct {
	Package string
	Name    string

Source Files

Jump to

Keyboard shortcuts

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