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 ¶
- Variables
- func FprintVerb(t Type) string
- func RegisterType(goValue interface{}, thanosTypeOrConstructor interface{})
- func ToSnakeCase(str string) string
- func UnwrapTypeExprs(typeExprs []TypeExpr) []ast.Expr
- type Array
- func (t Array) BlockArgTypes(m string, args []Type) []Type
- func (t Array) ClassName() string
- func (t Array) Equals(t2 Type) bool
- func (t Array) GoType() string
- func (t Array) HasMethod(method string) bool
- func (t Array) Inner() Type
- func (t Array) IsComposite() bool
- func (t Array) IsMultiple() bool
- func (t Array) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (t Array) Outer() Type
- func (t Array) String() string
- func (t Array) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- type Block
- type Bool
- func (t Bool) Alias(existingMethod, newMethod string)
- func (t Bool) BlockArgTypes(m string, args []Type) []Type
- func (p Bool) ClassName() string
- func (p Bool) Def(m string, spec MethodSpec)
- func (t Bool) Equals(t2 Type) bool
- func (p Bool) GenerateMethods(iface interface{}, exclusions ...string)
- func (t Bool) GoType() string
- func (t Bool) HasMethod(m string) bool
- func (t Bool) IsComposite() bool
- func (p Bool) IsMultiple() bool
- func (p Bool) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t Bool) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p Bool) Methods() map[string]MethodSpec
- func (t Bool) MustResolve(m string) MethodSpec
- func (t Bool) Resolve(m string) (MethodSpec, bool)
- func (p Bool) SelfDef(m string, spec MethodSpec)
- func (t Bool) String() string
- func (t Bool) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p Bool) UserDefined() bool
- type Class
- func (p Class) Alias(existingMethod, newMethod string)
- func (t *Class) BlockArgTypes(m string, args []Type) []Type
- func (p Class) ClassName() string
- func (t *Class) Constructor() string
- func (p Class) Def(m string, spec MethodSpec)
- func (t *Class) Equals(t2 Type) bool
- func (p Class) GenerateMethods(iface interface{}, exclusions ...string)
- func (t *Class) GoType() string
- func (t *Class) HasMethod(m string) bool
- func (t *Class) IsComposite() bool
- func (p Class) IsMultiple() bool
- func (p Class) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t *Class) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p Class) Methods() map[string]MethodSpec
- func (t *Class) MustResolve(m string) MethodSpec
- func (t *Class) Resolve(m string) (MethodSpec, bool)
- func (p Class) SelfDef(m string, spec MethodSpec)
- func (t *Class) String() string
- func (t *Class) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p Class) UserDefined() bool
- type CompositeType
- type Float
- func (t Float) Alias(existingMethod, newMethod string)
- func (t Float) BlockArgTypes(m string, args []Type) []Type
- func (p Float) ClassName() string
- func (p Float) Def(m string, spec MethodSpec)
- func (t Float) Equals(t2 Type) bool
- func (p Float) GenerateMethods(iface interface{}, exclusions ...string)
- func (t Float) GoType() string
- func (t Float) HasMethod(m string) bool
- func (t Float) IsComposite() bool
- func (p Float) IsMultiple() bool
- func (p Float) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t Float) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p Float) Methods() map[string]MethodSpec
- func (t Float) MustResolve(m string) MethodSpec
- func (t Float) Resolve(m string) (MethodSpec, bool)
- func (p Float) SelfDef(m string, spec MethodSpec)
- func (t Float) String() string
- func (t Float) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p Float) UserDefined() bool
- type Hash
- func (t Hash) BlockArgTypes(m string, args []Type) []Type
- func (t Hash) ClassName() string
- func (t Hash) Equals(t2 Type) bool
- func (t Hash) GoType() string
- func (t Hash) HasMethod(method string) bool
- func (t Hash) Inner() Type
- func (t Hash) IsComposite() bool
- func (t Hash) IsMultiple() bool
- func (t Hash) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (t Hash) Outer() Type
- func (t Hash) String() string
- func (t Hash) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- type Instance
- func (t Instance) Alias(existingMethod, newMethod string)
- func (t Instance) BlockArgTypes(m string, args []Type) []Type
- func (p Instance) ClassName() string
- func (p Instance) Def(m string, spec MethodSpec)
- func (t Instance) Equals(t2 Type) bool
- func (p Instance) GenerateMethods(iface interface{}, exclusions ...string)
- func (t Instance) GoType() string
- func (t Instance) HasMethod(m string) bool
- func (t Instance) IsComposite() bool
- func (p Instance) IsMultiple() bool
- func (p Instance) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t Instance) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p Instance) Methods() map[string]MethodSpec
- func (t Instance) MustResolve(m string) MethodSpec
- func (t Instance) Resolve(m string) (MethodSpec, bool)
- func (p Instance) SelfDef(m string, spec MethodSpec)
- func (t Instance) String() string
- func (t Instance) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p Instance) UserDefined() bool
- type Int
- func (t Int) Alias(existingMethod, newMethod string)
- func (t Int) BlockArgTypes(m string, args []Type) []Type
- func (p Int) ClassName() string
- func (p Int) Def(m string, spec MethodSpec)
- func (t Int) Equals(t2 Type) bool
- func (p Int) GenerateMethods(iface interface{}, exclusions ...string)
- func (t Int) GoType() string
- func (t Int) HasMethod(m string) bool
- func (t Int) IsComposite() bool
- func (p Int) IsMultiple() bool
- func (p Int) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t Int) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p Int) Methods() map[string]MethodSpec
- func (t Int) MustResolve(m string) MethodSpec
- func (t Int) Resolve(m string) (MethodSpec, bool)
- func (p Int) SelfDef(m string, spec MethodSpec)
- func (t Int) String() string
- func (t Int) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p Int) UserDefined() bool
- type MethodSpec
- type Multiple
- func (t Multiple) BlockArgTypes(m string, args []Type) []Type
- func (t Multiple) ClassName() string
- func (mt Multiple) Equals(t Type) bool
- func (t Multiple) GoType() string
- func (t Multiple) HasMethod(m string) bool
- func (t Multiple) Imports(s string) []string
- func (t Multiple) IsComposite() bool
- func (t Multiple) IsMultiple() bool
- func (t Multiple) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (t Multiple) String() string
- func (t Multiple) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- type Numeric
- func (t Numeric) Alias(existingMethod, newMethod string)
- func (t Numeric) BlockArgTypes(m string, args []Type) []Type
- func (p Numeric) ClassName() string
- func (p Numeric) Def(m string, spec MethodSpec)
- func (t Numeric) Equals(t2 Type) bool
- func (p Numeric) GenerateMethods(iface interface{}, exclusions ...string)
- func (t Numeric) GoType() string
- func (t Numeric) HasMethod(m string) bool
- func (t Numeric) IsComposite() bool
- func (p Numeric) IsMultiple() bool
- func (p Numeric) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t Numeric) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p Numeric) Methods() map[string]MethodSpec
- func (t Numeric) MustResolve(m string) MethodSpec
- func (t Numeric) Resolve(m string) (MethodSpec, bool)
- func (p Numeric) SelfDef(m string, spec MethodSpec)
- func (t Numeric) String() string
- func (t Numeric) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p Numeric) UserDefined() bool
- type Object
- func (t Object) Alias(existingMethod, newMethod string)
- func (t Object) BlockArgTypes(m string, args []Type) []Type
- func (p Object) ClassName() string
- func (p Object) Def(m string, spec MethodSpec)
- func (t Object) Equals(t2 Type) bool
- func (p Object) GenerateMethods(iface interface{}, exclusions ...string)
- func (t Object) GoType() string
- func (t Object) HasMethod(m string) bool
- func (t Object) IsComposite() bool
- func (p Object) IsMultiple() bool
- func (p Object) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t Object) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p Object) Methods() map[string]MethodSpec
- func (t Object) MustResolve(m string) MethodSpec
- func (t Object) Resolve(m string) (MethodSpec, bool)
- func (p Object) SelfDef(m string, spec MethodSpec)
- func (t Object) String() string
- func (t Object) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p Object) UserDefined() bool
- type Proc
- func (t *Proc) BlockArgTypes(m string, args []Type) []Type
- func (t *Proc) ClassName() string
- func (t *Proc) Equals(t2 Type) bool
- func (t *Proc) GoType() string
- func (t *Proc) HasMethod(method string) bool
- func (t *Proc) IsComposite() bool
- func (t *Proc) IsMultiple() bool
- func (t *Proc) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (t *Proc) String() string
- func (t *Proc) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- type Range
- func (t Range) BlockArgTypes(m string, args []Type) []Type
- func (t Range) ClassName() string
- func (t Range) Equals(t2 Type) bool
- func (t Range) GoType() string
- func (t Range) HasMethod(m string) bool
- func (t Range) Inner() Type
- func (t Range) IsComposite() bool
- func (t Range) IsMultiple() bool
- func (t Range) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (t Range) MustResolve(m string) MethodSpec
- func (t Range) Outer() Type
- func (t Range) Resolve(m string) (MethodSpec, bool)
- func (t Range) String() string
- func (t Range) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- type Regexp
- func (t Regexp) Alias(existingMethod, newMethod string)
- func (t Regexp) BlockArgTypes(m string, args []Type) []Type
- func (p Regexp) ClassName() string
- func (p Regexp) Def(m string, spec MethodSpec)
- func (t Regexp) Equals(t2 Type) bool
- func (p Regexp) GenerateMethods(iface interface{}, exclusions ...string)
- func (t Regexp) GoType() string
- func (t Regexp) HasMethod(m string) bool
- func (t Regexp) IsComposite() bool
- func (p Regexp) IsMultiple() bool
- func (p Regexp) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t Regexp) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p Regexp) Methods() map[string]MethodSpec
- func (t Regexp) MustResolve(m string) MethodSpec
- func (t Regexp) Resolve(m string) (MethodSpec, bool)
- func (p Regexp) SelfDef(m string, spec MethodSpec)
- func (t Regexp) String() string
- func (t Regexp) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p Regexp) UserDefined() bool
- type ReturnTypeFunc
- type Set
- func (t Set) BlockArgTypes(m string, args []Type) []Type
- func (t Set) ClassName() string
- func (t Set) Equals(t2 Type) bool
- func (t Set) GoType() string
- func (t Set) HasMethod(m string) bool
- func (t Set) Inner() Type
- func (t Set) IsComposite() bool
- func (t Set) IsMultiple() bool
- func (t Set) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (t Set) MustResolve(m string) MethodSpec
- func (t Set) Outer() Type
- func (t Set) Resolve(m string) (MethodSpec, bool)
- func (t Set) String() string
- func (t Set) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- type Simple
- func (t Simple) BlockArgTypes(m string, args []Type) []Type
- func (t Simple) ClassName() string
- func (t Simple) Equals(t2 Type) bool
- func (t Simple) GoType() string
- func (t Simple) HasMethod(m string) bool
- func (t Simple) IsComposite() bool
- func (t Simple) IsMultiple() bool
- func (t Simple) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (i Simple) String() string
- func (t Simple) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- type String
- func (t String) Alias(existingMethod, newMethod string)
- func (t String) BlockArgTypes(m string, args []Type) []Type
- func (p String) ClassName() string
- func (p String) Def(m string, spec MethodSpec)
- func (t String) Equals(t2 Type) bool
- func (p String) GenerateMethods(iface interface{}, exclusions ...string)
- func (t String) GoType() string
- func (t String) HasMethod(m string) bool
- func (t String) IsComposite() bool
- func (p String) IsMultiple() bool
- func (p String) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t String) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p String) Methods() map[string]MethodSpec
- func (t String) MustResolve(m string) MethodSpec
- func (t String) Resolve(m string) (MethodSpec, bool)
- func (p String) SelfDef(m string, spec MethodSpec)
- func (t String) String() string
- func (t String) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p String) UserDefined() bool
- type Symbol
- func (t Symbol) Alias(existingMethod, newMethod string)
- func (t Symbol) BlockArgTypes(m string, args []Type) []Type
- func (p Symbol) ClassName() string
- func (p Symbol) Def(m string, spec MethodSpec)
- func (t Symbol) Equals(t2 Type) bool
- func (p Symbol) GenerateMethods(iface interface{}, exclusions ...string)
- func (t Symbol) GoType() string
- func (t Symbol) HasMethod(m string) bool
- func (t Symbol) IsComposite() bool
- func (p Symbol) IsMultiple() bool
- func (p Symbol) MakeAlias(existingMethod, newMethod string, classMethod bool)
- func (t Symbol) MethodReturnType(m string, b Type, args []Type) (Type, error)
- func (p Symbol) Methods() map[string]MethodSpec
- func (t Symbol) MustResolve(m string) MethodSpec
- func (t Symbol) Resolve(m string) (MethodSpec, bool)
- func (p Symbol) SelfDef(m string, spec MethodSpec)
- func (t Symbol) String() string
- func (t Symbol) TransformAST(m string, rcvr ast.Expr, args []TypeExpr, blk *Block, it bst.IdentTracker) Transform
- func (p Symbol) UserDefined() bool
- type Transform
- type TransformFunc
- type Type
- type TypeExpr
Constants ¶
This section is empty.
Variables ¶
var ( KernelType = kernel{newProto("Kernel", "", ClassRegistry)} KernelClass = NewClass("Kernel", "", KernelType, ClassRegistry) )
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"), } }, }
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"), } }, }
var ArrayClass = NewClass("Array", "Object", nil, ClassRegistry)
var BoolClass = NewClass("Boolean", "Object", BoolType, ClassRegistry)
var BoolType = Bool{newProto("Boolean", "Object", ClassRegistry)}
var ClassRegistry = &classRegistry{registry: make(map[string]*Class)}
var FileType = NewClass("File", "Object", nil, ClassRegistry)
var FloatClass = NewClass("Float", "Numeric", FloatType, ClassRegistry)
var FloatType = Float{newProto("Float", "Numeric", ClassRegistry)}
var HashClass = NewClass("Hash", "Object", nil, ClassRegistry)
var IntClass = NewClass("Integer", "Numeric", IntType, ClassRegistry)
var IntType = Int{newProto("Integer", "Numeric", ClassRegistry)}
var MatchDataClass = NewClass("MatchData", "Object", MatchDataType, ClassRegistry)
var MatchDataType = matchData{newProto("MatchData", "Object", ClassRegistry)}
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, } }, }
var NumericClass = NewClass("Numeric", "Object", NumericType, ClassRegistry)
var NumericType = Numeric{newProto("Numeric", "Object", ClassRegistry)}
var ObjectClass = NewClass("Object", "", ObjectType, ClassRegistry)
var ObjectType = Object{newProto("Object", "", ClassRegistry)}
var ProcClass = NewClass("Proc", "Object", nil, ClassRegistry)
var RangeClass = NewClass("Range", "Object", nil, ClassRegistry)
var RegexpClass = NewClass("Regexp", "Object", RegexpType, ClassRegistry)
var RegexpType = Regexp{newProto("Regexp", "Object", ClassRegistry)}
var SetClass = NewClass("Set", "Object", nil, ClassRegistry)
var StringClass = NewClass("String", "Object", StringType, ClassRegistry)
var StringType = String{newProto("String", "Object", ClassRegistry)}
var SymbolClass = NewClass("Symbol", "Object", SymbolType, ClassRegistry)
var SymbolType = Symbol{newProto("Symbol", "Object", ClassRegistry)}
Functions ¶
func FprintVerb ¶
func RegisterType ¶
func RegisterType(goValue interface{}, thanosTypeOrConstructor interface{})
func ToSnakeCase ¶
func UnwrapTypeExprs ¶
Types ¶
type Array ¶
type Array struct { Element Type Instance instance }
func (Array) IsComposite ¶
func (Array) IsMultiple ¶
func (Array) MethodReturnType ¶
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
func (Bool) Def ¶
func (p Bool) Def(m string, spec MethodSpec)
func (Bool) GenerateMethods ¶
func (p Bool) GenerateMethods(iface interface{}, exclusions ...string)
func (Bool) IsComposite ¶
func (Bool) IsMultiple ¶
func (p Bool) IsMultiple() bool
func (Bool) MethodReturnType ¶
func (Bool) Methods ¶
func (p Bool) Methods() map[string]MethodSpec
func (Bool) MustResolve ¶
func (t Bool) MustResolve(m string) MethodSpec
func (Bool) SelfDef ¶
func (p Bool) SelfDef(m string, spec MethodSpec)
func (Bool) TransformAST ¶
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 (*Class) Constructor ¶
func (Class) Def ¶
func (p Class) Def(m string, spec MethodSpec)
func (Class) GenerateMethods ¶
func (p Class) GenerateMethods(iface interface{}, exclusions ...string)
func (*Class) IsComposite ¶
func (Class) IsMultiple ¶
func (p Class) IsMultiple() bool
func (*Class) MethodReturnType ¶
func (Class) Methods ¶
func (p Class) Methods() map[string]MethodSpec
func (*Class) MustResolve ¶
func (t *Class) MustResolve(m string) MethodSpec
func (Class) SelfDef ¶
func (p Class) SelfDef(m string, spec MethodSpec)
func (*Class) TransformAST ¶
func (Class) UserDefined ¶
func (p Class) UserDefined() bool
type CompositeType ¶
type Float ¶
type Float struct {
// contains filtered or unexported fields
}
func (Float) Def ¶
func (p Float) Def(m string, spec MethodSpec)
func (Float) GenerateMethods ¶
func (p Float) GenerateMethods(iface interface{}, exclusions ...string)
func (Float) IsComposite ¶
func (Float) IsMultiple ¶
func (p Float) IsMultiple() bool
func (Float) MethodReturnType ¶
func (Float) Methods ¶
func (p Float) Methods() map[string]MethodSpec
func (Float) MustResolve ¶
func (t Float) MustResolve(m string) MethodSpec
func (Float) SelfDef ¶
func (p Float) SelfDef(m string, spec MethodSpec)
func (Float) TransformAST ¶
func (Float) UserDefined ¶
func (p Float) UserDefined() bool
type Hash ¶
type Hash struct {
Key, Value Type
Instance instance
}
func (Hash) IsComposite ¶
func (Hash) IsMultiple ¶
func (Hash) MethodReturnType ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
func (Instance) Def ¶
func (p Instance) Def(m string, spec MethodSpec)
func (Instance) GenerateMethods ¶
func (p Instance) GenerateMethods(iface interface{}, exclusions ...string)
func (Instance) IsComposite ¶
func (Instance) IsMultiple ¶
func (p Instance) IsMultiple() bool
func (Instance) MethodReturnType ¶
func (Instance) Methods ¶
func (p Instance) Methods() map[string]MethodSpec
func (Instance) MustResolve ¶
func (t Instance) MustResolve(m string) MethodSpec
func (Instance) SelfDef ¶
func (p Instance) SelfDef(m string, spec MethodSpec)
func (Instance) TransformAST ¶
func (Instance) UserDefined ¶
func (p Instance) UserDefined() bool
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
func (Int) BlockArgTypes ¶
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) Def ¶
func (p Int) Def(m string, spec MethodSpec)
func (Int) GenerateMethods ¶
func (p Int) GenerateMethods(iface interface{}, exclusions ...string)
func (Int) IsComposite ¶
func (Int) IsMultiple ¶
func (p Int) IsMultiple() bool
func (Int) MethodReturnType ¶
func (Int) Methods ¶
func (p Int) Methods() map[string]MethodSpec
func (Int) MustResolve ¶
func (t Int) MustResolve(m string) MethodSpec
func (Int) SelfDef ¶
func (p Int) SelfDef(m string, spec MethodSpec)
func (Int) TransformAST ¶
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) IsComposite ¶
func (Multiple) IsMultiple ¶
func (Multiple) MethodReturnType ¶
type Numeric ¶
type Numeric struct {
// contains filtered or unexported fields
}
func (Numeric) BlockArgTypes ¶
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) Def ¶
func (p Numeric) Def(m string, spec MethodSpec)
func (Numeric) GenerateMethods ¶
func (p Numeric) GenerateMethods(iface interface{}, exclusions ...string)
func (Numeric) IsComposite ¶
func (Numeric) IsMultiple ¶
func (p Numeric) IsMultiple() bool
func (Numeric) MethodReturnType ¶
func (Numeric) Methods ¶
func (p Numeric) Methods() map[string]MethodSpec
func (Numeric) MustResolve ¶
func (t Numeric) MustResolve(m string) MethodSpec
func (Numeric) SelfDef ¶
func (p Numeric) SelfDef(m string, spec MethodSpec)
func (Numeric) TransformAST ¶
func (Numeric) UserDefined ¶
func (p Numeric) UserDefined() bool
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
func (Object) Def ¶
func (p Object) Def(m string, spec MethodSpec)
func (Object) GenerateMethods ¶
func (p Object) GenerateMethods(iface interface{}, exclusions ...string)
func (Object) IsComposite ¶
func (Object) IsMultiple ¶
func (p Object) IsMultiple() bool
func (Object) MethodReturnType ¶
func (Object) Methods ¶
func (p Object) Methods() map[string]MethodSpec
func (Object) MustResolve ¶
func (t Object) MustResolve(m string) MethodSpec
func (Object) SelfDef ¶
func (p Object) SelfDef(m string, spec MethodSpec)
func (Object) TransformAST ¶
func (Object) UserDefined ¶
func (p Object) UserDefined() bool
type Range ¶
type Range struct { Element Type Instance instance }
func (Range) IsComposite ¶
func (Range) IsMultiple ¶
func (Range) MethodReturnType ¶
func (Range) MustResolve ¶
func (t Range) MustResolve(m string) MethodSpec
type Regexp ¶
type Regexp struct {
// contains filtered or unexported fields
}
func (Regexp) Def ¶
func (p Regexp) Def(m string, spec MethodSpec)
func (Regexp) GenerateMethods ¶
func (p Regexp) GenerateMethods(iface interface{}, exclusions ...string)
func (Regexp) IsComposite ¶
func (Regexp) IsMultiple ¶
func (p Regexp) IsMultiple() bool
func (Regexp) MethodReturnType ¶
func (Regexp) Methods ¶
func (p Regexp) Methods() map[string]MethodSpec
func (Regexp) MustResolve ¶
func (t Regexp) MustResolve(m string) MethodSpec
func (Regexp) SelfDef ¶
func (p Regexp) SelfDef(m string, spec MethodSpec)
func (Regexp) TransformAST ¶
func (Regexp) UserDefined ¶
func (p Regexp) UserDefined() bool
type ReturnTypeFunc ¶
type Set ¶
type Set struct { Element Type Instance instance }
func (Set) IsComposite ¶
func (Set) IsMultiple ¶
func (Set) MethodReturnType ¶
func (Set) MustResolve ¶
func (t Set) MustResolve(m string) MethodSpec
type Simple ¶
type Simple int
func (Simple) IsComposite ¶
func (Simple) IsMultiple ¶
func (Simple) MethodReturnType ¶
type String ¶
type String struct {
// contains filtered or unexported fields
}
func (String) Def ¶
func (p String) Def(m string, spec MethodSpec)
func (String) GenerateMethods ¶
func (p String) GenerateMethods(iface interface{}, exclusions ...string)
func (String) IsComposite ¶
func (String) IsMultiple ¶
func (p String) IsMultiple() bool
func (String) MethodReturnType ¶
func (String) Methods ¶
func (p String) Methods() map[string]MethodSpec
func (String) MustResolve ¶
func (t String) MustResolve(m string) MethodSpec
func (String) SelfDef ¶
func (p String) SelfDef(m string, spec MethodSpec)
func (String) TransformAST ¶
func (String) UserDefined ¶
func (p String) UserDefined() bool
type Symbol ¶
type Symbol struct {
// contains filtered or unexported fields
}
func (Symbol) Def ¶
func (p Symbol) Def(m string, spec MethodSpec)
func (Symbol) GenerateMethods ¶
func (p Symbol) GenerateMethods(iface interface{}, exclusions ...string)
func (Symbol) IsComposite ¶
func (Symbol) IsMultiple ¶
func (p Symbol) IsMultiple() bool
func (Symbol) MethodReturnType ¶
func (Symbol) Methods ¶
func (p Symbol) Methods() map[string]MethodSpec
func (Symbol) MustResolve ¶
func (t Symbol) MustResolve(m string) MethodSpec
func (Symbol) SelfDef ¶
func (p Symbol) SelfDef(m string, spec MethodSpec)
func (Symbol) TransformAST ¶
func (Symbol) UserDefined ¶
func (p Symbol) UserDefined() bool
type TransformFunc ¶
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 }