evalop

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFuncCallNotAllowed = errors.New("function calls not allowed without using 'call'")
)

Functions

func Listing

func Listing(depth []int, ops []Op) string

Types

type AddrOf

type AddrOf struct {
	Node *ast.UnaryExpr
}

AddrOf replaces the topmost stack variable v with &v.

type Binary

type Binary struct {
	Node *ast.BinaryExpr
}

Binary pops two variables from the stack, applies the specified binary operator to them and pushes the result back on the stack.

type BoolToConst

type BoolToConst struct {
}

BoolToConst pops the topmost variable from the stack, which must be a boolean variable, and converts it to a constant.

type BuiltinCall

type BuiltinCall struct {
	Name string
	Args []ast.Expr
}

BuiltinCall pops len(Args) argument from the stack, calls the specified builtin on them and pushes the result back on the stack.

type CallInjectionComplete

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

CallInjectionComplete resumes target execution so that the injected call can run.

type CallInjectionCopyArg

type CallInjectionCopyArg struct {
	ArgNum  int
	ArgExpr ast.Expr
	// contains filtered or unexported fields
}

CallInjectionCopyArg copies one argument for call injection.

type CallInjectionSetTarget

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

CallInjectionSetTarget starts the call injection, after runtime.debugCallVn set up the stack for us, by copying the entry point of the function, setting the closure register and copying the receiver.

type CallInjectionStart

type CallInjectionStart struct {
	HasFunc bool // target function already pushed on the stack
	Node    *ast.CallExpr
	// contains filtered or unexported fields
}

CallInjectionStart starts call injection by calling runtime.debugCallVn.

type CallInjectionStartSpecial

type CallInjectionStartSpecial struct {
	FnName string
	ArgAst []ast.Expr
	// contains filtered or unexported fields
}

CallInjectionStartSpecial starts call injection for a function with a name and arguments known at compile time.

type ConvertAllocToString

type ConvertAllocToString struct {
}

ConvertAllocToString pops two variables from the stack, a constant string and the return value of runtime.mallocgc (mallocv), copies the contents of the string at the address in mallocv and pushes on the stack a new string value that uses the backing storage of mallocv.

type Index

type Index struct {
	Node *ast.IndexExpr
}

Index pops two variables, idx and v, and pushes v[idx].

type Jump

type Jump struct {
	When   JumpCond
	Pop    bool
	Target int
	Node   ast.Expr
}

Jump looks at the topmost stack variable and if it satisfies the condition specified by When it jumps to the stack machine instruction at Target+1. If Pop is set the topmost stack variable is also popped.

type JumpCond

type JumpCond uint8

JumpCond specifies a condition for the Jump instruction.

const (
	JumpIfFalse JumpCond = iota
	JumpIfTrue
	JumpIfAllocStringChecksFail
)

type Op

type Op interface {
	// contains filtered or unexported methods
}

Op is a stack machine opcode

func Compile

func Compile(lookup evalLookup, expr string, canSet bool) ([]Op, error)

Compile compiles the expression expr into a list of instructions. If canSet is true expressions like "x = y" are also accepted.

func CompileAST

func CompileAST(lookup evalLookup, t ast.Expr) ([]Op, error)

CompileAST compiles the expression t into a list of instructions.

func CompileSet

func CompileSet(lookup evalLookup, lhexpr, rhexpr string) ([]Op, error)

CompileSet compiles the expression setting lhexpr to rhexpr into a list of instructions.

type PointerDeref

type PointerDeref struct {
	Node *ast.StarExpr
}

PointerDeref replaces the topmost stack variable v with *v.

type Pop

type Pop struct {
}

Pop removes the topmost variable from the stack.

type PushConst

type PushConst struct {
	Value constant.Value
}

PushConst pushes a constant on the stack.

type PushCurg

type PushCurg struct {
}

PushCurg pushes the current goroutine on the stack.

type PushFrameoff

type PushFrameoff struct {
}

PushFrameoff pushes the frame offset for the current frame on the stack.

type PushIdent

type PushIdent struct {
	Name string
}

PushIdent pushes a local or global variable or a predefined identifier (true, false, etc) or the value of a register on the stack.

type PushLen

type PushLen struct {
}

PushLen pushes the length of the variable at the top of the stack into the stack.

type PushLocal

type PushLocal struct {
	Name  string
	Frame int64
}

PushLocal pushes the local variable with the given name on the stack.

type PushNil

type PushNil struct {
}

PushNil pushes an untyped nil on the stack.

type PushPackageVarOrSelect

type PushPackageVarOrSelect struct {
	Name, Sel    string
	NameIsString bool
}

PushPackageVarOrSelect pushes the value of Name.Sel on the stack, which could either be a global variable (with the package name specified), or a field of a local variable.

type PushRangeParentOffset

type PushRangeParentOffset struct {
}

PushRangeParentOffset pushes the frame offset of the range-over-func closure body parent.

type PushThreadID

type PushThreadID struct {
}

PushThreadID pushes the ID of the current thread on the stack.

type Reslice

type Reslice struct {
	HasHigh  bool
	TrustLen bool
	Node     *ast.SliceExpr
}

Reslice implements a reslice operation. If HasHigh is set it pops three variables, low, high and v, and pushes v[low:high]. Otherwise it pops two variables, low and v, and pushes v[low:]. If TrustLen is set when the variable resulting from the reslice is loaded it will be fully loaded.

type Select

type Select struct {
	Name string
}

Select replaces the topmost stack variable v with v.Name.

type SetValue

type SetValue struct {
	Rhe ast.Expr
	// contains filtered or unexported fields
}

SetValue pops to variables from the stack, lhv and rhv, and sets lhv to rhv.

type TypeAssert

type TypeAssert struct {
	DwarfType godwarf.Type
	Node      *ast.TypeAssertExpr
}

TypeAssert replaces the topmost stack variable v with v.(DwarfType).

type TypeCast

type TypeCast struct {
	DwarfType godwarf.Type
	Node      *ast.CallExpr
}

TypeCast replaces the topmost stack variable v with (DwarfType)(v).

type Unary

type Unary struct {
	Node *ast.UnaryExpr
}

Unary applies the given unary operator to the topmost stack variable.

Jump to

Keyboard shortcuts

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