object

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StrFileName is a dummy file name for str literal, which is used for stacktraces.
	StrFileName = "<string>"
	// StdinFileName is a dummy file name for stdin, which is used for stacktraces.
	StdinFileName = "<stdin>"

	// SourcePathVar is a variable name which contains source file path str.
	SourcePathVar = "_PANGAEA_SOURCE_PATH"
)
View Source
const (
	Err             = "Err"
	AssertionErr    = "AssertionErr"
	FileNotFoundErr = "FileNotFoundErr"
	NameErr         = "NameErr"
	NoPropErr       = "NoPropErr"
	NotImplementErr = "NotImplementedErr"
	StopIterErr     = "StopIterErr"
	SyntaxErr       = "SyntaxErr"
	TypeErr         = "TypeErr"
	ValueErr        = "ValueErr"
	ZeroDivisionErr = "ZeroDivisionErr"
)

nolint: comment

View Source
const ArrType = "ArrType"

ArrType is a type of PanArr.

View Source
const BoolType = "BoolType"

BoolType is a type of PanBool.

View Source
const BuiltInIterType = "BuiltInIterType"

BuiltInIterType is a type of PanBuiltInIter.

View Source
const BuiltInType = "BuiltInType"

BuiltInType is a type of PanBuiltIn.

View Source
const DeferType = "DeferType"

DeferType is a type of DeferObj.

View Source
const ErrType = "ErrType"

ErrType is a type of PanErr.

View Source
const ErrWrapperType = "ErrWrapperType"

ErrWrapperType is a type of PanErrWrapper.

View Source
const FloatType = "FloatType"

FloatType is a type of PanFloat.

View Source
const FuncType = "FuncType"

FuncType is a type of PanFunc.

View Source
const IOType = "IOType"

IOType is a type of PanIO.

View Source
const IntType = "IntType"

IntType is a type of PanInt.

View Source
const MapType = "MapType"

MapType is a type of PanMap.

View Source
const MatchType = "MatchType"

MatchType is a type of PanMatch.

View Source
const NilType = "NilType"

NilType is a type of PanNil.

View Source
const ObjType = "ObjType"

ObjType is a type of PanObj.

View Source
const RangeType = "RangeType"

RangeType is a type of PanRange.

View Source
const ReturnType = "ReturnType"

ReturnType is a type of ReturnObj.

View Source
const StrType = "StrType"

StrType is a type of PanStr.

View Source
const YieldType = "YieldType"

YieldType is a type of YieldObj.

Variables

View Source
var BuiltInArrObj = &PanObj{}

BuiltInArrObj is an object of Arr (proto of each arr).

View Source
var BuiltInAssertionErr = &PanObj{}

BuiltInAssertionErr is an object of AssertionErr (proto of each assertionErr).

View Source
var BuiltInBaseObj = &PanObj{}

BuiltInBaseObj is an object of BaseObj (ancestor of all objects).

View Source
var BuiltInComparableObj = &PanObj{}

BuiltInComparableObj is an object of Comparable, which is mixed-in comparable objects.

View Source
var BuiltInDiamondObj = &PanObj{}

BuiltInDiamondObj is an object of Diamond.

View Source
var BuiltInEitherErrObj = &PanObj{}

BuiltInEitherErrObj is an object of EitherErr.

View Source
var BuiltInEitherObj = &PanObj{}

BuiltInEitherObj is an object of Either.

View Source
var BuiltInEitherValObj = &PanObj{}

BuiltInEitherValObj is an object of EitherVal.

View Source
var BuiltInErrObj = &PanObj{}

BuiltInErrObj is an object of Err (proto of all specific err types).

View Source
var BuiltInFalse = &PanBool{false}

BuiltInFalse is a bool object `false`.

View Source
var BuiltInFileNotFoundErr = &PanObj{}

BuiltInFileNotFoundErr is an object of FileNotFoundErr (proto of each fileNotFoundErr).

View Source
var BuiltInFloatObj = &PanObj{}

BuiltInFloatObj is an object of Float (proto of each float).

View Source
var BuiltInFuncObj = &PanObj{}

BuiltInFuncObj is an object of Func (proto of each func).

View Source
var BuiltInIOObj = &PanObj{}

BuiltInIOObj is an object of IO (proto of each io).

View Source
var BuiltInIntObj = &PanObj{}

BuiltInIntObj is an object of Int (proto of each int).

View Source
var BuiltInIterObj = &PanObj{}

BuiltInIterObj is an object of Iter (proto of each iter).

View Source
var BuiltInIterableObj = &PanObj{}

BuiltInIterableObj is an object of Iterable, which is mixed-in iterable objects.

View Source
var BuiltInJSONObj = &PanObj{}

BuiltInJSONObj is an object of JSON, whose props can be used in top-level.

View Source
var BuiltInKernelObj = &PanObj{}

BuiltInKernelObj is an object of Kernel, whose props can be used in top-level.

View Source
var BuiltInMapObj = &PanObj{}

BuiltInMapObj is an object of Map (proto of each map).

View Source
var BuiltInMatchObj = &PanObj{}

BuiltInMatchObj is an object of Match (proto of each match).

View Source
var BuiltInNameErr = &PanObj{}

BuiltInNameErr is an object of NameErr (proto of each nameErr).

View Source
var BuiltInNil = &PanNil{proto: BuiltInNilObj}

BuiltInNil is a nil object `nil`.

View Source
var BuiltInNilObj = &PanObj{}

BuiltInNilObj is an object of Nil (proto of nil).

View Source
var BuiltInNoPropErr = &PanObj{}

BuiltInNoPropErr is an object of NoPropErr (proto of each noPropErr).

View Source
var BuiltInNotImplemented = NewNotImplementedErr("Not implemented")

BuiltInNotImplemented is an object of _

View Source
var BuiltInNotImplementedErr = &PanObj{}

BuiltInNotImplementedErr is an object of NotImplemented (proto of each notImplementdErr).

View Source
var BuiltInNumObj = &PanObj{}

BuiltInNumObj is an object of Num.

View Source
var BuiltInObjObj = &PanObj{}

BuiltInObjObj is an object of Obj (proto of each obj).

View Source
var BuiltInOneInt = &PanInt{Value: 1, proto: BuiltInIntObj}

BuiltInOneInt is an int object `1`.

View Source
var BuiltInRangeObj = &PanObj{}

BuiltInRangeObj is an object of Range (proto of each range).

View Source
var BuiltInStopIterErr = &PanObj{}

BuiltInStopIterErr is an object of StopIterErr (proto of each stopIterErr).

View Source
var BuiltInStrObj = &PanObj{}

BuiltInStrObj is an object of Str (proto of each str).

View Source
var BuiltInSyntaxErr = &PanObj{}

BuiltInSyntaxErr is an object of SyntaxErr (proto of each syntaxErr).

View Source
var BuiltInTrue = &PanBool{true}

BuiltInTrue is a bool object `true`.

View Source
var BuiltInTypeErr = &PanObj{}

BuiltInTypeErr is an object of TypeErr (proto of each typeErr).

View Source
var BuiltInValueErr = &PanObj{}

BuiltInValueErr is an object of ValueErr (proto of each valueErr).

View Source
var BuiltInWrappableObj = &PanObj{}

BuiltInWrappableObj is an object of Wrappable, which is mixed-in wrappable objects.

View Source
var BuiltInZeroDivisionErr = &PanObj{}

BuiltInZeroDivisionErr is an object of ZeroDivisionErr (proto of each zeroDivisionErr).

View Source
var BuiltInZeroInt = &PanInt{Value: 0, proto: BuiltInIntObj}

BuiltInZeroInt is an int object `0`.

Functions

func WithZero added in v0.8.0

func WithZero(zero PanObject) panObjOption

WithZero can set zero value to the new *PanObj.

func WithZeroFromSelf added in v0.8.0

func WithZeroFromSelf(f func(*PanObj) PanObject) panObjOption

WithZeroFromSelf can set zero value created from new object itself.

Types

type BuiltInFunc

type BuiltInFunc func(env *Env, kwargs *PanObj, args ...PanObject) PanObject

BuiltInFunc is a function for PanBuiltIn.

type DeferObj

type DeferObj struct {
	Node ast.Expr
}

DeferObj is a wrapper for deferred expr.

func (*DeferObj) Inspect

func (o *DeferObj) Inspect() string

Inspect returns formatted source code of this object.

func (*DeferObj) Proto

func (o *DeferObj) Proto() PanObject

Proto returns proto of this object.

func (*DeferObj) Repr added in v0.3.0

func (o *DeferObj) Repr() string

Repr returns pritty-printed string of this object.

func (*DeferObj) Type

func (o *DeferObj) Type() PanObjType

Type returns type of this PanObject.

func (*DeferObj) Zero added in v0.8.0

func (e *DeferObj) Zero() PanObject

Zero returns zero value of this object.

type Env

type Env struct {
	Store map[SymHash]PanObject
	// contains filtered or unexported fields
}

Env is an environment of variables.

func NewCopiedEnv added in v0.2.0

func NewCopiedEnv(env *Env) *Env

NewCopiedEnv makes copied environment of env, which is independent of original one.

func NewEnclosedEnv

func NewEnclosedEnv(e *Env) *Env

NewEnclosedEnv makes new environment of variables inside e. It is used to make closure.

func NewEnv

func NewEnv() *Env

NewEnv makes new environment of variables.

func NewEnvWithConsts

func NewEnvWithConsts() *Env

NewEnvWithConsts makes new global environment, which includes all standart objects.

func (*Env) Get

func (e *Env) Get(h SymHash) (PanObject, bool)

Get fetches variable value from the environment.

func (*Env) Global added in v0.10.0

func (e *Env) Global() *Env

Global returns the outer environment.

func (*Env) InjectFrom

func (e *Env) InjectFrom(obj *PanObj)

InjectFrom injects all obj props to env.

func (*Env) InjectIO

func (e *Env) InjectIO(in io.Reader, out io.Writer)

InjectIO injects reader and writer for `IO` object

func (*Env) InjectRecur

func (e *Env) InjectRecur(recurFunc BuiltInFunc)

InjectRecur injects built-in func `recur`.

func (*Env) Items

func (e *Env) Items() PanObject

Items returns all variables in the environment as obj.

func (*Env) Outer

func (e *Env) Outer() *Env

Outer returns outer environment.

func (*Env) Set

func (e *Env) Set(h SymHash, obj PanObject)

Set sets variable to the environment.

func (*Env) SetSourceFilePath added in v0.11.0

func (e *Env) SetSourceFilePath(path string)

SetSourceFilePath sets the path of the evaluating source file to _PANGAEA_SOURCE_PATH

type ErrKind

type ErrKind string

ErrKind is a information to designate error type. NOTE: ErrKind is necessary because all err is implemented by same struct, PanErr.

type FuncKind

type FuncKind int

FuncKind is a type of func-like objects. NOTE: The type is used to designate func and iter because their implementation is same type.

const (
	// FuncFunc shows PanFunc is func literal.
	FuncFunc FuncKind = iota
	// IterFunc shows PanFunc is iter literal.
	IterFunc
)

type FuncWrapper

type FuncWrapper interface {
	String() string
	Args() *PanArr
	Kwargs() *PanObj
	Body() *[]ast.Stmt
}

FuncWrapper is a wrapper for func literal ast node. NOTE: use interface to keep loose coupling to ast package

type HashKey

type HashKey struct {
	// to distinguish different type values with same hash
	Type  PanObjType
	Value uint64
}

HashKey is a hash for obj/map indexing. All Scalar objects have its own hash.

type MatchWrapper

type MatchWrapper interface {
	String() string
}

MatchWrapper is a wrapper for match literal ast node. NOTE: keep loose coupling to ast.MatchLiteral and PanMatch ast.MatchLiteral implements MatchWrapper

type Pair

type Pair struct {
	Key   PanObject
	Value PanObject
}

Pair is a PanObject key-value pair for obj or map items.

type PanArr

type PanArr struct {
	Elems []PanObject
	// contains filtered or unexported fields
}

PanArr is object of arr literal.

func NewInheritedArr added in v0.8.0

func NewInheritedArr(proto PanObject, elems ...PanObject) *PanArr

NewInheritedArr returns new arr object born of proto.

func NewPanArr added in v0.3.0

func NewPanArr(elems ...PanObject) *PanArr

NewPanArr returns new arr object.

func TraceProtoOfArr

func TraceProtoOfArr(obj PanObject) (*PanArr, bool)

TraceProtoOfArr traces proto chain of obj and returns arr proto.

func (*PanArr) Inspect

func (a *PanArr) Inspect() string

Inspect returns formatted source code of this object.

func (*PanArr) Proto

func (a *PanArr) Proto() PanObject

Proto returns proto of this object.

func (*PanArr) Repr added in v0.3.0

func (a *PanArr) Repr() string

Repr returns pritty-printed string of this object.

func (*PanArr) Type

func (a *PanArr) Type() PanObjType

Type returns type of this PanObject.

func (*PanArr) Zero added in v0.8.0

func (a *PanArr) Zero() PanObject

Zero returns zero value of this object.

type PanBool

type PanBool struct {
	Value bool
}

PanBool is object of bool literal.

func TraceProtoOfBool

func TraceProtoOfBool(obj PanObject) (*PanBool, bool)

TraceProtoOfBool traces proto chain of obj and returns bool proto.

func (*PanBool) Hash

func (b *PanBool) Hash() HashKey

Hash returns hashkey of this object.

func (*PanBool) Inspect

func (b *PanBool) Inspect() string

Inspect returns formatted source code of this object.

func (*PanBool) Proto

func (b *PanBool) Proto() PanObject

Proto returns proto of this object.

func (*PanBool) Repr added in v0.3.0

func (b *PanBool) Repr() string

Repr returns pritty-printed string of this object.

func (*PanBool) Type

func (b *PanBool) Type() PanObjType

Type returns type of this PanObject.

func (*PanBool) Zero added in v0.8.0

func (b *PanBool) Zero() PanObject

Zero returns zero value of this object.

type PanBuiltIn

type PanBuiltIn struct {
	Fn BuiltInFunc
}

PanBuiltIn is object of built-in func literal.

func NewPanBuiltInFunc added in v0.3.0

func NewPanBuiltInFunc(f BuiltInFunc) *PanBuiltIn

NewPanBuiltInFunc returns new BuiltInFunc object.

func TraceProtoOfBuiltInFunc

func TraceProtoOfBuiltInFunc(obj PanObject) (*PanBuiltIn, bool)

TraceProtoOfBuiltInFunc traces proto chain of obj and returns builtInFunc proto.

func (*PanBuiltIn) Inspect

func (b *PanBuiltIn) Inspect() string

Inspect returns formatted source code of this object.

func (*PanBuiltIn) Proto

func (b *PanBuiltIn) Proto() PanObject

Proto returns proto of this object.

func (*PanBuiltIn) Repr added in v0.3.0

func (b *PanBuiltIn) Repr() string

Repr returns pritty-printed string of this object.

func (*PanBuiltIn) Type

func (b *PanBuiltIn) Type() PanObjType

Type returns type of this PanObject.

func (*PanBuiltIn) Zero added in v0.8.0

func (b *PanBuiltIn) Zero() PanObject

Zero returns zero value of this object.

type PanBuiltInIter

type PanBuiltInIter struct {
	Fn  BuiltInFunc
	Env *Env
}

PanBuiltInIter is object of built-in iter literal. NOTE: it has env to save state

func NewPanBuiltInIter added in v0.3.0

func NewPanBuiltInIter(f BuiltInFunc, env *Env) *PanBuiltInIter

NewPanBuiltInIter returns new BuiltInIter object.

func TraceProtoOfBuiltInIter

func TraceProtoOfBuiltInIter(obj PanObject) (*PanBuiltInIter, bool)

TraceProtoOfBuiltInIter traces proto chain of obj and returns builtInIter proto.

func (*PanBuiltInIter) Inspect

func (b *PanBuiltInIter) Inspect() string

Inspect returns formatted source code of this object.

func (*PanBuiltInIter) Proto

func (b *PanBuiltInIter) Proto() PanObject

Proto returns proto of this object.

func (*PanBuiltInIter) Repr added in v0.3.0

func (b *PanBuiltInIter) Repr() string

Repr returns pritty-printed string of this object.

func (*PanBuiltInIter) Type

func (b *PanBuiltInIter) Type() PanObjType

Type returns type of this PanObject.

func (*PanBuiltInIter) Zero added in v0.8.0

func (b *PanBuiltInIter) Zero() PanObject

Zero returns zero value of this object.

type PanErr

type PanErr struct {
	ErrKind    ErrKind
	Msg        string
	StackTrace string
	// contains filtered or unexported fields
}

PanErr is object of err literal.

func NewAssertionErr

func NewAssertionErr(msg string) *PanErr

NewAssertionErr returns new assertionErr object.

func NewFileNotFoundErr added in v0.11.0

func NewFileNotFoundErr(msg string) *PanErr

NewFileNotFoundErr returns new fileNotFoundErr object.

func NewNameErr

func NewNameErr(msg string) *PanErr

NewNameErr returns new nameErr object.

func NewNoPropErr

func NewNoPropErr(msg string) *PanErr

NewNoPropErr returns new noPropErr object.

func NewNotImplementedErr

func NewNotImplementedErr(msg string) *PanErr

NewNotImplementedErr returns new notImplementedErr object.

func NewPanErr

func NewPanErr(msg string) *PanErr

NewPanErr returns new err object.

func NewStopIterErr

func NewStopIterErr(msg string) *PanErr

NewStopIterErr returns new stopIterErr object. NOTE: This error is prepared to make iter simpler, even though stopIter is not an error actually.

func NewSyntaxErr

func NewSyntaxErr(msg string) *PanErr

NewSyntaxErr returns new syntaxErr object.

func NewTypeErr

func NewTypeErr(msg string) *PanErr

NewTypeErr returns new typeErr object.

func NewValueErr

func NewValueErr(msg string) *PanErr

NewValueErr returns new valueErr object.

func NewZeroDivisionErr

func NewZeroDivisionErr(msg string) *PanErr

NewZeroDivisionErr returns new zeroDivisionErr object.

func (*PanErr) Inspect

func (e *PanErr) Inspect() string

Inspect returns formatted source code of this object.

func (*PanErr) Kind added in v0.2.0

func (e *PanErr) Kind() string

Kind returns kind of this err.

func (*PanErr) Message added in v0.2.0

func (e *PanErr) Message() string

Message returns error message.

func (*PanErr) Proto

func (e *PanErr) Proto() PanObject

Proto returns proto of this object.

func (*PanErr) Repr added in v0.3.0

func (e *PanErr) Repr() string

Repr returns pritty-printed string of this object.

func (*PanErr) Type

func (e *PanErr) Type() PanObjType

Type returns type of this PanObject.

func (*PanErr) Zero added in v0.8.0

func (e *PanErr) Zero() PanObject

Zero returns zero value of this object.

type PanErrWrapper added in v0.2.0

type PanErrWrapper struct {
	PanErr
}

PanErrWrapper is an error wrapper to treat error info without exception.

func TraceProtoOfErrWrapper added in v0.2.0

func TraceProtoOfErrWrapper(obj PanObject) (*PanErrWrapper, bool)

TraceProtoOfErrWrapper traces proto chain of obj and returns errWrapper proto.

func WrapErr added in v0.2.0

func WrapErr(err *PanErr) *PanErrWrapper

WrapErr wraps PanErr object and enables to treat error info without exception.

func (*PanErrWrapper) Inspect added in v0.2.0

func (w *PanErrWrapper) Inspect() string

Inspect returns formatted source code of this object.

func (*PanErrWrapper) Repr added in v0.3.0

func (w *PanErrWrapper) Repr() string

Repr returns pritty-printed string of this object.

func (*PanErrWrapper) Type added in v0.2.0

func (w *PanErrWrapper) Type() PanObjType

Type returns type of this PanObject.

type PanFloat

type PanFloat struct {
	Value float64
	// contains filtered or unexported fields
}

PanFloat is object of float literal.

func NewInheritedFloat added in v0.8.0

func NewInheritedFloat(proto PanObject, f float64) *PanFloat

NewInheritedFloat returns new float object born of proto.

func NewPanFloat added in v0.3.0

func NewPanFloat(f float64) *PanFloat

NewPanFloat returns new float object.

func TraceProtoOfFloat

func TraceProtoOfFloat(obj PanObject) (*PanFloat, bool)

TraceProtoOfFloat traces proto chain of obj and returns float proto.

func (*PanFloat) Hash

func (f *PanFloat) Hash() HashKey

Hash returns hashkey of this object.

func (*PanFloat) Inspect

func (f *PanFloat) Inspect() string

Inspect returns formatted source code of this object.

func (*PanFloat) Proto

func (f *PanFloat) Proto() PanObject

Proto returns proto of this object.

func (*PanFloat) Repr added in v0.3.0

func (f *PanFloat) Repr() string

Repr returns pritty-printed string of this object.

func (*PanFloat) Type

func (f *PanFloat) Type() PanObjType

Type returns type of this PanObject.

func (*PanFloat) Zero added in v0.8.0

func (f *PanFloat) Zero() PanObject

Zero returns zero value of this object.

type PanFunc

type PanFunc struct {
	FuncWrapper
	FuncKind FuncKind
	Env      *Env
}

PanFunc is object of func literal.

func NewPanFunc added in v0.3.0

func NewPanFunc(f FuncWrapper, env *Env) *PanFunc

NewPanFunc returns new func object.

func NewPanIter added in v0.3.0

func NewPanIter(f FuncWrapper, env *Env) *PanFunc

NewPanIter returns new func object.

func TraceProtoOfFunc

func TraceProtoOfFunc(obj PanObject) (*PanFunc, bool)

TraceProtoOfFunc traces proto chain of obj and returns func proto.

func (*PanFunc) Inspect

func (f *PanFunc) Inspect() string

Inspect returns formatted source code of this object.

func (*PanFunc) Proto

func (f *PanFunc) Proto() PanObject

Proto returns proto of this object.

func (*PanFunc) Repr added in v0.3.0

func (f *PanFunc) Repr() string

Repr returns pritty-printed string of this object.

func (*PanFunc) Type

func (f *PanFunc) Type() PanObjType

Type returns type of this PanObject.

func (*PanFunc) Zero added in v0.8.0

func (f *PanFunc) Zero() PanObject

Zero returns zero value of this object.

type PanIO

type PanIO struct {
	In  io.Reader
	Out io.Writer
	// contains filtered or unexported fields
}

PanIO is object of IO literal.

func NewPanIO added in v0.2.0

func NewPanIO(in io.Reader, out io.Writer) *PanIO

NewPanIO makes new io object.

func TraceProtoOfIO

func TraceProtoOfIO(obj PanObject) (*PanIO, bool)

TraceProtoOfIO traces proto chain of obj and returns IO proto.

func (*PanIO) Inspect

func (io *PanIO) Inspect() string

Inspect returns formatted source code of this object.

func (*PanIO) Proto

func (io *PanIO) Proto() PanObject

Proto returns proto of this object.

func (*PanIO) ReadLine added in v0.2.0

func (io *PanIO) ReadLine() (*PanStr, bool)

ReadLine reads line from in and returns it as PanStr.

func (*PanIO) Repr added in v0.3.0

func (io *PanIO) Repr() string

Repr returns pritty-printed string of this object.

func (*PanIO) Type

func (io *PanIO) Type() PanObjType

Type returns type of this PanObject.

func (*PanIO) Zero added in v0.8.0

func (io *PanIO) Zero() PanObject

Zero returns zero value of this object.

type PanInt

type PanInt struct {
	Value int64
	// contains filtered or unexported fields
}

PanInt is object of int literal.

func NewInheritedInt added in v0.8.0

func NewInheritedInt(proto PanObject, i int64) *PanInt

NewInheritedInt returns new int object born of proto.

func NewPanInt

func NewPanInt(i int64) *PanInt

NewPanInt returns new int object. NOTE: `0` and `1` are cached and always same instance are returned.

func TraceProtoOfInt

func TraceProtoOfInt(obj PanObject) (*PanInt, bool)

TraceProtoOfInt traces proto chain of obj and returns int proto.

func (*PanInt) Hash

func (i *PanInt) Hash() HashKey

Hash returns hashkey of this object.

func (*PanInt) Inspect

func (i *PanInt) Inspect() string

Inspect returns formatted source code of this object.

func (*PanInt) Proto

func (i *PanInt) Proto() PanObject

Proto returns proto of this object.

func (*PanInt) Repr added in v0.3.0

func (i *PanInt) Repr() string

Repr returns pritty-printed string of this object.

func (*PanInt) Type

func (i *PanInt) Type() PanObjType

Type returns type of this PanObject.

func (*PanInt) Zero added in v0.8.0

func (i *PanInt) Zero() PanObject

Zero returns zero value of this object.

type PanMap

type PanMap struct {
	// used to keep map order
	HashKeys         *[]HashKey
	Pairs            *map[HashKey]Pair
	NonHashablePairs *[]Pair
	// contains filtered or unexported fields
}

PanMap is object of map literal.

func NewEmptyPanMap added in v0.3.0

func NewEmptyPanMap() *PanMap

NewEmptyPanMap returns new empty map object.

func NewInheritedMap added in v0.8.0

func NewInheritedMap(proto PanObject, pairs ...Pair) *PanMap

NewInheritedMap returns new map object born of proto.

func NewPanMap added in v0.3.0

func NewPanMap(pairs ...Pair) *PanMap

NewPanMap returns new map object.

func TraceProtoOfMap

func TraceProtoOfMap(obj PanObject) (*PanMap, bool)

TraceProtoOfMap traces proto chain of obj and returns map proto.

func (*PanMap) Inspect

func (m *PanMap) Inspect() string

Inspect returns formatted source code of this object.

func (*PanMap) Proto

func (m *PanMap) Proto() PanObject

Proto returns proto of this object.

func (*PanMap) Repr added in v0.3.0

func (m *PanMap) Repr() string

Repr returns pritty-printed string of this object.

func (*PanMap) Type

func (m *PanMap) Type() PanObjType

Type returns type of this PanObject.

func (*PanMap) Zero added in v0.8.0

func (m *PanMap) Zero() PanObject

Zero returns zero value of this object.

type PanMatch

type PanMatch struct {
	MatchWrapper
}

PanMatch is object of match literal.

func TraceProtoOfMatch

func TraceProtoOfMatch(obj PanObject) (*PanMatch, bool)

TraceProtoOfMatch traces proto chain of obj and returns match proto.

func (*PanMatch) Inspect

func (m *PanMatch) Inspect() string

Inspect returns formatted source code of this object.

func (*PanMatch) Proto

func (m *PanMatch) Proto() PanObject

Proto returns proto of this object.

func (*PanMatch) Repr added in v0.3.0

func (m *PanMatch) Repr() string

Repr returns pritty-printed string of this object.

func (*PanMatch) Type

func (m *PanMatch) Type() PanObjType

Type returns type of this PanObject.

func (*PanMatch) Zero added in v0.8.0

func (m *PanMatch) Zero() PanObject

Zero returns zero value of this object.

type PanNil

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

PanNil is object of nil literal.

func NewInheritedNil added in v0.8.0

func NewInheritedNil(proto PanObject) *PanNil

NewInheritedNil returns new nil object born of proto.

func NewPanNil added in v0.3.0

func NewPanNil() *PanNil

NewPanNil returns new nil object.

func TraceProtoOfNil

func TraceProtoOfNil(obj PanObject) (*PanNil, bool)

TraceProtoOfNil traces proto chain of obj and returns nil proto.

func (*PanNil) Hash

func (n *PanNil) Hash() HashKey

Hash returns hashkey of this object.

func (*PanNil) Inspect

func (n *PanNil) Inspect() string

Inspect returns formatted source code of this object.

func (*PanNil) Proto

func (n *PanNil) Proto() PanObject

Proto returns proto of this object.

func (*PanNil) Repr added in v0.3.0

func (n *PanNil) Repr() string

Repr returns pritty-printed string of this object.

func (*PanNil) Type

func (n *PanNil) Type() PanObjType

Type returns type of this PanObject.

func (*PanNil) Zero added in v0.8.0

func (n *PanNil) Zero() PanObject

Zero returns zero value of this object.

type PanObj

type PanObj struct {
	Pairs       *map[SymHash]Pair
	Keys        *[]SymHash
	PrivateKeys *[]SymHash
	// contains filtered or unexported fields
}

PanObj is object for not only obj literal but also any PanObject except specific data structure literal.

func ChildPanObjPtr

func ChildPanObjPtr(proto PanObject, src *PanObj, options ...panObjOption) *PanObj

FIXME: call NewPanObj inside ChildPanObjPtr makes new child object of proto with props in src.

func EmptyPanObjPtr

func EmptyPanObjPtr() *PanObj

EmptyPanObjPtr makes new empty obj literal.

func NewPanObj

func NewPanObj(pairs *map[SymHash]Pair, proto PanObject, options ...panObjOption) *PanObj

NewPanObj makes new PanObj instance.

func PanObjInstance

func PanObjInstance(pairs *map[SymHash]Pair) PanObj

FIXME: use PanObjInstancePtr instead PanObjInstance makes new obj literal.

func TraceProtoOfObj

func TraceProtoOfObj(obj PanObject) (*PanObj, bool)

TraceProtoOfObj traces proto chain of obj and returns PanObj type proto.

func (*PanObj) AddPairs

func (o *PanObj) AddPairs(pairs *map[SymHash]Pair) error

AddPairs adds pairs to obj. NOTE: Use this method only for prop DI. Otherwise immutability gets broken.

func (*PanObj) Inspect

func (o *PanObj) Inspect() string

Inspect returns formatted source code of this object.

func (*PanObj) Proto

func (o *PanObj) Proto() PanObject

Proto returns proto of this object.

func (*PanObj) Repr added in v0.3.0

func (o *PanObj) Repr() string

Repr returns pritty-printed string of this object.

func (*PanObj) Type

func (o *PanObj) Type() PanObjType

Type returns type of this PanObject.

func (*PanObj) Zero added in v0.8.0

func (o *PanObj) Zero() PanObject

Zero returns zero value of this object.

type PanObjType

type PanObjType string

PanObjType is type information to designate each PanObject.

type PanObject

type PanObject interface {
	Type() PanObjType
	Inspect() string
	Repr() string
	Proto() PanObject
	Zero() PanObject
}

PanObject is an interface of all Pangaea object implementations.

func FindPropAlongProtos added in v0.2.0

func FindPropAlongProtos(o PanObject, propHash SymHash) (PanObject, bool)

FindPropAlongProtos traces proto chain and returns prop.

func FindPropOwner added in v0.4.0

func FindPropOwner(o PanObject, propHash SymHash) (PanObject, bool)

FindPropOwner traces proto chain and returns the prop's owner.

func PanObjInstancePtr

func PanObjInstancePtr(pairs *map[SymHash]Pair) PanObject

PanObjInstancePtr makes new obj literal.

func SymHash2Str

func SymHash2Str(h SymHash) (PanObject, bool)

SymHash2Str gets str literal from symbol hash.

type PanRange

type PanRange struct {
	Start PanObject
	Stop  PanObject
	Step  PanObject
	// contains filtered or unexported fields
}

PanRange is object of range literal.

func NewInheritedRange added in v0.8.0

func NewInheritedRange(proto PanObject, start, stop, step PanObject) *PanRange

NewInheritedRange returns new range object born of proto.

func NewPanRange added in v0.3.0

func NewPanRange(start, stop, step PanObject) *PanRange

NewPanRange returns new range object.

func TraceProtoOfRange

func TraceProtoOfRange(obj PanObject) (*PanRange, bool)

TraceProtoOfRange traces proto chain of obj and returns range proto.

func (*PanRange) Inspect

func (r *PanRange) Inspect() string

Inspect returns formatted source code of this object.

func (*PanRange) Proto

func (r *PanRange) Proto() PanObject

Proto returns proto of this object.

func (*PanRange) Repr added in v0.3.0

func (r *PanRange) Repr() string

Repr returns pritty-printed string of this object.

func (*PanRange) Type

func (r *PanRange) Type() PanObjType

Type returns type of this PanObject.

func (*PanRange) Zero added in v0.8.0

func (r *PanRange) Zero() PanObject

Zero returns zero value of this object.

type PanScalar

type PanScalar interface {
	PanObject
	Hash() HashKey
}

PanScalar is an interface of scalar PanObject, which does not have child components.

type PanStr

type PanStr struct {
	Value    string
	IsPublic bool
	IsSym    bool
	// contains filtered or unexported fields
}

PanStr is object of str literal.

func NewInheritedStr added in v0.8.0

func NewInheritedStr(proto PanObject, s string) *PanStr

NewInheritedStr returns new str object born of proto.

func NewPanStr

func NewPanStr(s string) *PanStr

NewPanStr makes new str object.

func TraceProtoOfStr

func TraceProtoOfStr(obj PanObject) (*PanStr, bool)

TraceProtoOfStr traces proto chain of obj and returns str proto.

func (*PanStr) Hash

func (s *PanStr) Hash() HashKey

Hash returns hashkey of this object.

func (*PanStr) Inspect

func (s *PanStr) Inspect() string

Inspect returns formatted source code of this object.

func (*PanStr) Proto

func (s *PanStr) Proto() PanObject

Proto returns proto of this object.

func (*PanStr) Repr added in v0.3.0

func (s *PanStr) Repr() string

Repr returns pritty-printed string of this object.

func (*PanStr) SymHash

func (s *PanStr) SymHash() SymHash

SymHash returns symbol hash of this object, which is used for prop reference.

func (*PanStr) Type

func (s *PanStr) Type() PanObjType

Type returns type of this PanObject.

func (*PanStr) Zero added in v0.8.0

func (s *PanStr) Zero() PanObject

Zero returns zero value of this object.

type ReturnObj

type ReturnObj struct {
	PanObject
}

ReturnObj is a wrapper for returned value.

func (*ReturnObj) Type

func (o *ReturnObj) Type() PanObjType

Type returns type of this PanObject.

type SymHash

type SymHash = uint64

SymHash is symbol hash to refer str literal efficiently. This is lighter than HashKey and only for str.

func GetSymHash

func GetSymHash(str string) SymHash

GetSymHash gets symbol hash of the string.

type YieldObj

type YieldObj struct {
	PanObject
}

YieldObj is a wrapper for yielded value.

func (*YieldObj) Type

func (o *YieldObj) Type() PanObjType

Type returns type of this PanObject.

Jump to

Keyboard shortcuts

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