bbq

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodePrinter

type CodePrinter[T, E any] func(
	builder *strings.Builder,
	code []E,
	resolve bool,
	constants []constant.DecodedConstant,
	types []T,
	functionNames []string,
	colorize bool,
) error

type Contract

type Contract struct {
	Name     string
	Location common.Location
}

type ContractGlobal added in v1.8.0

type ContractGlobal struct {
	GlobalInfo
	Contract *Contract
}

func NewContractGlobal added in v1.8.0

func NewContractGlobal(
	memoryGauge common.MemoryGauge,
	name string,
	location common.Location,
	index uint16,
) *ContractGlobal

func (ContractGlobal) GetGlobalInfo added in v1.8.0

func (g ContractGlobal) GetGlobalInfo() GlobalInfo

type Function

type Function[E any] struct {
	Name               string
	QualifiedName      string
	Code               []E
	ParameterCount     uint16
	TypeParameterCount uint16
	LocalCount         uint16
	TypeIndex          uint16
	LineNumbers        LineNumberTable
}

func (Function[E]) IsAnonymous

func (f Function[E]) IsAnonymous() bool

func (Function[E]) IsNative

func (f Function[E]) IsNative() bool

type FunctionGlobal added in v1.8.0

type FunctionGlobal[E any] struct {
	GlobalInfo
	Function *Function[E]
}

func NewFunctionGlobal added in v1.8.0

func NewFunctionGlobal[E any](
	memoryGauge common.MemoryGauge,
	name string,
	location common.Location,
	index uint16,
) *FunctionGlobal[E]

func (FunctionGlobal[E]) GetGlobalInfo added in v1.8.0

func (g FunctionGlobal[E]) GetGlobalInfo() GlobalInfo

type Global added in v1.8.0

type Global interface {
	GetGlobalInfo() GlobalInfo
}

type GlobalInfo added in v1.8.0

type GlobalInfo struct {
	Name string
	// Need to maintain both "qualified" and "unqualified" names for a global,
	// because when type-aliasing is used, imported global name becomes qualified.
	// However, the same imported-global must use the unqualified name when linking.
	// TODO: We can simplify this by always using qualified names for all imports.
	QualifiedName string
	Location      common.Location
	Index         uint16
}

type GlobalKind added in v1.8.0

type GlobalKind int
const (
	GlobalKindFunction GlobalKind = iota
	GlobalKindVariable
	GlobalKindContract
	GlobalKindImported
)

type Import

type Import struct {
	Location common.Location
	Name     string
}

type ImportedGlobal added in v1.8.0

type ImportedGlobal struct {
	GlobalInfo
}

func NewImportedGlobal added in v1.8.0

func NewImportedGlobal(
	memoryGauge common.MemoryGauge,
	name string,
	qualifiedName string,
	location common.Location,
	index uint16,
) *ImportedGlobal

func (ImportedGlobal) GetGlobalInfo added in v1.8.0

func (g ImportedGlobal) GetGlobalInfo() GlobalInfo

type InstructionProgram

type InstructionProgram = Program[opcode.Instruction, StaticType]

type LineNumberTable

type LineNumberTable struct {
	Positions []PositionInfo
}

LineNumberTable holds the instruction-index to source-position mapping. It only maintains an entry for an instruction only if the position info got changed during that instruction. i.e: If multiple consecutive instructions were emitted for the same source-code position, then only the first instruction of that instruction-set would be available in the table.

func (*LineNumberTable) AddPositionInfo

func (t *LineNumberTable) AddPositionInfo(bytecodeIndex uint16, position Position)

func (*LineNumberTable) GetSourcePosition

func (t *LineNumberTable) GetSourcePosition(instructionIndex uint16) Position

type Position

type Position struct {
	StartPos ast.Position
	EndPos   ast.Position
}

func (Position) EndPosition

func (p Position) EndPosition(_ common.MemoryGauge) ast.Position

func (Position) StartPosition

func (p Position) StartPosition() ast.Position

type PositionInfo

type PositionInfo struct {
	InstructionIndex uint16
	Position         Position
}

type Program

type Program[E, T any] struct {
	Contracts []*Contract
	Imports   []Import
	Functions []Function[E]
	Constants []constant.DecodedConstant
	Variables []Variable[E]
	Types     []T
	Globals   []Global
}

type ProgramPrinter

type ProgramPrinter[E, T any] struct {
	// contains filtered or unexported fields
}

func NewBytecodeProgramPrinter

func NewBytecodeProgramPrinter(resolve bool, colorize bool, showFlow bool) *ProgramPrinter[byte, []byte]

func NewInstructionsProgramPrinter

func NewInstructionsProgramPrinter(resolve bool, colorize bool, showFlow bool) *ProgramPrinter[opcode.Instruction, StaticType]

func (*ProgramPrinter[E, T]) PrintProgram

func (p *ProgramPrinter[E, T]) PrintProgram(program *Program[E, T]) string

type StaticType

type StaticType = interpreter.StaticType

type TypeDecoder

type TypeDecoder[T any] func(bytes T) (StaticType, error)

type Variable

type Variable[E any] struct {
	Name   string
	Getter *Function[E]
}

type VariableGlobal added in v1.8.0

type VariableGlobal[E any] struct {
	GlobalInfo
	Variable *Variable[E]
}

func NewVariableGlobal added in v1.8.0

func NewVariableGlobal[E any](
	memoryGauge common.MemoryGauge,
	name string,
	location common.Location,
	index uint16,
) *VariableGlobal[E]

func (VariableGlobal[E]) GetGlobalInfo added in v1.8.0

func (g VariableGlobal[E]) GetGlobalInfo() GlobalInfo

Directories

Path Synopsis
gen command
vm

Jump to

Keyboard shortcuts

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