evalop

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 13 Imported by: 1

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 CallInjectionAllocString

type CallInjectionAllocString struct {
	Phase int
}

CallInjectionAllocString uses the call injection protocol to allocate the value of a string literal somewhere on the target's memory so that it can be assigned to a variable (or passed to a function). There are three phases to CallInjectionAllocString, distinguished by the Phase field. They must always appear in sequence in the program:

CallInjectionAllocString{Phase: 0}
CallInjectionAllocString{Phase: 1}
CallInjectionAllocString{Phase: 2}

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 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
)

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 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 PushPackageVar

type PushPackageVar struct {
	PkgName, Name string // if PkgName == "" use current function's package
}

PushPackageVar pushes a package variable on the stack.

type PushRegister

type PushRegister struct {
	Regnum  int
	Regname string
}

PushRegister pushes the CPU register Regnum on the stack.

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