Documentation ¶
Index ¶
Constants ¶
const CurrentFunction = -1
const NoVariadicArgs = -1
const ReturnString = -1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Condition ¶
type Condition int8
const ( ConditionZero Condition = iota // x == 0 ConditionNotZero // x != 0 ConditionEqual // x == y ConditionNotEqual // x != y ConditionInterfaceEqual // x == y ConditionInterfaceNotEqual // x != y ConditionLess // x < y ConditionLessEqual // x <= y ConditionGreater // x > y ConditionGreaterEqual // x >= y ConditionLessU // x < y (unsigned) ConditionLessEqualU // x <= y (unsigned) ConditionGreaterU // x > y (unsigned) ConditionGreaterEqualU // x >= y (unsigned) ConditionLenEqual // len(x) == y ConditionLenNotEqual // len(x) != y ConditionLenLess // len(x) < y ConditionLenLessEqual // len(x) <= y ConditionLenGreater // len(x) > y ConditionLenGreaterEqual // len(x) >= y ConditionInterfaceNil // x == nil ConditionInterfaceNotNil // x != nil ConditionNil // x == nil ConditionNotNil // x != nil ConditionContainsSubstring // x contains y ConditionContainsRune // x contains y ConditionContainsElement // x contains y ConditionContainsKey // x contains y ConditionContainsNil // x contains nil ConditionNotContainsSubstring // x not contains y ConditionNotContainsRune // x not contains y ConditionNotContainsElement // x not contains y ConditionNotContainsKey // x not contains y ConditionNotContainsNil // x not contains nil ConditionOK // [vm.ok] ConditionNotOK // ![vm.ok] )
type Function ¶
type Function struct { Pkg string Name string File string Pos *Position // position of the function declaration. Type reflect.Type Parent *Function VarRefs []int16 Types []reflect.Type NumReg [4]int8 FinalRegs [][2]int8 // [indirect -> return parameter registers] Macro bool Format ast.Format Values Registers FieldIndexes [][]int Functions []*Function NativeFunctions []*NativeFunction Body []Instruction Text [][]byte InstructionInfo map[Addr]InstructionInfo }
Function represents a function.
type Instruction ¶
type InstructionInfo ¶ added in v0.55.0
type InstructionInfo struct { Position Position // position of the instruction in the source code. Path string // path of the source code where the instruction is located in. OperandKind [3]reflect.Kind // kind of operands A, B and C. FuncType reflect.Type // type of the function that is called; only for call instructions. }
InstructionInfo represents a set of information associated to a given instruction. None of the fields below is mandatory.
type NativeFunction ¶
type NativeFunction struct {
// contains filtered or unexported fields
}
func NewNativeFunction ¶
func NewNativeFunction(pkg, name string, function interface{}) *NativeFunction
NewNativeFunction returns a new native function given its package and name and the function value or its reflect value. pkg and name can be empty strings.
func (*NativeFunction) Func ¶
func (fn *NativeFunction) Func() interface{}
func (*NativeFunction) Name ¶
func (fn *NativeFunction) Name() string
func (*NativeFunction) Package ¶
func (fn *NativeFunction) Package() string
type Operation ¶
type Operation int8
const ( OpNone Operation = iota OpAdd OpAddInt OpAddFloat64 OpAddr OpAnd OpAndNot OpAssert OpAppend OpAppendSlice OpBreak OpCallFunc OpCallIndirect OpCallMacro OpCallNative OpCap OpCase OpClose OpComplex64 OpComplex128 OpConcat OpContinue OpConvert OpConvertInt OpConvertUint OpConvertFloat OpConvertString OpCopy OpDefer OpDelete OpDiv OpDivInt OpDivFloat64 OpField OpGetVar OpGetVarAddr OpGo OpGoto OpIf OpIfInt OpIfFloat OpIfString OpIndex OpIndexString OpIndexRef OpLen OpLoad OpLoadFunc OpMakeArray OpMakeChan OpMakeMap OpMakeSlice OpMakeStruct OpMapIndex OpMapIndexAny OpMethodValue OpMove OpMul OpMulInt OpMulFloat64 OpNeg OpNew OpOr OpPanic OpPrint OpRange OpRangeString OpRealImag OpReceive OpRecover OpRem OpRemInt OpReturn OpSelect OpSend OpSetField OpSetMap OpSetSlice OpSetVar OpShl OpShlInt OpShow OpShr OpShrInt OpSlice OpStringSlice OpSub OpSubInt OpSubFloat64 OpSubInv OpSubInvInt OpSubInvFloat64 OpTailCall OpText OpTypify OpXor OpZero )
type PanicError ¶ added in v0.49.0
type PanicError struct {
// contains filtered or unexported fields
}
func (*PanicError) Error ¶ added in v0.49.0
func (p *PanicError) Error() string
Error returns all currently active panics as a string.
To print only the message, use the String method instead.
func (*PanicError) Message ¶ added in v0.49.0
func (p *PanicError) Message() interface{}
Message returns the message.
func (*PanicError) Next ¶ added in v0.49.0
func (p *PanicError) Next() *PanicError
Next returns the next panic in the chain.
func (*PanicError) Path ¶ added in v0.49.0
func (p *PanicError) Path() string
Path returns the path of the file that panicked.
func (*PanicError) Position ¶ added in v0.49.0
func (p *PanicError) Position() Position
Position returns the position.
func (*PanicError) Recovered ¶ added in v0.49.0
func (p *PanicError) Recovered() bool
Recovered reports whether it has been recovered.
func (*PanicError) String ¶ added in v0.49.0
func (p *PanicError) String() string
String returns the message as a string.
type Position ¶
type Position struct { Line int // line starting from 1 Column int // column in characters starting from 1 Start int // index of the first byte End int // index of the last byte }
Position represents a source position.
type ScriggoType ¶
type ScriggoType interface { reflect.Type // Wrap wraps a value with a Scriggo type putting into a proxy that exposes // methods to Go. Wrap(reflect.Value) reflect.Value // Unwrap unwraps a value that has been read from Go. If the value given as // parameter can be unwrapped using the unwrapper's type, the unwrapped // value is returned and the method returns true. Unwrap(reflect.Value) (reflect.Value, bool) // GoType returns the Go type of a Scriggo type. Note that the // implementation of the reflect.Type returned by GoType is the // implementation of the package 'reflect', so it's safe to pass the // returned value to reflect functions and methods as argument. GoType() reflect.Type }
A ScriggoType represents a type compiled by Scriggo from a type definition or a composite type literal with at least one element with a Scriggo type.
type StackShift ¶
type StackShift [4]int8
type TypeOfFunc ¶
A TypeOfFunc function returns a type of a value.
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM represents a Scriggo virtual machine.
func (*VM) Reset ¶
func (vm *VM) Reset()
Reset resets a virtual machine so that it is ready for a new call to Run.
func (*VM) Run ¶
Run starts the execution of the function fn with the given global variables and waits for it to complete.
During the execution if a panic occurs and has not been recovered, by default Run panics with the panic message.
If a context has been set and the context is canceled, Run returns as soon as possible with the error returned by the Err method of the context.
func (*VM) SetContext ¶
SetContext sets the context.
SetContext must not be called after vm has been started.
func (*VM) SetPrint ¶
SetPrint sets the "print" builtin function.
SetPrint must not be called after vm has been started.
func (*VM) SetRenderer ¶ added in v0.49.0
SetRenderer sets template output and markdown converter.
SetRenderer must not be called after vm has been started.