Documentation ¶
Index ¶
- Constants
- Variables
- func WithZero(zero PanObject) panObjOption
- func WithZeroFromSelf(f func(*PanObj) PanObject) panObjOption
- type BuiltInFunc
- type DeferObj
- type Env
- func (e *Env) Get(h SymHash) (PanObject, bool)
- func (e *Env) Global() *Env
- func (e *Env) InjectFrom(obj *PanObj)
- func (e *Env) InjectIO(in io.Reader, out io.Writer)
- func (e *Env) InjectRecur(recurFunc BuiltInFunc)
- func (e *Env) Items() PanObject
- func (e *Env) Outer() *Env
- func (e *Env) Set(h SymHash, obj PanObject)
- func (e *Env) SetSourceFilePath(path string)
- type ErrKind
- type FuncKind
- type FuncWrapper
- type HashKey
- type MatchWrapper
- type Pair
- type PanArr
- type PanBool
- type PanBuiltIn
- type PanBuiltInIter
- type PanErr
- func NewAssertionErr(msg string) *PanErr
- func NewFileNotFoundErr(msg string) *PanErr
- func NewNameErr(msg string) *PanErr
- func NewNoPropErr(msg string) *PanErr
- func NewNotImplementedErr(msg string) *PanErr
- func NewPanErr(msg string) *PanErr
- func NewStopIterErr(msg string) *PanErr
- func NewSyntaxErr(msg string) *PanErr
- func NewTypeErr(msg string) *PanErr
- func NewValueErr(msg string) *PanErr
- func NewZeroDivisionErr(msg string) *PanErr
- type PanErrWrapper
- type PanFloat
- type PanFunc
- type PanIO
- type PanInt
- type PanMap
- type PanMatch
- type PanNil
- type PanObj
- func ChildPanObjPtr(proto PanObject, src *PanObj, options ...panObjOption) *PanObj
- func EmptyPanObjPtr() *PanObj
- func NewPanObj(pairs *map[SymHash]Pair, proto PanObject, options ...panObjOption) *PanObj
- func PanObjInstance(pairs *map[SymHash]Pair) PanObj
- func TraceProtoOfObj(obj PanObject) (*PanObj, bool)
- type PanObjType
- type PanObject
- type PanRange
- type PanScalar
- type PanStr
- type ReturnObj
- type SymHash
- type YieldObj
Constants ¶
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" )
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
const ArrType = "ArrType"
ArrType is a type of PanArr.
const BoolType = "BoolType"
BoolType is a type of PanBool.
const BuiltInIterType = "BuiltInIterType"
BuiltInIterType is a type of PanBuiltInIter.
const BuiltInType = "BuiltInType"
BuiltInType is a type of PanBuiltIn.
const DeferType = "DeferType"
DeferType is a type of DeferObj.
const ErrType = "ErrType"
ErrType is a type of PanErr.
const ErrWrapperType = "ErrWrapperType"
ErrWrapperType is a type of PanErrWrapper.
const FloatType = "FloatType"
FloatType is a type of PanFloat.
const FuncType = "FuncType"
FuncType is a type of PanFunc.
const IOType = "IOType"
IOType is a type of PanIO.
const IntType = "IntType"
IntType is a type of PanInt.
const MapType = "MapType"
MapType is a type of PanMap.
const MatchType = "MatchType"
MatchType is a type of PanMatch.
const NilType = "NilType"
NilType is a type of PanNil.
const ObjType = "ObjType"
ObjType is a type of PanObj.
const RangeType = "RangeType"
RangeType is a type of PanRange.
const ReturnType = "ReturnType"
ReturnType is a type of ReturnObj.
const StrType = "StrType"
StrType is a type of PanStr.
const YieldType = "YieldType"
YieldType is a type of YieldObj.
Variables ¶
var BuiltInArrObj = &PanObj{}
BuiltInArrObj is an object of Arr (proto of each arr).
var BuiltInAssertionErr = &PanObj{}
BuiltInAssertionErr is an object of AssertionErr (proto of each assertionErr).
var BuiltInBaseObj = &PanObj{}
BuiltInBaseObj is an object of BaseObj (ancestor of all objects).
var BuiltInComparableObj = &PanObj{}
BuiltInComparableObj is an object of Comparable, which is mixed-in comparable objects.
var BuiltInDiamondObj = &PanObj{}
BuiltInDiamondObj is an object of Diamond.
var BuiltInEitherErrObj = &PanObj{}
BuiltInEitherErrObj is an object of EitherErr.
var BuiltInEitherObj = &PanObj{}
BuiltInEitherObj is an object of Either.
var BuiltInEitherValObj = &PanObj{}
BuiltInEitherValObj is an object of EitherVal.
var BuiltInErrObj = &PanObj{}
BuiltInErrObj is an object of Err (proto of all specific err types).
var BuiltInFalse = &PanBool{false}
BuiltInFalse is a bool object `false`.
var BuiltInFileNotFoundErr = &PanObj{}
BuiltInFileNotFoundErr is an object of FileNotFoundErr (proto of each fileNotFoundErr).
var BuiltInFloatObj = &PanObj{}
BuiltInFloatObj is an object of Float (proto of each float).
var BuiltInFuncObj = &PanObj{}
BuiltInFuncObj is an object of Func (proto of each func).
var BuiltInIOObj = &PanObj{}
BuiltInIOObj is an object of IO (proto of each io).
var BuiltInIntObj = &PanObj{}
BuiltInIntObj is an object of Int (proto of each int).
var BuiltInIterObj = &PanObj{}
BuiltInIterObj is an object of Iter (proto of each iter).
var BuiltInIterableObj = &PanObj{}
BuiltInIterableObj is an object of Iterable, which is mixed-in iterable objects.
var BuiltInJSONObj = &PanObj{}
BuiltInJSONObj is an object of JSON, whose props can be used in top-level.
var BuiltInKernelObj = &PanObj{}
BuiltInKernelObj is an object of Kernel, whose props can be used in top-level.
var BuiltInMapObj = &PanObj{}
BuiltInMapObj is an object of Map (proto of each map).
var BuiltInMatchObj = &PanObj{}
BuiltInMatchObj is an object of Match (proto of each match).
var BuiltInNameErr = &PanObj{}
BuiltInNameErr is an object of NameErr (proto of each nameErr).
var BuiltInNil = &PanNil{proto: BuiltInNilObj}
BuiltInNil is a nil object `nil`.
var BuiltInNilObj = &PanObj{}
BuiltInNilObj is an object of Nil (proto of nil).
var BuiltInNoPropErr = &PanObj{}
BuiltInNoPropErr is an object of NoPropErr (proto of each noPropErr).
var BuiltInNotImplemented = NewNotImplementedErr("Not implemented")
BuiltInNotImplemented is an object of _
var BuiltInNotImplementedErr = &PanObj{}
BuiltInNotImplementedErr is an object of NotImplemented (proto of each notImplementdErr).
var BuiltInNumObj = &PanObj{}
BuiltInNumObj is an object of Num.
var BuiltInObjObj = &PanObj{}
BuiltInObjObj is an object of Obj (proto of each obj).
var BuiltInOneInt = &PanInt{Value: 1, proto: BuiltInIntObj}
BuiltInOneInt is an int object `1`.
var BuiltInRangeObj = &PanObj{}
BuiltInRangeObj is an object of Range (proto of each range).
var BuiltInStopIterErr = &PanObj{}
BuiltInStopIterErr is an object of StopIterErr (proto of each stopIterErr).
var BuiltInStrObj = &PanObj{}
BuiltInStrObj is an object of Str (proto of each str).
var BuiltInSyntaxErr = &PanObj{}
BuiltInSyntaxErr is an object of SyntaxErr (proto of each syntaxErr).
var BuiltInTrue = &PanBool{true}
BuiltInTrue is a bool object `true`.
var BuiltInTypeErr = &PanObj{}
BuiltInTypeErr is an object of TypeErr (proto of each typeErr).
var BuiltInValueErr = &PanObj{}
BuiltInValueErr is an object of ValueErr (proto of each valueErr).
var BuiltInWrappableObj = &PanObj{}
BuiltInWrappableObj is an object of Wrappable, which is mixed-in wrappable objects.
var BuiltInZeroDivisionErr = &PanObj{}
BuiltInZeroDivisionErr is an object of ZeroDivisionErr (proto of each zeroDivisionErr).
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
WithZeroFromSelf can set zero value created from new object itself.
Types ¶
type BuiltInFunc ¶
BuiltInFunc is a function for PanBuiltIn.
type DeferObj ¶
DeferObj is a wrapper for deferred expr.
type Env ¶
Env is an environment of variables.
func NewCopiedEnv ¶ added in v0.2.0
NewCopiedEnv makes copied environment of env, which is independent of original one.
func NewEnclosedEnv ¶
NewEnclosedEnv makes new environment of variables inside e. It is used to make closure.
func NewEnvWithConsts ¶
func NewEnvWithConsts() *Env
NewEnvWithConsts makes new global environment, which includes all standart objects.
func (*Env) InjectFrom ¶
InjectFrom injects all obj props to env.
func (*Env) InjectRecur ¶
func (e *Env) InjectRecur(recurFunc BuiltInFunc)
InjectRecur injects built-in func `recur`.
func (*Env) SetSourceFilePath ¶ added in v0.11.0
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.
type FuncWrapper ¶
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 PanArr ¶
type PanArr struct { Elems []PanObject // contains filtered or unexported fields }
PanArr is object of arr literal.
func NewInheritedArr ¶ added in v0.8.0
NewInheritedArr returns new arr object born of proto.
func TraceProtoOfArr ¶
TraceProtoOfArr traces proto chain of obj and returns arr proto.
type PanBool ¶
type PanBool struct {
Value bool
}
PanBool is object of bool literal.
func TraceProtoOfBool ¶
TraceProtoOfBool traces proto chain of obj and returns bool proto.
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 ¶
NewAssertionErr returns new assertionErr object.
func NewFileNotFoundErr ¶ added in v0.11.0
NewFileNotFoundErr returns new fileNotFoundErr object.
func NewNoPropErr ¶
NewNoPropErr returns new noPropErr object.
func NewNotImplementedErr ¶
NewNotImplementedErr returns new notImplementedErr object.
func NewStopIterErr ¶
NewStopIterErr returns new stopIterErr object. NOTE: This error is prepared to make iter simpler, even though stopIter is not an error actually.
func NewSyntaxErr ¶
NewSyntaxErr returns new syntaxErr object.
func NewZeroDivisionErr ¶
NewZeroDivisionErr returns new zeroDivisionErr 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
NewInheritedFloat returns new float object born of proto.
func NewPanFloat ¶ added in v0.3.0
NewPanFloat returns new float object.
func TraceProtoOfFloat ¶
TraceProtoOfFloat traces proto chain of obj and returns float proto.
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 ¶
TraceProtoOfFunc traces proto chain of obj and returns func proto.
type PanIO ¶
PanIO is object of IO literal.
func TraceProtoOfIO ¶
TraceProtoOfIO traces proto chain of obj and returns IO proto.
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
NewInheritedInt returns new int object born of proto.
func NewPanInt ¶
NewPanInt returns new int object. NOTE: `0` and `1` are cached and always same instance are returned.
func TraceProtoOfInt ¶
TraceProtoOfInt traces proto chain of obj and returns int proto.
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
NewInheritedMap returns new map object born of proto.
func TraceProtoOfMap ¶
TraceProtoOfMap traces proto chain of obj and returns map proto.
type PanMatch ¶
type PanMatch struct {
MatchWrapper
}
PanMatch is object of match literal.
func TraceProtoOfMatch ¶
TraceProtoOfMatch traces proto chain of obj and returns match proto.
type PanNil ¶
type PanNil struct {
// contains filtered or unexported fields
}
PanNil is object of nil literal.
func NewInheritedNil ¶ added in v0.8.0
NewInheritedNil returns new nil object born of proto.
func TraceProtoOfNil ¶
TraceProtoOfNil traces proto chain of obj and returns nil proto.
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 ¶
FIXME: call NewPanObj inside ChildPanObjPtr makes new child object of proto with props in src.
func PanObjInstance ¶
FIXME: use PanObjInstancePtr instead PanObjInstance makes new obj literal.
func TraceProtoOfObj ¶
TraceProtoOfObj traces proto chain of obj and returns PanObj type proto.
func (*PanObj) AddPairs ¶
AddPairs adds pairs to obj. NOTE: Use this method only for prop DI. Otherwise immutability gets broken.
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
FindPropAlongProtos traces proto chain and returns prop.
func FindPropOwner ¶ added in v0.4.0
FindPropOwner traces proto chain and returns the prop's owner.
func PanObjInstancePtr ¶
PanObjInstancePtr makes new obj literal.
func SymHash2Str ¶
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
NewInheritedRange returns new range object born of proto.
func NewPanRange ¶ added in v0.3.0
NewPanRange returns new range object.
func TraceProtoOfRange ¶
TraceProtoOfRange traces proto chain of obj and returns range proto.
type PanScalar ¶
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
NewInheritedStr returns new str object born of proto.
func TraceProtoOfStr ¶
TraceProtoOfStr traces proto chain of obj and returns str proto.