Documentation
¶
Index ¶
- Constants
- Variables
- func NewWritersFrom(cfg *Config) (*Writer, *Writer)
- type BindingPower
- type Chunk
- type Compiler
- type CompilerError
- type Config
- type ConfirmationAction
- type Diff
- type Evaluator
- type Goroutine
- type GoroutineDump
- func (gd *GoroutineDump) Add(g *Goroutine)
- func (gd *GoroutineDump) Copy() *GoroutineDump
- func (gd *GoroutineDump) Has(p *Goroutine) bool
- func (gd *GoroutineDump) Index()
- func (gd *GoroutineDump) Len() int
- func (gd *GoroutineDump) Next() *Goroutine
- func (gd GoroutineDump) Save(fn string) error
- func (gd *GoroutineDump) Show(w *Writer, pragma PragmaDedup, limit, offset int)
- func (gd *GoroutineDump) Sort()
- func (gd *GoroutineDump) StartIter()
- func (gd *GoroutineDump) String() string
- func (gd *GoroutineDump) Summary(w *Writer, name string)
- type MultiAssignment
- type Op
- type OpCode
- type Pragma
- type PragmaDedup
- type PragmaDisplay
- type Tag
- type Token
- type TokenType
- type Tokenizer
- type VM
- type Value
- type Writer
Constants ¶
const ( PragmaDisplayCount = "count" PragmaDisplaySummary = "summary" PragmaDisplayNone = "none" )
const ( PragmaDedupIDs = "ids" PragmaDedupNumber = "number" PragmaDedupNone = "none" )
Variables ¶
var ( ErrOutOfGas = errors.New("processed more than maximum number of instructions") ErrEmptyStack = errors.New("tried to pop off empty stack") ErrUnexpectedStackState = errors.New("unexpected stack state") ErrNotIterating = errors.New("not iterating a goroutine dump") ErrOutOfStackBounds = errors.New("jump outside of stack bounds") ErrInvalidType = errors.New("invalid type for operation") ErrWrongTag = errors.New("data had wrong tag for type") ErrInvalidOpArg = errors.New("invalid argument for operation") ErrArgumentUnset = errors.New("expected argument is unset") ErrNoSuchOpCode = errors.New("no such op code") ErrExpectedConstantValueByte = errors.New("expected value after constant load byte") ErrExpectedJumpAddress = errors.New("expected address for jump") ErrExpectedCommand = errors.New("expected valid command after command byte") ErrNoSuchEnv = errors.New("no identifer with name") ErrNoSuchPragma = errors.New("no pragma with name") ErrExpectedDiffAssign = errors.New("assigning a diff must have 3 identifiers or \"_\"") ErrCommandQuit = errors.New("user quit") ErrCommandOk = errors.New("command ok") ErrCommandConfirm = errors.New("are you sure?") )
var EmptyToken = Token{}
var ErrEOF = errors.New("EOF")
var ErrExpectedMaybeType = errors.New("expected optional")
var ErrExpectedPath = errors.New("expected a path argument")
var ErrInvalidArg = errors.New("invalid argument")
var ErrMissingArgs = errors.New("expected more arguments")
var ErrTooManyArgs = errors.New("too many arguments")
var NoValue = Value{Tag: TagNone}
Functions ¶
func NewWritersFrom ¶
NewWritersFrom returns a "stdout" and a "stderr" Writer based on the configuration
Types ¶
type BindingPower ¶
type BindingPower = int
const ( BindingNone BindingPower = iota BindingComma BindingAssignment BindingPipe BindingFunc BindingOr BindingAnd BindingEq BindingCompare BindingUnary BindingCall BindingPrimary BindingAtom )
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
func NewCompiler ¶
func NewCompiler() *Compiler
type CompilerError ¶
type CompilerError struct {
// contains filtered or unexported fields
}
func (CompilerError) Error ¶
func (e CompilerError) Error() string
func (CompilerError) Unwrap ¶
func (e CompilerError) Unwrap() error
type ConfirmationAction ¶
type ConfirmationAction struct {
// contains filtered or unexported fields
}
ConfirmationAction lets us close over a function and smuggle it back out to the REPL for execution
func (ConfirmationAction) Error ¶
func (c ConfirmationAction) Error() string
func (ConfirmationAction) Run ¶
func (c ConfirmationAction) Run()
type Diff ¶
type Diff struct {
Left *GoroutineDump
Right *GoroutineDump
Common *GoroutineDump
}
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
func NewEvaluator ¶
func (*Evaluator) Completions ¶
Completions returns all the known functions, commands, and keywords, plus all the tokens in the environment
type Goroutine ¶
type Goroutine struct {
ID int `json:"id"`
Duration int `json:"duration"` // In minutes, from meta in header
State string `json:"state"` // From meta in header
CreatedBy int `json:"createdBy"`
Trace string `json:"trace"`
LineCount int `json:"lines"`
// contains filtered or unexported fields
}
func NewGoroutine ¶
NewGoroutine creates and returns a new Goroutine.
type GoroutineDump ¶
type GoroutineDump struct {
// contains filtered or unexported fields
}
func NewGoroutineDump ¶
func NewGoroutineDump() *GoroutineDump
func (*GoroutineDump) Add ¶
func (gd *GoroutineDump) Add(g *Goroutine)
func (*GoroutineDump) Copy ¶
func (gd *GoroutineDump) Copy() *GoroutineDump
Copy duplicates the goroutine dump with a shallow copy of the goroutines and a reset iterator
func (*GoroutineDump) Has ¶
func (gd *GoroutineDump) Has(p *Goroutine) bool
func (*GoroutineDump) Index ¶
func (gd *GoroutineDump) Index()
Index creates an lookup table for duplicates. It assumes the dump is sorted. Because dumps are intended to be immutable, it'll check/set the isIndexed flag so that we only do this expensive work once.
func (*GoroutineDump) Len ¶
func (gd *GoroutineDump) Len() int
func (*GoroutineDump) Next ¶
func (gd *GoroutineDump) Next() *Goroutine
func (GoroutineDump) Save ¶
func (gd GoroutineDump) Save(fn string) error
Save saves the goroutine dump to the given file. Assumes the dump is already sorted.
func (*GoroutineDump) Show ¶
func (gd *GoroutineDump) Show(w *Writer, pragma PragmaDedup, limit, offset int)
Show displays the goroutines with the given limit and offset
func (*GoroutineDump) Sort ¶
func (gd *GoroutineDump) Sort()
Sort sorts the goroutines by ID. Generally speaking we only need this once we've unioned two dumps
func (*GoroutineDump) StartIter ¶
func (gd *GoroutineDump) StartIter()
func (*GoroutineDump) String ¶
func (gd *GoroutineDump) String() string
String is a placeholder until we wire this all up to the REPL writer
func (*GoroutineDump) Summary ¶
func (gd *GoroutineDump) Summary(w *Writer, name string)
type MultiAssignment ¶
type MultiAssignment []int
MultiAssignment is stored as a constant and itself contains indexes into the constants table. This lets us multi-assign by emitting an OpCodeAssignment that the VM will then dereference into these values and pop items off the stack. Like Go, you can use the _ sigil, which maps to a -1 xindex. In that case, the VM will pop a value off the stack and drop it.
type OpCode ¶
type OpCode uint
const ( OpCodeNoop OpCode = iota // loads OpCodeLoadGoroutineDump OpCodeLoadFieldAccessor OpCodeLoadNumber OpCodeLoadString // stores OpCodeAssignment OpCodePushBool OpCodePushDump OpCodeDup // filter iteration OpCodeAddGoroutine OpCodeNextGoroutine OpCodeTempDump // comparisons OpCodeContains OpCodeIn // opContains OpCodeRegexMatches OpCodeRegexNotMatches // opRegexMatches OpCodeEqual // opComparison OpCodeGreater // opComparison OpCodeGreaterEqual // opComparison OpCodeLess // opComparison OpCodeLessEqual // opComparison OpCodeNotEqual // opComparison // control flow OpCodeJumpIfFalse // opConditionalJump OpCodeJumpIfTrue // opConditionalJump OpCodeJumpTo // functions OpCodeFuncDiff OpCodeFuncIntersect OpCodeFuncLoad OpCodeFuncSave OpCodeFuncShowDump OpCodeFuncToJSON OpCodeFuncToDot OpCodeFuncUnion OpCodeFuncGraph // commands OpCodeCommandChangeDir OpCodeCommandEmpty OpCodeCommandGetWorkingDir OpCodeCommandHelp OpCodeCommandListDir OpCodeCommandQuit OpCodeCommandVars OpCodeCommandSetPragma OpCodeCommandGetPragma OpCodePatchPlaceholder = 0x000000000000ffff )
type Pragma ¶
type Pragma struct {
EmptyConfirm bool
ExitConfirm bool
ListFormat string
ShowColor bool
ShowCount int
ShowDedup string
VarsDisplay string
Gas int
StackSize int
}
Pragma represents all the VM's configuration values.
type PragmaDedup ¶
type PragmaDedup string
type PragmaDisplay ¶
type PragmaDisplay string
type TokenType ¶
type TokenType uint8
const ( TokenInvalid TokenType = iota // invalid TokenPipe // pipe TokenLeftParen // left paren TokenRightParen // right paren TokenPlus // + TokenMinus // - TokenStar // * TokenSlash // / TokenBang // ! TokenComma // , TokenAssign // = // comparisons TokenEqual // == TokenNotEqual // != TokenLessThan // < TokenLessEqualThan // <= TokenGreaterThan // > TokenGreaterEqualThan // >= TokenKeywordContains // contains TokenKeywordMatches // match TokenKeywordIn // in TokenRegexMatch // =~ TokenRegexNotMatch // !~ // literals TokenIdentifier // identifier TokenString // string TokenNumber // number TokenFieldAccessor // field accessor // logic TokenKeywordAnd // and TokenKeywordOr // or // TokenCommand // command TokenFunction // function TokenMethod // method TokenPragma // pragma )
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}
func NewTokenizer ¶
func NewTokenizer() *Tokenizer