object

package
v2.0.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package object defines the standard set of object types in Tamarin.

For external users of Tamarin, often an object.Object interface will be type asserted to a specific object type, such as *object.Float.

For example:

switch obj := obj.(type) {
case *object.String:
	// do something with obj.Value()
case *object.Float:
	// do something with obj.Value()
}

The Type() method of each object may also be used to get a string name of the object type, such as "string" or "float".

Index

Constants

View Source
const OneMB = 1024 * 1024

Variables

View Source
var (
	Nil   = &NilType{}
	True  = &Bool{value: true}
	False = &Bool{value: false}
)

Functions

func AsList

func AsList(obj Object) (*List, *Error)

func AsMap

func AsMap(obj Object) (*Map, *Error)

func AsSet

func AsSet(obj Object) (*Set, *Error)

func CompareTypes

func CompareTypes(a, b Object) int

func Equals

func Equals(a, b Object) bool

func GetLimits

func GetLimits(ctx context.Context) (*limits.Limits, bool)

GetLimits returns Tamarin limits associated with the context, if any.

func IsError

func IsError(obj Object) bool

func ResolveIndex

func ResolveIndex(idx int64, size int64) (int64, error)

ResolveIndex checks that the index is inbounds and transforms a negative index into the corresponding positive index. If the index is out of bounds, an error is returned.

func ResolveIntSlice

func ResolveIntSlice(slice Slice, size int64) (start int64, stop int64, err error)

ResolveIntSlice checks that the slice start and stop indices are inbounds and transforms negative indices into the corresponding positive indices. If the slice is out of bounds, an error is returned.

func WithCallFunc

func WithCallFunc(ctx context.Context, fn CallFunc) context.Context

WithCallFunc adds an CallFunc to the context, which can be used by objects to call a Tamarin function at runtime.

func WithCodeFunc

func WithCodeFunc(ctx context.Context, fn CodeFunc) context.Context

WithCodeFunc adds an CodeFunc to the context, which can be used by objects to retrieve the active code at runtime

func WithLimits

func WithLimits(ctx context.Context, l *limits.Limits) context.Context

WithCodeFunc adds an CodeFunc to the context, which can be used by objects to retrieve the active code at runtime

Types

type BSlice

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

func NewBSlice

func NewBSlice(value []byte) *BSlice

func (*BSlice) Clone

func (b *BSlice) Clone() *BSlice

func (*BSlice) Compare

func (b *BSlice) Compare(other Object) (int, error)

func (*BSlice) Contains

func (b *BSlice) Contains(obj Object) *Bool

func (*BSlice) ContainsAny

func (b *BSlice) ContainsAny(obj Object) Object

func (*BSlice) ContainsRune

func (b *BSlice) ContainsRune(obj Object) Object

func (*BSlice) Count

func (b *BSlice) Count(obj Object) Object

func (*BSlice) DelItem

func (b *BSlice) DelItem(key Object) *Error

func (*BSlice) Equals

func (b *BSlice) Equals(other Object) Object

func (*BSlice) GetAttr

func (b *BSlice) GetAttr(name string) (Object, bool)

func (*BSlice) GetItem

func (b *BSlice) GetItem(key Object) (Object, *Error)

func (*BSlice) GetSlice

func (b *BSlice) GetSlice(slice Slice) (Object, *Error)

func (*BSlice) HasPrefix

func (b *BSlice) HasPrefix(obj Object) Object

func (*BSlice) HasSuffix

func (b *BSlice) HasSuffix(obj Object) Object

func (*BSlice) HashKey

func (b *BSlice) HashKey() HashKey

func (*BSlice) Index

func (b *BSlice) Index(obj Object) Object

func (*BSlice) IndexAny

func (b *BSlice) IndexAny(obj Object) Object

func (*BSlice) IndexByte

func (b *BSlice) IndexByte(obj Object) Object

func (*BSlice) IndexRune

func (b *BSlice) IndexRune(obj Object) Object

func (*BSlice) Inspect

func (b *BSlice) Inspect() string

func (*BSlice) Integers

func (b *BSlice) Integers() []Object

func (*BSlice) Interface

func (b *BSlice) Interface() interface{}

func (*BSlice) IsTruthy

func (b *BSlice) IsTruthy() bool

func (*BSlice) Iter

func (b *BSlice) Iter() Iterator

func (*BSlice) Len

func (b *BSlice) Len() *Int

func (*BSlice) Repeat

func (b *BSlice) Repeat(obj Object) Object

func (*BSlice) Replace

func (b *BSlice) Replace(old, new, count Object) Object

func (*BSlice) ReplaceAll

func (b *BSlice) ReplaceAll(old, new Object) Object

func (*BSlice) Reversed

func (b *BSlice) Reversed() *BSlice

func (*BSlice) RunOperation

func (b *BSlice) RunOperation(opType op.BinaryOpType, right Object) Object

func (*BSlice) SetItem

func (b *BSlice) SetItem(key, value Object) *Error

func (*BSlice) String

func (b *BSlice) String() string

func (*BSlice) Type

func (b *BSlice) Type() Type

func (*BSlice) Value

func (b *BSlice) Value() []byte

type BSliceIter

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

func NewBytesIter

func NewBytesIter(b *BSlice) *BSliceIter

func (*BSliceIter) Equals

func (iter *BSliceIter) Equals(other Object) Object

func (*BSliceIter) GetAttr

func (iter *BSliceIter) GetAttr(name string) (Object, bool)

func (*BSliceIter) Inspect

func (iter *BSliceIter) Inspect() string

func (*BSliceIter) Interface

func (iter *BSliceIter) Interface() interface{}

func (*BSliceIter) IsTruthy

func (iter *BSliceIter) IsTruthy() bool

func (*BSliceIter) Next

func (iter *BSliceIter) Next() (IteratorEntry, bool)

func (*BSliceIter) RunOperation

func (iter *BSliceIter) RunOperation(opType op.BinaryOpType, right Object) Object

func (*BSliceIter) String

func (iter *BSliceIter) String() string

func (*BSliceIter) Type

func (iter *BSliceIter) Type() Type

type Bool

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

Bool wraps bool and implements Object and Hashable interface.

func NewBool

func NewBool(value bool) *Bool

func Not

func Not(b *Bool) *Bool

func (*Bool) Compare

func (b *Bool) Compare(other Object) (int, error)

func (*Bool) Equals

func (b *Bool) Equals(other Object) Object

func (*Bool) GetAttr

func (b *Bool) GetAttr(name string) (Object, bool)

func (*Bool) HashKey

func (b *Bool) HashKey() HashKey

func (*Bool) Inspect

func (b *Bool) Inspect() string

func (*Bool) Interface

func (b *Bool) Interface() interface{}

func (*Bool) IsTruthy

func (b *Bool) IsTruthy() bool

func (*Bool) RunOperation

func (b *Bool) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Bool) String

func (b *Bool) String() string

func (*Bool) Type

func (b *Bool) Type() Type

func (*Bool) Value

func (b *Bool) Value() bool

type BooleanConverter

type BooleanConverter struct{}

BooleanConverter converts between bool and Bool.

func (*BooleanConverter) From

func (c *BooleanConverter) From(obj interface{}) (Object, error)

func (*BooleanConverter) To

func (c *BooleanConverter) To(obj Object) (interface{}, error)

func (*BooleanConverter) Type

func (c *BooleanConverter) Type() reflect.Type

type Builtin

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

Builtin wraps func and implements Object interface.

func NewBuiltin

func NewBuiltin(name string, fn BuiltinFunction, module ...*Module) *Builtin

func NewErrorHandler

func NewErrorHandler(name string, fn BuiltinFunction, module ...*Module) *Builtin

func NewNoopBuiltin

func NewNoopBuiltin(name string, module *Module) *Builtin

NewNoopBuiltin creates a builtin function that has no effect.

func (*Builtin) Call

func (b *Builtin) Call(ctx context.Context, args ...Object) Object

func (*Builtin) Equals

func (b *Builtin) Equals(other Object) Object

func (*Builtin) GetAttr

func (b *Builtin) GetAttr(name string) (Object, bool)

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

func (*Builtin) Interface

func (b *Builtin) Interface() interface{}

func (*Builtin) IsErrorHandler

func (b *Builtin) IsErrorHandler() bool

func (*Builtin) IsTruthy

func (b *Builtin) IsTruthy() bool

func (*Builtin) Key

func (b *Builtin) Key() string

Returns a string that uniquely identifies this builtin function.

func (*Builtin) Name

func (b *Builtin) Name() string

func (*Builtin) RunOperation

func (b *Builtin) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Builtin) String

func (b *Builtin) String() string

func (*Builtin) Type

func (b *Builtin) Type() Type

func (*Builtin) Value

func (b *Builtin) Value() BuiltinFunction

type BuiltinFunction

type BuiltinFunction func(ctx context.Context, args ...Object) Object

BuiltinFunction holds the type of a built-in function.

type BytesConverter

type BytesConverter struct{}

BytesConverter converts between []byte and BSlice.

func (*BytesConverter) From

func (c *BytesConverter) From(obj interface{}) (Object, error)

func (*BytesConverter) To

func (c *BytesConverter) To(obj Object) (interface{}, error)

func (*BytesConverter) Type

func (c *BytesConverter) Type() reflect.Type

type CallFunc

type CallFunc func(ctx context.Context, fn *Function, args []Object) (Object, error)

CallFunc is a type signature for a function that can call a Tamarin function.

func GetCallFunc

func GetCallFunc(ctx context.Context) (CallFunc, bool)

GetCallFunc returns the CallFunc from the context, if it exists.

type Cell

type Cell struct {
	*DefaultImpl
	// contains filtered or unexported fields
}

func NewCell

func NewCell(value *Object) *Cell

func (*Cell) Equals

func (c *Cell) Equals(other Object) Object

func (*Cell) Inspect

func (c *Cell) Inspect() string

func (*Cell) Interface

func (c *Cell) Interface() interface{}

func (*Cell) Set

func (c *Cell) Set(value Object)

func (*Cell) String

func (c *Cell) String() string

func (*Cell) Type

func (c *Cell) Type() Type

func (*Cell) Value

func (c *Cell) Value() Object

type Code

type Code struct {
	Name         string
	IsNamed      bool
	Parent       *Code
	Symbols      *SymbolTable
	Instructions []op.Code
	Constants    []Object
	Loops        []*Loop
	Names        []string
	Source       string
	PipeActive   bool
}

func NewCode

func NewCode(name string) *Code

func (*Code) AddName

func (c *Code) AddName(name string) uint16

func (*Code) Builtins

func (c *Code) Builtins() []Object

func (*Code) Globals

func (c *Code) Globals() []Object

func (*Code) SymbolCount

func (c *Code) SymbolCount() uint16

type CodeFunc

type CodeFunc func(ctx context.Context) (*Code, error)

CodeFunc is a type signature for a function that can retrieve the active code.

func GetCodeFunc

func GetCodeFunc(ctx context.Context) (CodeFunc, bool)

GetCodeFunc returns the CodeFunc from the context, if it exists.

type CodeProxy

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

func NewCodeProxy

func NewCodeProxy(c *Code) *CodeProxy

func (*CodeProxy) Equals

func (c *CodeProxy) Equals(other Object) Object

func (*CodeProxy) GetAttr

func (c *CodeProxy) GetAttr(name string) (Object, bool)

func (*CodeProxy) Inspect

func (c *CodeProxy) Inspect() string

func (*CodeProxy) Interface

func (c *CodeProxy) Interface() interface{}

func (*CodeProxy) IsTruthy

func (c *CodeProxy) IsTruthy() bool

func (*CodeProxy) RunOperation

func (c *CodeProxy) RunOperation(opType op.BinaryOpType, right Object) Object

func (*CodeProxy) String

func (c *CodeProxy) String() string

func (*CodeProxy) Type

func (c *CodeProxy) Type() Type

type Color

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

func NewColor

func NewColor(c color.Color) *Color

func (*Color) Compare

func (c *Color) Compare(other Object) (int, error)

func (*Color) Equals

func (c *Color) Equals(other Object) Object

func (*Color) GetAttr

func (c *Color) GetAttr(name string) (Object, bool)

func (*Color) Inspect

func (c *Color) Inspect() string

func (*Color) Interface

func (c *Color) Interface() interface{}

func (*Color) IsTruthy

func (c *Color) IsTruthy() bool

func (*Color) RunOperation

func (c *Color) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Color) String

func (c *Color) String() string

func (*Color) Type

func (c *Color) Type() Type

func (*Color) Value

func (c *Color) Value() color.Color

type Comparable

type Comparable interface {
	Compare(other Object) (int, error)
}

Comparable is an interface used to compare two objects.

-1 if this < other
 0 if this == other
 1 if this > other

type Container

type Container interface {

	// GetItem implements the [key] operator for a container type.
	GetItem(key Object) (Object, *Error)

	// GetSlice implements the [start:stop] operator for a container type.
	GetSlice(s Slice) (Object, *Error)

	// SetItem implements the [key] = value operator for a container type.
	SetItem(key, value Object) *Error

	// DelItem implements the del [key] operator for a container type.
	DelItem(key Object) *Error

	// Contains returns true if the given item is found in this container.
	Contains(item Object) *Bool

	// Len returns the number of items in this container.
	Len() *Int

	// Iter returns an iterator for this container.
	Iter() Iterator
}

type ContextConverter

type ContextConverter struct{}

ContextConverter converts between context.Context and Context.

func (*ContextConverter) From

func (c *ContextConverter) From(obj interface{}) (Object, error)

func (*ContextConverter) To

func (c *ContextConverter) To(obj Object) (interface{}, error)

func (*ContextConverter) Type

func (c *ContextConverter) Type() reflect.Type

type DefaultImpl

type DefaultImpl struct{}

func (*DefaultImpl) Equals

func (d *DefaultImpl) Equals(other Object) Object

func (*DefaultImpl) GetAttr

func (d *DefaultImpl) GetAttr(name string) (Object, bool)

func (*DefaultImpl) Inspect

func (d *DefaultImpl) Inspect() string

func (*DefaultImpl) Interface

func (d *DefaultImpl) Interface() interface{}

func (*DefaultImpl) IsTruthy

func (d *DefaultImpl) IsTruthy() bool

func (*DefaultImpl) RunOperation

func (d *DefaultImpl) RunOperation(opType op.BinaryOpType, right Object) Object

func (*DefaultImpl) Type

func (d *DefaultImpl) Type() Type

type DefaultTypeRegistry

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

DefaultTypeRegistry implements the GoTypeRegistry interface.

func NewTypeRegistry

func NewTypeRegistry(opts ...TypeRegistryOpts) (*DefaultTypeRegistry, error)

NewTypeRegistry creates a GoTypeRegistry that can be used to proxy method calls to various struct types. The provided type conversion functions are used to translate between Go and Tamarin types.

func (*DefaultTypeRegistry) GetAttr

func (p *DefaultTypeRegistry) GetAttr(obj interface{}, name string) (GoAttr, bool)

func (*DefaultTypeRegistry) GetType

func (p *DefaultTypeRegistry) GetType(obj interface{}) (*GoType, bool)

func (*DefaultTypeRegistry) Register

func (p *DefaultTypeRegistry) Register(obj interface{}) (*GoType, error)

type Entry

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

func NewEntry

func NewEntry(key, value Object) *Entry

func (*Entry) Equals

func (e *Entry) Equals(other Object) Object

func (*Entry) GetAttr

func (e *Entry) GetAttr(name string) (Object, bool)

func (*Entry) Inspect

func (e *Entry) Inspect() string

func (*Entry) Interface

func (e *Entry) Interface() interface{}

func (*Entry) IsTruthy

func (e *Entry) IsTruthy() bool

func (*Entry) Key

func (e *Entry) Key() Object

func (*Entry) Primary

func (e *Entry) Primary() Object

func (*Entry) RunOperation

func (e *Entry) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Entry) Type

func (e *Entry) Type() Type

func (*Entry) Value

func (e *Entry) Value() Object

func (*Entry) WithKeyAsPrimary

func (e *Entry) WithKeyAsPrimary() *Entry

func (*Entry) WithValueAsPrimary

func (e *Entry) WithValueAsPrimary() *Entry

type Error

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

Error wraps a Go error interface and implements Object.

func AsBool

func AsBool(obj Object) (bool, *Error)

func AsBytes

func AsBytes(obj Object) ([]byte, *Error)

func AsFloat

func AsFloat(obj Object) (float64, *Error)

func AsInt

func AsInt(obj Object) (int64, *Error)

func AsString

func AsString(obj Object) (string, *Error)

func AsTime

func AsTime(obj Object) (result time.Time, err *Error)

func Errorf

func Errorf(format string, a ...interface{}) *Error

func NewArgsError

func NewArgsError(fn string, takes, given int) *Error

func NewArgsRangeError

func NewArgsRangeError(fn string, takesMin, takesMax, given int) *Error

func NewError

func NewError(err error) *Error

func Sort

func Sort(items []Object) *Error

Sort a list in place. If the list contains a non-comparable object, an error is returned.

func (*Error) Compare

func (e *Error) Compare(other Object) (int, error)

func (*Error) Equals

func (e *Error) Equals(other Object) Object

func (*Error) GetAttr

func (e *Error) GetAttr(name string) (Object, bool)

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Interface

func (e *Error) Interface() interface{}

func (*Error) IsTruthy

func (e *Error) IsTruthy() bool

func (*Error) Message

func (e *Error) Message() *String

func (*Error) RunOperation

func (e *Error) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Error) String

func (e *Error) String() string

func (*Error) Type

func (e *Error) Type() Type

func (*Error) Value

func (e *Error) Value() error

type ErrorConverter

type ErrorConverter struct{}

ErrorConverter converts between error and Error.

func (*ErrorConverter) From

func (c *ErrorConverter) From(obj interface{}) (Object, error)

func (*ErrorConverter) To

func (c *ErrorConverter) To(obj Object) (interface{}, error)

func (*ErrorConverter) Type

func (c *ErrorConverter) Type() reflect.Type

type File

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

func NewFile

func NewFile(ctx context.Context, value *os.File) *File

func (*File) Close

func (f *File) Close() error

func (*File) Compare

func (f *File) Compare(other Object) (int, error)

func (*File) Equals

func (f *File) Equals(other Object) Object

func (*File) GetAttr

func (f *File) GetAttr(name string) (Object, bool)

func (*File) Inspect

func (f *File) Inspect() string

func (*File) Interface

func (f *File) Interface() interface{}

func (*File) IsTruthy

func (f *File) IsTruthy() bool

func (*File) Read

func (f *File) Read(p []byte) (n int, err error)

func (*File) RunOperation

func (f *File) RunOperation(opType op.BinaryOpType, right Object) Object

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

func (*File) String

func (f *File) String() string

func (*File) Type

func (f *File) Type() Type

func (*File) Value

func (f *File) Value() *os.File

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

type Float

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

Float wraps float64 and implements Object and Hashable interfaces.

func NewFloat

func NewFloat(value float64) *Float

func (*Float) Compare

func (f *Float) Compare(other Object) (int, error)

func (*Float) Equals

func (f *Float) Equals(other Object) Object

func (*Float) GetAttr

func (f *Float) GetAttr(name string) (Object, bool)

func (*Float) HashKey

func (f *Float) HashKey() HashKey

func (*Float) Inspect

func (f *Float) Inspect() string

func (*Float) Interface

func (f *Float) Interface() interface{}

func (*Float) IsTruthy

func (f *Float) IsTruthy() bool

func (*Float) RunOperation

func (f *Float) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Float) String

func (f *Float) String() string

func (*Float) Type

func (f *Float) Type() Type

func (*Float) Value

func (f *Float) Value() float64

type Float32Converter

type Float32Converter struct{}

Float32Converter converts between float32 and Float.

func (*Float32Converter) From

func (c *Float32Converter) From(obj interface{}) (Object, error)

func (*Float32Converter) To

func (c *Float32Converter) To(obj Object) (interface{}, error)

func (*Float32Converter) Type

func (c *Float32Converter) Type() reflect.Type

type Float64Converter

type Float64Converter struct{}

Float64Converter converts between float64 and Float.

func (*Float64Converter) From

func (c *Float64Converter) From(obj interface{}) (Object, error)

func (*Float64Converter) To

func (c *Float64Converter) To(obj Object) (interface{}, error)

func (*Float64Converter) Type

func (c *Float64Converter) Type() reflect.Type

type Function

type Function struct {
	*DefaultImpl
	// contains filtered or unexported fields
}

Function is a function that has been compiled to bytecode.

func NewClosure

func NewClosure(
	fn *Function,
	code *Code,
	freeVars []*Cell,
) *Function

func NewFunction

func NewFunction(opts FunctionOpts) *Function

func (*Function) Code

func (f *Function) Code() *Code

func (*Function) Defaults

func (f *Function) Defaults() []Object

func (*Function) FreeVars

func (f *Function) FreeVars() []*Cell

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Instructions

func (f *Function) Instructions() []op.Code

func (*Function) LocalsCount

func (f *Function) LocalsCount() int

func (*Function) Name

func (f *Function) Name() string

func (*Function) Parameters

func (f *Function) Parameters() []string

func (*Function) RequiredArgsCount

func (f *Function) RequiredArgsCount() int

func (*Function) String

func (f *Function) String() string

func (*Function) Type

func (f *Function) Type() Type

type FunctionOpts

type FunctionOpts struct {
	Name           string
	ParameterNames []string
	Defaults       []Object
	Code           *Code
}

type GoAttr

type GoAttr interface {

	// Name of the attribute.
	Name() string

	// Type indicates whether the attribute is a method or a field.
	AttrType() GoAttrType
}

GoAttr is an interface to represent an attribute on a Go type. This could be either a field or a method.

type GoAttrType

type GoAttrType string

GoAttrType is used to indicate whether a GoAttr is a field or a method.

const (
	// GoAttrTypeMethod indicates that the GoAttr is a method.
	GoAttrTypeMethod GoAttrType = "method"

	// GoAttrTypeField indicates that the GoAttr is a field.
	GoAttrTypeField GoAttrType = "field"
)

type GoField

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

GoField represents a single field on a Go type that can be read or written.

func (*GoField) AttrType

func (f *GoField) AttrType() GoAttrType

func (*GoField) Converter

func (f *GoField) Converter() TypeConverter

func (*GoField) Name

func (f *GoField) Name() string

func (*GoField) Tag

func (f *GoField) Tag() reflect.StructTag

func (*GoField) Type

func (f *GoField) Type() reflect.Type

type GoMethod

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

GoMethod represents a single method on a Go type that can be proxied.

func (*GoMethod) AttrType

func (m *GoMethod) AttrType() GoAttrType

func (*GoMethod) Name

func (m *GoMethod) Name() string

type GoType

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

GoType represents a single Go type whose methods and fields can be proxied.

func (*GoType) AttrByName

func (gt *GoType) AttrByName(name string) (GoAttr, bool)

func (*GoType) Attrs

func (gt *GoType) Attrs() []GoAttr

func (*GoType) FieldByName

func (gt *GoType) FieldByName(name string) (*GoField, bool)

func (*GoType) Fields

func (gt *GoType) Fields() []*GoField

func (*GoType) MethodByName

func (gt *GoType) MethodByName(name string) (*GoMethod, bool)

func (*GoType) Methods

func (gt *GoType) Methods() []*GoMethod

func (*GoType) Name

func (gt *GoType) Name() string

func (*GoType) StructType

func (gt *GoType) StructType() reflect.Type

func (*GoType) Type

func (gt *GoType) Type() reflect.Type

type GoTypeRegistry

type GoTypeRegistry interface {

	// Register determines type and method information for the provided
	// object and saves that information for use in later method call proxying.
	Register(obj interface{}) (*GoType, error)

	// GetType returns the GoType for the given object and a boolean that
	// indicates whether the type was found. Only types that were previously
	// registered will be found.
	GetType(obj interface{}) (*GoType, bool)

	// GetAttr returns the GoAttr for the given object and name.
	GetAttr(obj interface{}, name string) (GoAttr, bool)
}

GoTypeRegistry is an interface that defines a way to register Go types and call methods on instances of those types.

type HashKey

type HashKey struct {
	// Type of the object being referenced.
	Type Type
	// FltValue is used as the key for floats.
	FltValue float64
	// IntValue is used as the key for integers.
	IntValue int64
	// StrValue is used as the key for strings.
	StrValue string
}

HashKey is used to identify unique values in a set.

type Hashable

type Hashable interface {

	// Hash returns a hash key for the given object.
	HashKey() HashKey
}

Hashable types can be hashed and consequently used in a set.

type HttpResponse

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

func NewHttpResponse

func NewHttpResponse(
	resp *http.Response,
	timeout time.Duration,
	limits *limits.Limits,
) *HttpResponse

func (*HttpResponse) Close

func (r *HttpResponse) Close()

func (*HttpResponse) ContentLength

func (r *HttpResponse) ContentLength() *Int

func (*HttpResponse) Equals

func (r *HttpResponse) Equals(other Object) Object

func (*HttpResponse) GetAttr

func (r *HttpResponse) GetAttr(name string) (Object, bool)

func (*HttpResponse) Header

func (r *HttpResponse) Header() *Map

func (*HttpResponse) Inspect

func (r *HttpResponse) Inspect() string

func (*HttpResponse) Interface

func (r *HttpResponse) Interface() interface{}

func (*HttpResponse) IsTruthy

func (r *HttpResponse) IsTruthy() bool

func (*HttpResponse) JSON

func (r *HttpResponse) JSON() Object

func (*HttpResponse) Proto

func (r *HttpResponse) Proto() *String

func (*HttpResponse) RunOperation

func (r *HttpResponse) RunOperation(opType op.BinaryOpType, right Object) Object

func (*HttpResponse) Status

func (r *HttpResponse) Status() *String

func (*HttpResponse) StatusCode

func (r *HttpResponse) StatusCode() *Int

func (*HttpResponse) Text

func (r *HttpResponse) Text() Object

func (*HttpResponse) Type

func (r *HttpResponse) Type() Type

type Image

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

func NewImage

func NewImage(image image.Image) *Image

func (*Image) Bounds

func (img *Image) Bounds() Object

func (*Image) Compare

func (img *Image) Compare(other Object) (int, error)

func (*Image) Equals

func (img *Image) Equals(other Object) Object

func (*Image) GetAttr

func (img *Image) GetAttr(name string) (Object, bool)

func (*Image) Inspect

func (img *Image) Inspect() string

func (*Image) Interface

func (img *Image) Interface() interface{}

func (*Image) IsTruthy

func (img *Image) IsTruthy() bool

func (*Image) RunOperation

func (img *Image) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Image) String

func (img *Image) String() string

func (*Image) Type

func (img *Image) Type() Type

func (*Image) Value

func (img *Image) Value() image.Image

type Int

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

Int wraps int64 and implements Object and Hashable interfaces.

func NewInt

func NewInt(value int64) *Int

func (*Int) Compare

func (i *Int) Compare(other Object) (int, error)

func (*Int) Equals

func (i *Int) Equals(other Object) Object

func (*Int) GetAttr

func (i *Int) GetAttr(name string) (Object, bool)

func (*Int) HashKey

func (i *Int) HashKey() HashKey

func (*Int) Inspect

func (i *Int) Inspect() string

func (*Int) Interface

func (i *Int) Interface() interface{}

func (*Int) IsTruthy

func (i *Int) IsTruthy() bool

func (*Int) RunOperation

func (i *Int) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Int) String

func (i *Int) String() string

func (*Int) Type

func (i *Int) Type() Type

func (*Int) Value

func (i *Int) Value() int64

type Int64Converter

type Int64Converter struct{}

Int64Converter converts between int64 and Integer.

func (*Int64Converter) From

func (c *Int64Converter) From(obj interface{}) (Object, error)

func (*Int64Converter) To

func (c *Int64Converter) To(obj Object) (interface{}, error)

func (*Int64Converter) Type

func (c *Int64Converter) Type() reflect.Type

type IntConverter

type IntConverter struct{}

IntConverter converts between int and Integer.

func (*IntConverter) From

func (c *IntConverter) From(obj interface{}) (Object, error)

func (*IntConverter) To

func (c *IntConverter) To(obj Object) (interface{}, error)

func (*IntConverter) Type

func (c *IntConverter) Type() reflect.Type

type Iterator

type Iterator interface {
	Object

	// Next returns the next item in the iterator and a bool indicating whether
	// the returned item is valid. If the iteration is complete, (nil, false) is
	// returned.
	Next() (IteratorEntry, bool)
}

Iterator is an interface used to iterate over a container.

type IteratorEntry

type IteratorEntry interface {
	Object
	Key() Object
	Value() Object
	Primary() Object
}

IteratorEntry is a single item returned by an iterator.

type List

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

List of objects

func NewList

func NewList(items []Object) *List

func NewStringList

func NewStringList(s []string) *List

func (*List) Append

func (ls *List) Append(obj Object)

Append adds an item at the end of the list.

func (*List) Clear

func (ls *List) Clear()

Clear removes all the items from the list.

func (*List) Compare

func (ls *List) Compare(other Object) (int, error)

func (*List) Contains

func (ls *List) Contains(item Object) *Bool

Contains returns true if the given item is found in this container.

func (*List) Copy

func (ls *List) Copy() *List

Copy returns a shallow copy of the list.

func (*List) Count

func (ls *List) Count(obj Object) int64

Count returns the number of items with the specified value.

func (*List) DelItem

func (ls *List) DelItem(key Object) *Error

DelItem implements the del [key] operator for a container type.

func (*List) Each

func (ls *List) Each(ctx context.Context, fn Object) Object

func (*List) Equals

func (ls *List) Equals(other Object) Object

func (*List) Extend

func (ls *List) Extend(other *List)

Extend adds the items of a list to the end of the current list.

func (*List) Filter

func (ls *List) Filter(ctx context.Context, fn Object) Object

func (*List) GetAttr

func (ls *List) GetAttr(name string) (Object, bool)

func (*List) GetItem

func (ls *List) GetItem(key Object) (Object, *Error)

func (*List) GetSlice

func (ls *List) GetSlice(s Slice) (Object, *Error)

GetSlice implements the [start:stop] operator for a container type.

func (*List) Index

func (ls *List) Index(obj Object) int64

Index returns the index of the first item with the specified value.

func (*List) Insert

func (ls *List) Insert(index int64, obj Object)

Insert adds an item at the specified position.

func (*List) Inspect

func (ls *List) Inspect() string

func (*List) Interface

func (ls *List) Interface() interface{}

func (*List) IsTruthy

func (ls *List) IsTruthy() bool

func (*List) Iter

func (ls *List) Iter() Iterator

func (*List) Keys

func (ls *List) Keys() Object

func (*List) Len

func (ls *List) Len() *Int

Len returns the number of items in this container.

func (*List) Map

func (ls *List) Map(ctx context.Context, fn Object) Object

func (*List) Pop

func (ls *List) Pop(index int64) Object

Pop removes the item at the specified position.

func (*List) Remove

func (ls *List) Remove(obj Object)

Remove removes the first item with the specified value.

func (*List) Reverse

func (ls *List) Reverse()

Reverse reverses the order of the list.

func (*List) Reversed

func (ls *List) Reversed() *List

func (*List) RunOperation

func (ls *List) RunOperation(opType op.BinaryOpType, right Object) Object

func (*List) SetItem

func (ls *List) SetItem(key, value Object) *Error

SetItem implements the [key] = value operator for a container type.

func (*List) String

func (ls *List) String() string

func (*List) Type

func (ls *List) Type() Type

func (*List) Value

func (ls *List) Value() []Object

type ListIter

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

func NewListIter

func NewListIter(l *List) *ListIter

func (*ListIter) Equals

func (iter *ListIter) Equals(other Object) Object

func (*ListIter) GetAttr

func (iter *ListIter) GetAttr(name string) (Object, bool)

func (*ListIter) Inspect

func (iter *ListIter) Inspect() string

func (*ListIter) Interface

func (iter *ListIter) Interface() interface{}

func (*ListIter) IsTruthy

func (iter *ListIter) IsTruthy() bool

func (*ListIter) Next

func (iter *ListIter) Next() (IteratorEntry, bool)

func (*ListIter) RunOperation

func (iter *ListIter) RunOperation(opType op.BinaryOpType, right Object) Object

func (*ListIter) String

func (iter *ListIter) String() string

func (*ListIter) Type

func (iter *ListIter) Type() Type

type Loop

type Loop struct {
	ContinuePos []int
	BreakPos    []int
}

type Map

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

func NewMap

func NewMap(m map[string]Object) *Map

func NewMapFromGo

func NewMapFromGo(m map[string]interface{}) *Map

func (*Map) Clear

func (m *Map) Clear()

func (*Map) Contains

func (m *Map) Contains(key Object) *Bool

Contains returns true if the given item is found in this container.

func (*Map) Copy

func (m *Map) Copy() *Map

func (*Map) DelItem

func (m *Map) DelItem(key Object) *Error

DelItem deletes the item with the given key from the map.

func (*Map) Delete

func (m *Map) Delete(key string) Object

func (*Map) Equals

func (m *Map) Equals(other Object) Object

func (*Map) Get

func (m *Map) Get(key string) Object

func (*Map) GetAttr

func (m *Map) GetAttr(name string) (Object, bool)

func (*Map) GetItem

func (m *Map) GetItem(key Object) (Object, *Error)

func (*Map) GetSlice

func (m *Map) GetSlice(s Slice) (Object, *Error)

GetSlice implements the [start:stop] operator for a container type.

func (*Map) GetWithDefault

func (m *Map) GetWithDefault(key string, defaultValue Object) Object

func (*Map) GetWithObject

func (m *Map) GetWithObject(key *String) Object

func (*Map) Inspect

func (m *Map) Inspect() string

func (*Map) Interface

func (m *Map) Interface() interface{}

func (*Map) IsTruthy

func (m *Map) IsTruthy() bool

func (*Map) Iter

func (m *Map) Iter() Iterator

func (*Map) Keys

func (m *Map) Keys() *List

func (*Map) Len

func (m *Map) Len() *Int

Len returns the number of items in this container.

func (*Map) ListItems

func (m *Map) ListItems() *List

func (*Map) Pop

func (m *Map) Pop(key string, def Object) Object

func (*Map) RunOperation

func (m *Map) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Map) Set

func (m *Map) Set(key string, value Object)

func (*Map) SetDefault

func (m *Map) SetDefault(key string, value Object) Object

func (*Map) SetItem

func (m *Map) SetItem(key, value Object) *Error

SetItem assigns a value to the given key in the map.

func (*Map) Size

func (m *Map) Size() int

func (*Map) SortedKeys

func (m *Map) SortedKeys() []string

func (*Map) String

func (m *Map) String() string

func (*Map) StringKeys

func (m *Map) StringKeys() []string

func (*Map) Type

func (m *Map) Type() Type

func (*Map) Update

func (m *Map) Update(other *Map)

func (*Map) Value

func (m *Map) Value() map[string]Object

func (*Map) Values

func (m *Map) Values() *List

type MapIter

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

func NewMapIter

func NewMapIter(m *Map) *MapIter

func (*MapIter) Equals

func (iter *MapIter) Equals(other Object) Object

func (*MapIter) GetAttr

func (iter *MapIter) GetAttr(name string) (Object, bool)

func (*MapIter) Inspect

func (iter *MapIter) Inspect() string

func (*MapIter) Interface

func (iter *MapIter) Interface() interface{}

func (*MapIter) IsTruthy

func (iter *MapIter) IsTruthy() bool

func (*MapIter) Next

func (iter *MapIter) Next() (IteratorEntry, bool)

func (*MapIter) RunOperation

func (iter *MapIter) RunOperation(opType op.BinaryOpType, right Object) Object

func (*MapIter) String

func (iter *MapIter) String() string

func (*MapIter) Type

func (iter *MapIter) Type() Type

type MapStringIfaceConverter

type MapStringIfaceConverter struct{}

MapStringIfaceConverter converts between map[string]interface{} and Hash.

func (*MapStringIfaceConverter) From

func (c *MapStringIfaceConverter) From(obj interface{}) (Object, error)

func (*MapStringIfaceConverter) To

func (c *MapStringIfaceConverter) To(obj Object) (interface{}, error)

func (*MapStringIfaceConverter) Type

type Module

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

func NewBuiltinsModule

func NewBuiltinsModule(name string, contents map[string]Object) *Module

func NewModule

func NewModule(name string, code *Code) *Module

func (*Module) Code

func (m *Module) Code() *Code

func (*Module) Compare

func (m *Module) Compare(other Object) (int, error)

func (*Module) Equals

func (m *Module) Equals(other Object) Object

func (*Module) GetAttr

func (m *Module) GetAttr(name string) (Object, bool)

func (*Module) Inspect

func (m *Module) Inspect() string

func (*Module) Interface

func (m *Module) Interface() interface{}

func (*Module) IsTruthy

func (m *Module) IsTruthy() bool

func (*Module) Name

func (m *Module) Name() *String

func (*Module) RunOperation

func (m *Module) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Module) String

func (m *Module) String() string

func (*Module) Type

func (m *Module) Type() Type

type NilType

type NilType struct{}

func (*NilType) Compare

func (n *NilType) Compare(other Object) (int, error)

func (*NilType) Equals

func (n *NilType) Equals(other Object) Object

func (*NilType) GetAttr

func (n *NilType) GetAttr(name string) (Object, bool)

func (*NilType) HashKey

func (n *NilType) HashKey() HashKey

func (*NilType) Inspect

func (n *NilType) Inspect() string

func (*NilType) Interface

func (n *NilType) Interface() interface{}

func (*NilType) IsTruthy

func (n *NilType) IsTruthy() bool

func (*NilType) RunOperation

func (n *NilType) RunOperation(opType op.BinaryOpType, right Object) Object

func (*NilType) String

func (n *NilType) String() string

func (*NilType) Type

func (n *NilType) Type() Type

type Object

type Object interface {

	// Type of the object.
	Type() Type

	// Inspect returns a string representation of the given object.
	Inspect() string

	// Interface converts the given object to a native Go value.
	Interface() interface{}

	// Returns True if the given object is equal to this object.
	Equals(other Object) Object

	// GetAttr returns the attribute with the given name from this object.
	GetAttr(name string) (Object, bool)

	// IsTruthy returns true if the object is considered "truthy".
	IsTruthy() bool

	// RunOperation runs an operation on this object with the given
	// right-hand side object.
	RunOperation(opType op.BinaryOpType, right Object) Object
}

Object is the interface that all object types in Tamarin must implement.

func BinaryOp

func BinaryOp(opType op.BinaryOpType, a, b Object) Object

BinaryOp performs a binary operation on two objects, given an operator.

func Compare

func Compare(opType op.CompareOpType, a, b Object) Object

Compare two objects using the given comparison operator. An Error object is returned if either of the objects is not comparable.

func FromGoType

func FromGoType(obj interface{}) Object

func NewSet

func NewSet(items []Object) Object

type Partial

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

Partial is a partially applied function

func NewPartial

func NewPartial(fn Object, args []Object) *Partial

func (*Partial) Args

func (f *Partial) Args() []Object

func (*Partial) Equals

func (f *Partial) Equals(other Object) Object

func (*Partial) Function

func (f *Partial) Function() Object

func (*Partial) GetAttr

func (f *Partial) GetAttr(name string) (Object, bool)

func (*Partial) Inspect

func (f *Partial) Inspect() string

func (*Partial) Interface

func (f *Partial) Interface() interface{}

func (*Partial) IsTruthy

func (f *Partial) IsTruthy() bool

func (*Partial) RunOperation

func (f *Partial) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Partial) Type

func (f *Partial) Type() Type

type Proxy

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

Proxy is a Tamarin type that proxies method calls to a wrapped Go struct. Only the public methods of the Go type are proxied.

func NewProxy

func NewProxy(reg GoTypeRegistry, obj interface{}) (*Proxy, error)

NewProxy returns a new Tamarin proxy object that wraps the given Go object. The Go type is registered with the type registry, which has no effect if the type is already registered. This operation may fail if the Go type has attributes whose types cannot be converted to Tamarin types.

func (*Proxy) Equals

func (p *Proxy) Equals(other Object) Object

func (*Proxy) GetAttr

func (p *Proxy) GetAttr(name string) (Object, bool)

func (*Proxy) Inspect

func (p *Proxy) Inspect() string

func (*Proxy) Interface

func (p *Proxy) Interface() interface{}

func (*Proxy) IsTruthy

func (p *Proxy) IsTruthy() bool

func (*Proxy) RunOperation

func (p *Proxy) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Proxy) String

func (p *Proxy) String() string

func (*Proxy) Type

func (p *Proxy) Type() Type

type Resolution

type Resolution struct {
	Symbol    *Symbol
	Scope     ScopeName
	Depth     int
	FreeIndex int
}

func (*Resolution) String

func (r *Resolution) String() string

type Result

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

Result contains one of: an "ok" value or an "err" value

func NewErrResult

func NewErrResult(err *Error) *Result

func NewOkResult

func NewOkResult(ok Object) *Result

func (*Result) Equals

func (rv *Result) Equals(other Object) Object

func (*Result) ErrMsg

func (rv *Result) ErrMsg() *String

func (*Result) Expect

func (rv *Result) Expect(other Object) Object

func (*Result) GetAttr

func (rv *Result) GetAttr(name string) (Object, bool)

func (*Result) Inspect

func (rv *Result) Inspect() string

func (*Result) Interface

func (rv *Result) Interface() interface{}

func (*Result) IsErr

func (rv *Result) IsErr() bool

func (*Result) IsOk

func (rv *Result) IsOk() bool

func (*Result) IsTruthy

func (rv *Result) IsTruthy() bool

func (*Result) RunOperation

func (rv *Result) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Result) String

func (rv *Result) String() string

func (*Result) Type

func (rv *Result) Type() Type

func (*Result) Unwrap

func (rv *Result) Unwrap() Object

func (*Result) UnwrapErr

func (rv *Result) UnwrapErr() *Error

func (*Result) UnwrapOr

func (rv *Result) UnwrapOr(other Object) Object

type ScopeName

type ScopeName string
const (
	ScopeBuiltin ScopeName = "builtin"
	ScopeLocal   ScopeName = "local"
	ScopeGlobal  ScopeName = "global"
	ScopeFree    ScopeName = "free"
)

type Set

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

func NewSetWithSize

func NewSetWithSize(size int) *Set

func (*Set) Add

func (s *Set) Add(items ...Object) Object

func (*Set) Clear

func (s *Set) Clear()

func (*Set) Contains

func (s *Set) Contains(key Object) *Bool

Contains returns true if the given item is found in this container.

func (*Set) DelItem

func (s *Set) DelItem(key Object) *Error

DelItem deletes the item with the given key from the map.

func (*Set) Difference

func (s *Set) Difference(other *Set) *Set

Difference returns a new set that is the difference of the two sets.

func (*Set) Equals

func (s *Set) Equals(other Object) Object

func (*Set) GetAttr

func (s *Set) GetAttr(name string) (Object, bool)

func (*Set) GetItem

func (s *Set) GetItem(key Object) (Object, *Error)

func (*Set) GetSlice

func (s *Set) GetSlice(slice Slice) (Object, *Error)

GetSlice implements the [start:stop] operator for a container type.

func (*Set) Inspect

func (s *Set) Inspect() string

func (*Set) Interface

func (s *Set) Interface() interface{}

func (*Set) Intersection

func (s *Set) Intersection(other *Set) *Set

Intersection returns a new set that is the intersection of the two sets.

func (*Set) IsTruthy

func (s *Set) IsTruthy() bool

func (*Set) Iter

func (s *Set) Iter() Iterator

func (*Set) Keys

func (s *Set) Keys() []HashKey

func (*Set) Len

func (s *Set) Len() *Int

Len returns the number of items in this container.

func (*Set) List

func (s *Set) List() *List

func (*Set) Remove

func (s *Set) Remove(items ...Object) Object

func (*Set) RunOperation

func (s *Set) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Set) SetItem

func (s *Set) SetItem(key, value Object) *Error

SetItem assigns a value to the given key in the map.

func (*Set) Size

func (s *Set) Size() int

func (*Set) SortedItems

func (s *Set) SortedItems() []Object

func (*Set) String

func (s *Set) String() string

func (*Set) Type

func (s *Set) Type() Type

func (*Set) Union

func (s *Set) Union(other *Set) *Set

Union returns a new set that is the union of the two sets.

func (*Set) Value

func (s *Set) Value() map[HashKey]Object

type SetIter

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

func NewSetIter

func NewSetIter(set *Set) *SetIter

func (*SetIter) Equals

func (iter *SetIter) Equals(other Object) Object

func (*SetIter) GetAttr

func (iter *SetIter) GetAttr(name string) (Object, bool)

func (*SetIter) Inspect

func (iter *SetIter) Inspect() string

func (*SetIter) Interface

func (iter *SetIter) Interface() interface{}

func (*SetIter) IsTruthy

func (iter *SetIter) IsTruthy() bool

func (*SetIter) Next

func (iter *SetIter) Next() (IteratorEntry, bool)

func (*SetIter) RunOperation

func (iter *SetIter) RunOperation(opType op.BinaryOpType, right Object) Object

func (*SetIter) String

func (iter *SetIter) String() string

func (*SetIter) Type

func (iter *SetIter) Type() Type

type Slice

type Slice struct {
	Start Object
	Stop  Object
}

Slice is used to specify a range or slice of items in a container.

type String

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

func NewString

func NewString(s string) *String

func (*String) Compare

func (s *String) Compare(other Object) (int, error)

func (*String) Contains

func (s *String) Contains(obj Object) *Bool

func (*String) Count

func (s *String) Count(obj Object) Object

func (*String) DelItem

func (s *String) DelItem(key Object) *Error

func (*String) Equals

func (s *String) Equals(other Object) Object

func (*String) Fields

func (s *String) Fields() Object

func (*String) GetAttr

func (s *String) GetAttr(name string) (Object, bool)

func (*String) GetItem

func (s *String) GetItem(key Object) (Object, *Error)

func (*String) GetSlice

func (s *String) GetSlice(slice Slice) (Object, *Error)

func (*String) HasPrefix

func (s *String) HasPrefix(obj Object) Object

func (*String) HasSuffix

func (s *String) HasSuffix(obj Object) Object

func (*String) HashKey

func (s *String) HashKey() HashKey

func (*String) Index

func (s *String) Index(obj Object) Object

func (*String) Inspect

func (s *String) Inspect() string

func (*String) Interface

func (s *String) Interface() interface{}

func (*String) IsTruthy

func (s *String) IsTruthy() bool

func (*String) Iter

func (s *String) Iter() Iterator

func (*String) Join

func (s *String) Join(obj Object) Object

func (*String) LastIndex

func (s *String) LastIndex(obj Object) Object

func (*String) Len

func (s *String) Len() *Int

func (*String) ReplaceAll

func (s *String) ReplaceAll(old, new Object) Object

func (*String) Reversed

func (s *String) Reversed() *String

func (*String) RunOperation

func (s *String) RunOperation(opType op.BinaryOpType, right Object) Object

func (*String) Runes

func (s *String) Runes() []Object

func (*String) SetItem

func (s *String) SetItem(key, value Object) *Error

func (*String) Split

func (s *String) Split(obj Object) Object

func (*String) String

func (s *String) String() string

func (*String) ToLower

func (s *String) ToLower() Object

func (*String) ToUpper

func (s *String) ToUpper() Object

func (*String) Trim

func (s *String) Trim(obj Object) Object

func (*String) TrimPrefix

func (s *String) TrimPrefix(obj Object) Object

func (*String) TrimSpace

func (s *String) TrimSpace() Object

func (*String) TrimSuffix

func (s *String) TrimSuffix(obj Object) Object

func (*String) Type

func (s *String) Type() Type

func (*String) Value

func (s *String) Value() string

type StringConverter

type StringConverter struct{}

StringConverter converts between string and String.

func (*StringConverter) From

func (c *StringConverter) From(obj interface{}) (Object, error)

func (*StringConverter) To

func (c *StringConverter) To(obj Object) (interface{}, error)

func (*StringConverter) Type

func (c *StringConverter) Type() reflect.Type

type StringIter

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

func NewStringIter

func NewStringIter(s *String) *StringIter

func (*StringIter) Equals

func (iter *StringIter) Equals(other Object) Object

func (*StringIter) GetAttr

func (iter *StringIter) GetAttr(name string) (Object, bool)

func (*StringIter) Inspect

func (iter *StringIter) Inspect() string

func (*StringIter) Interface

func (iter *StringIter) Interface() interface{}

func (*StringIter) IsTruthy

func (iter *StringIter) IsTruthy() bool

func (*StringIter) Next

func (iter *StringIter) Next() (IteratorEntry, bool)

func (*StringIter) RunOperation

func (iter *StringIter) RunOperation(opType op.BinaryOpType, right Object) Object

func (*StringIter) String

func (iter *StringIter) String() string

func (*StringIter) Type

func (iter *StringIter) Type() Type

type StructConverter

type StructConverter struct {
	Prototype interface{}
	AsPointer bool
}

StructConverter converts between a struct and a Map via JSON marshaling.

func (*StructConverter) From

func (c *StructConverter) From(obj interface{}) (Object, error)

func (*StructConverter) To

func (c *StructConverter) To(obj Object) (interface{}, error)

func (*StructConverter) Type

func (c *StructConverter) Type() reflect.Type

type Symbol

type Symbol struct {
	Name       string
	Index      uint16
	Value      Object
	IsConstant bool
}

type SymbolTable

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

func NewSymbolTable

func NewSymbolTable() *SymbolTable

func (*SymbolTable) AccessedNames

func (t *SymbolTable) AccessedNames() []string

func (*SymbolTable) Builtins

func (t *SymbolTable) Builtins() []Object

func (*SymbolTable) Free

func (t *SymbolTable) Free() []*Resolution

func (*SymbolTable) Get

func (t *SymbolTable) Get(name string) (*Symbol, bool)

func (*SymbolTable) InsertBuiltin

func (t *SymbolTable) InsertBuiltin(name string, value ...Object) (*Symbol, error)

func (*SymbolTable) InsertConstant

func (t *SymbolTable) InsertConstant(name string, value ...Object) (*Symbol, error)

func (*SymbolTable) InsertVariable

func (t *SymbolTable) InsertVariable(name string, value ...Object) (*Symbol, error)

func (*SymbolTable) InsertedNames

func (t *SymbolTable) InsertedNames() []string

func (*SymbolTable) IsBuiltin

func (t *SymbolTable) IsBuiltin(name string) bool

func (*SymbolTable) IsGlobal

func (t *SymbolTable) IsGlobal() bool

func (*SymbolTable) IsVariable

func (t *SymbolTable) IsVariable(name string) bool

func (*SymbolTable) LocalTable

func (t *SymbolTable) LocalTable() *SymbolTable

func (*SymbolTable) Lookup

func (t *SymbolTable) Lookup(name string) (*Resolution, bool)

func (*SymbolTable) NewBlock

func (t *SymbolTable) NewBlock() *SymbolTable

func (*SymbolTable) NewChild

func (t *SymbolTable) NewChild() *SymbolTable

func (*SymbolTable) Parent

func (t *SymbolTable) Parent() *SymbolTable

func (*SymbolTable) Root

func (t *SymbolTable) Root() *SymbolTable

func (*SymbolTable) SetValue

func (t *SymbolTable) SetValue(name string, value Object) error

func (*SymbolTable) Size

func (t *SymbolTable) Size() uint16

func (*SymbolTable) Variables

func (t *SymbolTable) Variables() []Object

type Time

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

func NewTime

func NewTime(t time.Time) *Time

func (*Time) After

func (t *Time) After(ctx context.Context, args ...Object) Object

func (*Time) Before

func (t *Time) Before(ctx context.Context, args ...Object) Object

func (*Time) Compare

func (t *Time) Compare(other Object) (int, error)

func (*Time) Equals

func (t *Time) Equals(other Object) Object

func (*Time) Format

func (t *Time) Format(ctx context.Context, args ...Object) Object

func (*Time) GetAttr

func (t *Time) GetAttr(name string) (Object, bool)

func (*Time) Inspect

func (t *Time) Inspect() string

func (*Time) Interface

func (t *Time) Interface() interface{}

func (*Time) IsTruthy

func (t *Time) IsTruthy() bool

func (*Time) RunOperation

func (t *Time) RunOperation(opType op.BinaryOpType, right Object) Object

func (*Time) String

func (t *Time) String() string

func (*Time) Type

func (t *Time) Type() Type

func (*Time) UTC

func (t *Time) UTC(ctx context.Context, args ...Object) Object

func (*Time) Unix

func (t *Time) Unix(ctx context.Context, args ...Object) Object

func (*Time) Value

func (t *Time) Value() time.Time

type TimeConverter

type TimeConverter struct{}

TimeConverter converts between time.Time and Time.

func (*TimeConverter) From

func (c *TimeConverter) From(obj interface{}) (Object, error)

func (*TimeConverter) To

func (c *TimeConverter) To(obj Object) (interface{}, error)

func (*TimeConverter) Type

func (c *TimeConverter) Type() reflect.Type

type Type

type Type string

Type of an object as a string.

const (
	BOOL          Type = "bool"
	BUILTIN       Type = "builtin"
	BSLICE        Type = "bslice"
	BSLICE_ITER   Type = "bslice_iter"
	CELL          Type = "cell"
	CODE          Type = "code"
	COLOR         Type = "color"
	ERROR         Type = "error"
	FILE          Type = "file"
	FLOAT         Type = "float"
	FUNCTION      Type = "function"
	HTTP_RESPONSE Type = "http_response"
	IMAGE         Type = "image"
	INT           Type = "int"
	ITER_ENTRY    Type = "iter_entry"
	LIST          Type = "list"
	LIST_ITER     Type = "list_iter"
	MAP           Type = "map"
	MAP_ITER      Type = "map_iter"
	MODULE        Type = "module"
	NIL           Type = "nil"
	PARTIAL       Type = "partial"
	PROXY         Type = "proxy"
	REGEXP        Type = "regexp"
	RESULT        Type = "result"
	SET           Type = "set"
	SET_ITER      Type = "set_iter"
	STRING        Type = "string"
	STRING_ITER   Type = "string_iter"
	TIME          Type = "time"
)

Type constants

type TypeConverter

type TypeConverter interface {

	// To converts a Tamarin object to a Go object.
	To(Object) (interface{}, error)

	// From converts a Go object to a Tamarin object.
	From(interface{}) (Object, error)

	// Type that this TypeConverter is responsible for.
	Type() reflect.Type
}

TypeConverter is an interface used to convert between Go and Tamarin objects for a single Go type. There may be a way to use generics here...

type TypeRegistryOpts

type TypeRegistryOpts struct {
	// Converters is a list of TypeConverters that will be used to convert
	// input and output types for method calls.
	Converters []TypeConverter

	// NoDefaults indicates that the default TypeConverters should not be
	// automatically used by the registry. If this is set, the caller should
	// provide their own TypeConverters.
	NoDefaults bool
}

TypeRegistryOpts contains options used to create a GoTypeRegistry.

Jump to

Keyboard shortcuts

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