expression

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ExtendedOpcodeFC = Opcode(0xfc)

Variables

View Source
var InstrToOpcode = map[string]Opcode{}/* 177 elements not displayed */

Functions

func ModifyAllFunctionIndexes

func ModifyAllFunctionIndexes(exp []*Expression, m map[int]int)

func ModifyAllGlobalIndexes

func ModifyAllGlobalIndexes(exp []*Expression, m map[int]int)

*

  • Modify (remap) some GlobalIndexes *

func ModifyUnresolvedFunctions

func ModifyUnresolvedFunctions(exp []*Expression, m map[string]string) error

func ResolveFunctions

func ResolveFunctions(exp []*Expression, wd WasmLookupContext) error

func ResolveGlobals

func ResolveGlobals(exp []*Expression, wd WasmLookupContext) error

Types

type Expression

type Expression struct {
	PC          uint64 // Program Counter (This is the byte offset into the Code section)
	PCNext      uint64
	Opcode      Opcode // Main opcode
	OpcodeExt   int
	I32Value    int32
	I64Value    int64
	F32Value    float32
	F64Value    float64
	FuncIndex   int
	LocalIndex  int
	GlobalIndex int
	LabelIndex  int
	TypeIndex   int
	TableIndex  int
	Labels      []int
	Result      types.ValType
	MemAlign    int
	MemOffset   int

	// This is set if the instruction has as I32Value that needs resolving (offset)
	DataOffsetNeedsLinking bool

	// This is set if the instruction needs adjusting using a base memory pointer
	DataOffsetNeedsAdjusting bool
	// This is set if the instruction has an I32Value that needs resolving (length)
	DataLengthNeedsLinking bool
	I32DataId              string

	// This is set if the instruction refers to a GlobalIndex that needs resolving
	GlobalNeedsLinking bool
	GlobalId           string

	// This is set if the instruction refers to a FuncIndex that needs resolving
	FunctionNeedsLinking bool
	FunctionId           string
}

func AddExpressionEnd

func AddExpressionEnd(exp []*Expression, to string) ([]*Expression, error)

*

  • Add an expression to the end of some code *

func AddExpressionStart

func AddExpressionStart(exp []*Expression, to string) ([]*Expression, error)

*

  • Add an expression to the start of some code *

func ExpressionFromWat

func ExpressionFromWat(d string) ([]*Expression, error)

*

  • Create an Expression from some wat source. *

func InsertAfterRelocating

func InsertAfterRelocating(exp []*Expression, to string) ([]*Expression, error)

*

  • Insert an expression after any instructions that need relocation fixup (offset()) *

func NewExpression

func NewExpression(data []byte, pc uint64) ([]*Expression, int, error)

func (*Expression) DecodeWat

func (e *Expression) DecodeWat(s string, localNames map[string]int) error

func (*Expression) EncodeBinary

func (e *Expression) EncodeBinary(w io.Writer) error

func (*Expression) EncodeWat

func (e *Expression) EncodeWat(w io.Writer, prefix string, wd WasmDebugContext) error

func (*Expression) Equals

func (e *Expression) Equals(f *Expression) bool

Check if two expressions are equal.

func (*Expression) HasMemoryArgs

func (e *Expression) HasMemoryArgs() bool

Returns true if the expression has memory args.

func (*Expression) HasNoArgs

func (e *Expression) HasNoArgs() bool

Returns true if the opcode has no arguments (Simple single Opcode)

type Opcode

type Opcode byte

type WasmDebugContext

type WasmDebugContext interface {
	GetLineNumberInfo(pc uint64) string
	GetGlobalIdentifier(globalIdx int, defaultEmpty bool) string
	GetFunctionIdentifier(funcIdx int, defaultEmpty bool) string
	GetLocalVarName(pc uint64, localIdx int) string
}

type WasmLookupContext

type WasmLookupContext interface {
	LookupGlobalID(id string) int
	LookupFunctionID(id string) int
}

Jump to

Keyboard shortcuts

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