types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: BSD-3-Clause-Clear Imports: 11 Imported by: 0

Documentation

Overview

package types provides an interface and many implementations of that interface as an abstraction, however leaky, of the union of the Go type system and the Ruby Object system.

Index

Constants

This section is empty.

Variables

View Source
var (
	KernelType  = kernel{newProto("Kernel", "", ClassRegistry)}
	KernelClass = NewClass("Kernel", "", KernelType, ClassRegistry)
)
View Source
var AlwaysFalse = MethodSpec{
	ReturnType: func(r Type, b Type, args []Type) (Type, error) {
		return BoolType, nil
	},
	TransformAST: func(rcvr TypeExpr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform {
		return Transform{
			Expr: it.Get("false"),
		}
	},
}
View Source
var AlwaysTrue = MethodSpec{
	ReturnType: func(r Type, b Type, args []Type) (Type, error) {
		return BoolType, nil
	},
	TransformAST: func(rcvr TypeExpr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform {
		return Transform{
			Expr: it.Get("true"),
		}
	},
}
View Source
var ArrayClass = NewClass("Array", "Object", nil, ClassRegistry)
View Source
var BoolClass = NewClass("Boolean", "Object", BoolType, ClassRegistry)
View Source
var BoolType = Bool{newProto("Boolean", "Object", ClassRegistry)}
View Source
var ClassRegistry = &classRegistry{registry: make(map[string]*Class)}
View Source
var FileType = NewClass("File", "Object", nil, ClassRegistry)
View Source
var FloatClass = NewClass("Float", "Numeric", FloatType, ClassRegistry)
View Source
var FloatType = Float{newProto("Float", "Numeric", ClassRegistry)}
View Source
var HashClass = NewClass("Hash", "Object", nil, ClassRegistry)
View Source
var IntClass = NewClass("Integer", "Numeric", IntType, ClassRegistry)
View Source
var IntType = Int{newProto("Integer", "Numeric", ClassRegistry)}
View Source
var MatchDataClass = NewClass("MatchData", "Object", MatchDataType, ClassRegistry)
View Source
var MatchDataType = matchData{newProto("MatchData", "Object", ClassRegistry)}
View Source
var NoopReturnSelf = MethodSpec{
	ReturnType: func(r Type, b Type, args []Type) (Type, error) {
		return r, nil
	},
	TransformAST: func(rcvr TypeExpr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform {
		return Transform{
			Expr: rcvr.Expr,
		}
	},
}
View Source
var NumericClass = NewClass("Numeric", "Object", NumericType, ClassRegistry)
View Source
var NumericType = Numeric{newProto("Numeric", "Object", ClassRegistry)}
View Source
var ObjectClass = NewClass("Object", "", ObjectType, ClassRegistry)
View Source
var ObjectType = Object{newProto("Object", "", ClassRegistry)}
View Source
var ProcClass = NewClass("Proc", "Object", nil, ClassRegistry)
View Source
var RangeClass = NewClass("Range", "Object", nil, ClassRegistry)
View Source
var RegexpClass = NewClass("Regexp", "Object", RegexpType, ClassRegistry)
View Source
var RegexpType = Regexp{newProto("Regexp", "Object", ClassRegistry)}
View Source
var SetClass = NewClass("Set", "Object", nil, ClassRegistry)
View Source
var StringClass = NewClass("String", "Object", StringType, ClassRegistry)
View Source
var StringType = String{newProto("String", "Object", ClassRegistry)}
View Source
var SymbolClass = NewClass("Symbol", "Object", SymbolType, ClassRegistry)
View Source
var SymbolType = Symbol{newProto("Symbol", "Object", ClassRegistry)}

Functions

func FprintVerb

func FprintVerb(t Type) string

func RegisterType

func RegisterType(goValue interface{}, thanosTypeOrConstructor interface{})

func ToSnakeCase

func ToSnakeCase(str string) string

func UnwrapTypeExprs

func UnwrapTypeExprs(typeExprs []TypeExpr) []ast.Expr

Types

type Array

type Array struct {
	Element  Type
	Instance instance
}

func (Array) BlockArgTypes

func (t Array) BlockArgTypes(m string, args []Type) []Type

func (Array) ClassName

func (t Array) ClassName() string

func (Array) Equals

func (t Array) Equals(t2 Type) bool

func (Array) GoType

func (t Array) GoType() string

func (Array) HasMethod

func (t Array) HasMethod(method string) bool

func (Array) Inner

func (t Array) Inner() Type

func (Array) IsComposite

func (t Array) IsComposite() bool

func (Array) IsMultiple

func (t Array) IsMultiple() bool

func (Array) MethodReturnType

func (t Array) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Array) Outer

func (t Array) Outer() Type

func (Array) String

func (t Array) String() string

func (Array) TransformAST

func (t Array) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

type Block

type Block struct {
	Args       []ast.Expr
	ReturnType Type
	Statements []ast.Stmt
}

type Bool

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

func (Bool) Alias

func (t Bool) Alias(existingMethod, newMethod string)

func (Bool) BlockArgTypes

func (t Bool) BlockArgTypes(m string, args []Type) []Type

func (Bool) ClassName

func (p Bool) ClassName() string

func (Bool) Def

func (p Bool) Def(m string, spec MethodSpec)

func (Bool) Equals

func (t Bool) Equals(t2 Type) bool

func (Bool) GenerateMethods

func (p Bool) GenerateMethods(iface interface{}, exclusions ...string)

func (Bool) GoType

func (t Bool) GoType() string

func (Bool) HasMethod

func (t Bool) HasMethod(m string) bool

func (Bool) IsComposite

func (t Bool) IsComposite() bool

func (Bool) IsMultiple

func (p Bool) IsMultiple() bool

func (Bool) MakeAlias

func (p Bool) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (Bool) MethodReturnType

func (t Bool) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Bool) Methods

func (p Bool) Methods() map[string]MethodSpec

func (Bool) MustResolve

func (t Bool) MustResolve(m string) MethodSpec

func (Bool) Resolve

func (t Bool) Resolve(m string) (MethodSpec, bool)

func (Bool) SelfDef

func (p Bool) SelfDef(m string, spec MethodSpec)

func (Bool) String

func (t Bool) String() string

func (Bool) TransformAST

func (t Bool) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (Bool) UserDefined

func (p Bool) UserDefined() bool

type Class

type Class struct {
	Prefix string

	Instance instance

	UserDefined bool
	// contains filtered or unexported fields
}

func NewClass

func NewClass(name, parent string, inst instance, registry *classRegistry) *Class

func (Class) Alias

func (p Class) Alias(existingMethod, newMethod string)

func (*Class) BlockArgTypes

func (t *Class) BlockArgTypes(m string, args []Type) []Type

func (Class) ClassName

func (p Class) ClassName() string

func (*Class) Constructor

func (t *Class) Constructor() string

func (Class) Def

func (p Class) Def(m string, spec MethodSpec)

func (*Class) Equals

func (t *Class) Equals(t2 Type) bool

func (Class) GenerateMethods

func (p Class) GenerateMethods(iface interface{}, exclusions ...string)

func (*Class) GoType

func (t *Class) GoType() string

func (*Class) HasMethod

func (t *Class) HasMethod(m string) bool

func (*Class) IsComposite

func (t *Class) IsComposite() bool

func (Class) IsMultiple

func (p Class) IsMultiple() bool

func (Class) MakeAlias

func (p Class) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (*Class) MethodReturnType

func (t *Class) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Class) Methods

func (p Class) Methods() map[string]MethodSpec

func (*Class) MustResolve

func (t *Class) MustResolve(m string) MethodSpec

func (*Class) Resolve

func (t *Class) Resolve(m string) (MethodSpec, bool)

func (Class) SelfDef

func (p Class) SelfDef(m string, spec MethodSpec)

func (*Class) String

func (t *Class) String() string

func (*Class) TransformAST

func (t *Class) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (Class) UserDefined

func (p Class) UserDefined() bool

type CompositeType

type CompositeType interface {
	Type
	Outer() Type
	Inner() Type
}

type Float

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

func (Float) Alias

func (t Float) Alias(existingMethod, newMethod string)

func (Float) BlockArgTypes

func (t Float) BlockArgTypes(m string, args []Type) []Type

func (Float) ClassName

func (p Float) ClassName() string

func (Float) Def

func (p Float) Def(m string, spec MethodSpec)

func (Float) Equals

func (t Float) Equals(t2 Type) bool

func (Float) GenerateMethods

func (p Float) GenerateMethods(iface interface{}, exclusions ...string)

func (Float) GoType

func (t Float) GoType() string

func (Float) HasMethod

func (t Float) HasMethod(m string) bool

func (Float) IsComposite

func (t Float) IsComposite() bool

func (Float) IsMultiple

func (p Float) IsMultiple() bool

func (Float) MakeAlias

func (p Float) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (Float) MethodReturnType

func (t Float) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Float) Methods

func (p Float) Methods() map[string]MethodSpec

func (Float) MustResolve

func (t Float) MustResolve(m string) MethodSpec

func (Float) Resolve

func (t Float) Resolve(m string) (MethodSpec, bool)

func (Float) SelfDef

func (p Float) SelfDef(m string, spec MethodSpec)

func (Float) String

func (t Float) String() string

func (Float) TransformAST

func (t Float) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (Float) UserDefined

func (p Float) UserDefined() bool

type Hash

type Hash struct {
	Key, Value Type
	Instance   instance
}

func (Hash) BlockArgTypes

func (t Hash) BlockArgTypes(m string, args []Type) []Type

func (Hash) ClassName

func (t Hash) ClassName() string

func (Hash) Equals

func (t Hash) Equals(t2 Type) bool

func (Hash) GoType

func (t Hash) GoType() string

func (Hash) HasMethod

func (t Hash) HasMethod(method string) bool

func (Hash) Inner

func (t Hash) Inner() Type

func (Hash) IsComposite

func (t Hash) IsComposite() bool

func (Hash) IsMultiple

func (t Hash) IsMultiple() bool

func (Hash) MethodReturnType

func (t Hash) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Hash) Outer

func (t Hash) Outer() Type

func (Hash) String

func (t Hash) String() string

func (Hash) TransformAST

func (t Hash) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

type Instance

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

func (Instance) Alias

func (t Instance) Alias(existingMethod, newMethod string)

func (Instance) BlockArgTypes

func (t Instance) BlockArgTypes(m string, args []Type) []Type

func (Instance) ClassName

func (p Instance) ClassName() string

func (Instance) Def

func (p Instance) Def(m string, spec MethodSpec)

func (Instance) Equals

func (t Instance) Equals(t2 Type) bool

func (Instance) GenerateMethods

func (p Instance) GenerateMethods(iface interface{}, exclusions ...string)

func (Instance) GoType

func (t Instance) GoType() string

func (Instance) HasMethod

func (t Instance) HasMethod(m string) bool

func (Instance) IsComposite

func (t Instance) IsComposite() bool

func (Instance) IsMultiple

func (p Instance) IsMultiple() bool

func (Instance) MakeAlias

func (p Instance) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (Instance) MethodReturnType

func (t Instance) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Instance) Methods

func (p Instance) Methods() map[string]MethodSpec

func (Instance) MustResolve

func (t Instance) MustResolve(m string) MethodSpec

func (Instance) Resolve

func (t Instance) Resolve(m string) (MethodSpec, bool)

func (Instance) SelfDef

func (p Instance) SelfDef(m string, spec MethodSpec)

func (Instance) String

func (t Instance) String() string

func (Instance) TransformAST

func (t Instance) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (Instance) UserDefined

func (p Instance) UserDefined() bool

type Int

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

func (Int) Alias

func (t Int) Alias(existingMethod, newMethod string)

func (Int) BlockArgTypes

func (t Int) BlockArgTypes(m string, args []Type) []Type

TODO we don't need this in the interface. Instead, the parser or compiler should retrieve the MethodSpec and check for a not-nil blockArgs (which will then need to be exported

func (Int) ClassName

func (p Int) ClassName() string

func (Int) Def

func (p Int) Def(m string, spec MethodSpec)

func (Int) Equals

func (t Int) Equals(t2 Type) bool

func (Int) GenerateMethods

func (p Int) GenerateMethods(iface interface{}, exclusions ...string)

func (Int) GoType

func (t Int) GoType() string

func (Int) HasMethod

func (t Int) HasMethod(m string) bool

func (Int) IsComposite

func (t Int) IsComposite() bool

func (Int) IsMultiple

func (p Int) IsMultiple() bool

func (Int) MakeAlias

func (p Int) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (Int) MethodReturnType

func (t Int) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Int) Methods

func (p Int) Methods() map[string]MethodSpec

func (Int) MustResolve

func (t Int) MustResolve(m string) MethodSpec

func (Int) Resolve

func (t Int) Resolve(m string) (MethodSpec, bool)

func (Int) SelfDef

func (p Int) SelfDef(m string, spec MethodSpec)

func (Int) String

func (t Int) String() string

func (Int) TransformAST

func (t Int) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (Int) UserDefined

func (p Int) UserDefined() bool

type MethodSpec

type MethodSpec struct {
	// When inferring the return types for methods that take a block, we must
	// consider the return type of the block (since blocks cannot explicitly
	// return, this means resolving the type of the last expression in the block
	// -- no plans to support `break` or `next` yet as I'm honestly unsure if
	// I've ever seen them in the wild) and the receiver, since in a composite
	// type the inner type will determine or factor into the return type. Args
	// are often not given with Enumerable but when they are that can determine
	// the return type.
	ReturnType ReturnTypeFunc

	TransformAST TransformFunc
	// contains filtered or unexported fields
}

Holds data for methods implemented "natively" in Thanos, initially targeting built-in methods on native Ruby datastructures and types. This of course means all the stuff that comes in Enumerable, which involves doing things with blocks that in theory _could_ be done with anonymous functions in Go but translates most efficiently and idiomatically to simple for loops.

type Multiple

type Multiple []Type

func (Multiple) BlockArgTypes

func (t Multiple) BlockArgTypes(m string, args []Type) []Type

func (Multiple) ClassName

func (t Multiple) ClassName() string

func (Multiple) Equals

func (mt Multiple) Equals(t Type) bool

func (Multiple) GoType

func (t Multiple) GoType() string

func (Multiple) HasMethod

func (t Multiple) HasMethod(m string) bool

func (Multiple) Imports

func (t Multiple) Imports(s string) []string

func (Multiple) IsComposite

func (t Multiple) IsComposite() bool

func (Multiple) IsMultiple

func (t Multiple) IsMultiple() bool

func (Multiple) MethodReturnType

func (t Multiple) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Multiple) String

func (t Multiple) String() string

func (Multiple) TransformAST

func (t Multiple) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

type Numeric

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

func (Numeric) Alias

func (t Numeric) Alias(existingMethod, newMethod string)

func (Numeric) BlockArgTypes

func (t Numeric) BlockArgTypes(m string, args []Type) []Type

TODO we don't need this in the interface. Instead, the parser or compiler should retrieve the MethodSpec and check for a not-nil blockArgs (which will then need to be exported

func (Numeric) ClassName

func (p Numeric) ClassName() string

func (Numeric) Def

func (p Numeric) Def(m string, spec MethodSpec)

func (Numeric) Equals

func (t Numeric) Equals(t2 Type) bool

func (Numeric) GenerateMethods

func (p Numeric) GenerateMethods(iface interface{}, exclusions ...string)

func (Numeric) GoType

func (t Numeric) GoType() string

func (Numeric) HasMethod

func (t Numeric) HasMethod(m string) bool

func (Numeric) IsComposite

func (t Numeric) IsComposite() bool

func (Numeric) IsMultiple

func (p Numeric) IsMultiple() bool

func (Numeric) MakeAlias

func (p Numeric) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (Numeric) MethodReturnType

func (t Numeric) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Numeric) Methods

func (p Numeric) Methods() map[string]MethodSpec

func (Numeric) MustResolve

func (t Numeric) MustResolve(m string) MethodSpec

func (Numeric) Resolve

func (t Numeric) Resolve(m string) (MethodSpec, bool)

func (Numeric) SelfDef

func (p Numeric) SelfDef(m string, spec MethodSpec)

func (Numeric) String

func (t Numeric) String() string

func (Numeric) TransformAST

func (t Numeric) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (Numeric) UserDefined

func (p Numeric) UserDefined() bool

type Object

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

func (Object) Alias

func (t Object) Alias(existingMethod, newMethod string)

func (Object) BlockArgTypes

func (t Object) BlockArgTypes(m string, args []Type) []Type

func (Object) ClassName

func (p Object) ClassName() string

func (Object) Def

func (p Object) Def(m string, spec MethodSpec)

func (Object) Equals

func (t Object) Equals(t2 Type) bool

func (Object) GenerateMethods

func (p Object) GenerateMethods(iface interface{}, exclusions ...string)

func (Object) GoType

func (t Object) GoType() string

func (Object) HasMethod

func (t Object) HasMethod(m string) bool

func (Object) IsComposite

func (t Object) IsComposite() bool

func (Object) IsMultiple

func (p Object) IsMultiple() bool

func (Object) MakeAlias

func (p Object) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (Object) MethodReturnType

func (t Object) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Object) Methods

func (p Object) Methods() map[string]MethodSpec

func (Object) MustResolve

func (t Object) MustResolve(m string) MethodSpec

func (Object) Resolve

func (t Object) Resolve(m string) (MethodSpec, bool)

func (Object) SelfDef

func (p Object) SelfDef(m string, spec MethodSpec)

func (Object) String

func (t Object) String() string

func (Object) TransformAST

func (t Object) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (Object) UserDefined

func (p Object) UserDefined() bool

type Proc

type Proc struct {
	Args       []Type
	ReturnType Type
	Instance   instance
}

func NewProc

func NewProc() *Proc

func (*Proc) BlockArgTypes

func (t *Proc) BlockArgTypes(m string, args []Type) []Type

func (*Proc) ClassName

func (t *Proc) ClassName() string

func (*Proc) Equals

func (t *Proc) Equals(t2 Type) bool

func (*Proc) GoType

func (t *Proc) GoType() string

func (*Proc) HasMethod

func (t *Proc) HasMethod(method string) bool

func (*Proc) IsComposite

func (t *Proc) IsComposite() bool

func (*Proc) IsMultiple

func (t *Proc) IsMultiple() bool

func (*Proc) MethodReturnType

func (t *Proc) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (*Proc) String

func (t *Proc) String() string

func (*Proc) TransformAST

func (t *Proc) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

type Range

type Range struct {
	Element  Type
	Instance instance
}

func (Range) BlockArgTypes

func (t Range) BlockArgTypes(m string, args []Type) []Type

func (Range) ClassName

func (t Range) ClassName() string

func (Range) Equals

func (t Range) Equals(t2 Type) bool

func (Range) GoType

func (t Range) GoType() string

func (Range) HasMethod

func (t Range) HasMethod(m string) bool

func (Range) Inner

func (t Range) Inner() Type

func (Range) IsComposite

func (t Range) IsComposite() bool

func (Range) IsMultiple

func (t Range) IsMultiple() bool

func (Range) MethodReturnType

func (t Range) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Range) MustResolve

func (t Range) MustResolve(m string) MethodSpec

func (Range) Outer

func (t Range) Outer() Type

func (Range) Resolve

func (t Range) Resolve(m string) (MethodSpec, bool)

func (Range) String

func (t Range) String() string

func (Range) TransformAST

func (t Range) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

type Regexp

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

func (Regexp) Alias

func (t Regexp) Alias(existingMethod, newMethod string)

func (Regexp) BlockArgTypes

func (t Regexp) BlockArgTypes(m string, args []Type) []Type

func (Regexp) ClassName

func (p Regexp) ClassName() string

func (Regexp) Def

func (p Regexp) Def(m string, spec MethodSpec)

func (Regexp) Equals

func (t Regexp) Equals(t2 Type) bool

func (Regexp) GenerateMethods

func (p Regexp) GenerateMethods(iface interface{}, exclusions ...string)

func (Regexp) GoType

func (t Regexp) GoType() string

func (Regexp) HasMethod

func (t Regexp) HasMethod(m string) bool

func (Regexp) IsComposite

func (t Regexp) IsComposite() bool

func (Regexp) IsMultiple

func (p Regexp) IsMultiple() bool

func (Regexp) MakeAlias

func (p Regexp) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (Regexp) MethodReturnType

func (t Regexp) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Regexp) Methods

func (p Regexp) Methods() map[string]MethodSpec

func (Regexp) MustResolve

func (t Regexp) MustResolve(m string) MethodSpec

func (Regexp) Resolve

func (t Regexp) Resolve(m string) (MethodSpec, bool)

func (Regexp) SelfDef

func (p Regexp) SelfDef(m string, spec MethodSpec)

func (Regexp) String

func (t Regexp) String() string

func (Regexp) TransformAST

func (t Regexp) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (Regexp) UserDefined

func (p Regexp) UserDefined() bool

type ReturnTypeFunc

type ReturnTypeFunc func(receiverType Type, blockReturnType Type, args []Type) (Type, error)

type Set

type Set struct {
	Element  Type
	Instance instance
}

func (Set) BlockArgTypes

func (t Set) BlockArgTypes(m string, args []Type) []Type

func (Set) ClassName

func (t Set) ClassName() string

func (Set) Equals

func (t Set) Equals(t2 Type) bool

func (Set) GoType

func (t Set) GoType() string

func (Set) HasMethod

func (t Set) HasMethod(m string) bool

func (Set) Inner

func (t Set) Inner() Type

func (Set) IsComposite

func (t Set) IsComposite() bool

func (Set) IsMultiple

func (t Set) IsMultiple() bool

func (Set) MethodReturnType

func (t Set) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Set) MustResolve

func (t Set) MustResolve(m string) MethodSpec

func (Set) Outer

func (t Set) Outer() Type

func (Set) Resolve

func (t Set) Resolve(m string) (MethodSpec, bool)

func (Set) String

func (t Set) String() string

func (Set) TransformAST

func (t Set) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

type Simple

type Simple int
const (
	ConstType Simple = iota
	NilType
	FuncType
	AnyType
	ErrorType
)

func (Simple) BlockArgTypes

func (t Simple) BlockArgTypes(m string, args []Type) []Type

func (Simple) ClassName

func (t Simple) ClassName() string

func (Simple) Equals

func (t Simple) Equals(t2 Type) bool

func (Simple) GoType

func (t Simple) GoType() string

func (Simple) HasMethod

func (t Simple) HasMethod(m string) bool

lies but needed for now

func (Simple) IsComposite

func (t Simple) IsComposite() bool

func (Simple) IsMultiple

func (t Simple) IsMultiple() bool

func (Simple) MethodReturnType

func (t Simple) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Simple) String

func (i Simple) String() string

func (Simple) TransformAST

func (t Simple) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

type String

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

func (String) Alias

func (t String) Alias(existingMethod, newMethod string)

func (String) BlockArgTypes

func (t String) BlockArgTypes(m string, args []Type) []Type

func (String) ClassName

func (p String) ClassName() string

func (String) Def

func (p String) Def(m string, spec MethodSpec)

func (String) Equals

func (t String) Equals(t2 Type) bool

func (String) GenerateMethods

func (p String) GenerateMethods(iface interface{}, exclusions ...string)

func (String) GoType

func (t String) GoType() string

func (String) HasMethod

func (t String) HasMethod(m string) bool

func (String) IsComposite

func (t String) IsComposite() bool

func (String) IsMultiple

func (p String) IsMultiple() bool

func (String) MakeAlias

func (p String) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (String) MethodReturnType

func (t String) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (String) Methods

func (p String) Methods() map[string]MethodSpec

func (String) MustResolve

func (t String) MustResolve(m string) MethodSpec

func (String) Resolve

func (t String) Resolve(m string) (MethodSpec, bool)

func (String) SelfDef

func (p String) SelfDef(m string, spec MethodSpec)

func (String) String

func (t String) String() string

func (String) TransformAST

func (t String) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (String) UserDefined

func (p String) UserDefined() bool

type Symbol

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

func (Symbol) Alias

func (t Symbol) Alias(existingMethod, newMethod string)

func (Symbol) BlockArgTypes

func (t Symbol) BlockArgTypes(m string, args []Type) []Type

func (Symbol) ClassName

func (p Symbol) ClassName() string

func (Symbol) Def

func (p Symbol) Def(m string, spec MethodSpec)

func (Symbol) Equals

func (t Symbol) Equals(t2 Type) bool

func (Symbol) GenerateMethods

func (p Symbol) GenerateMethods(iface interface{}, exclusions ...string)

func (Symbol) GoType

func (t Symbol) GoType() string

func (Symbol) HasMethod

func (t Symbol) HasMethod(m string) bool

func (Symbol) IsComposite

func (t Symbol) IsComposite() bool

func (Symbol) IsMultiple

func (p Symbol) IsMultiple() bool

func (Symbol) MakeAlias

func (p Symbol) MakeAlias(existingMethod, newMethod string, classMethod bool)

func (Symbol) MethodReturnType

func (t Symbol) MethodReturnType(m string, b Type, args []Type) (Type, error)

func (Symbol) Methods

func (p Symbol) Methods() map[string]MethodSpec

func (Symbol) MustResolve

func (t Symbol) MustResolve(m string) MethodSpec

func (Symbol) Resolve

func (t Symbol) Resolve(m string) (MethodSpec, bool)

func (Symbol) SelfDef

func (p Symbol) SelfDef(m string, spec MethodSpec)

func (Symbol) String

func (t Symbol) String() string

func (Symbol) TransformAST

func (t Symbol) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform

func (Symbol) UserDefined

func (p Symbol) UserDefined() bool

type Transform

type Transform struct {
	Stmts   []ast.Stmt
	Expr    ast.Expr
	Imports []string
}

type TransformFunc

type TransformFunc func(TypeExpr, []TypeExpr, *Block, bst.IdentTracker) Transform

type Type

type Type interface {
	BlockArgTypes(string, []Type) []Type
	ClassName() string
	Equals(Type) bool
	GoType() string
	HasMethod(string) bool
	IsComposite() bool
	IsMultiple() bool
	MethodReturnType(string, Type, []Type) (Type, error)
	String() string
	TransformAST(string, ast.Expr, []TypeExpr, *Block, bst.IdentTracker) Transform
}

func NewArray

func NewArray(inner Type) Type

func NewHash

func NewHash(k, v Type) Type

func NewRange

func NewRange(inner Type) Type

func NewSet

func NewSet(inner Type) Type

type TypeExpr

type TypeExpr struct {
	Type Type
	Expr ast.Expr
}

Jump to

Keyboard shortcuts

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