gen

package
v0.0.0-...-47fd24d Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertArgumentsBetween

func AssertArgumentsBetween(
	info *InstructionInfo,
	atLeast int,
	atMost int,
) core.ResultList

func AssertArgumentsExactly

func AssertArgumentsExactly(
	info *InstructionInfo,
	count int,
) core.ResultList

func AssertAtLeastArguments

func AssertAtLeastArguments(
	info *InstructionInfo,
	atLeast int,
) core.ResultList

func AssertAtMostArguments

func AssertAtMostArguments(
	info *InstructionInfo,
	atMost int,
) core.ResultList

func AssertBigIntInSet

func AssertBigIntInSet(
	view *core.UnmanagedSourceView,
	bigInt *big.Int,
	options []int64,
) (int64, core.ResultList)

func AssertTargetsExactly

func AssertTargetsExactly(
	info *InstructionInfo,
	count int,
) core.ResultList

func NewRegisterTypeMismatchResult

func NewRegisterTypeMismatchResult(
	NewDeclaration core.UnmanagedSourceView,
	FirstDeclaration core.UnmanagedSourceView,
) core.ResultList

func NodeToSourceString

func NodeToSourceString(
	ctx *FileGenerationContext,
	node parse.Node,
) string

func UndefinedRegisterResult

func UndefinedRegisterResult(node parse.RegisterNode) core.ResultList

func ViewToSourceString

func ViewToSourceString(
	ctx *FileGenerationContext,
	view core.UnmanagedSourceView,
) string

Types

type ArgumentGenerator

type ArgumentGenerator struct {
	RegisterArgumentGenerator  InstructionContextGenerator[parse.RegisterNode, ArgumentInfo]
	ImmediateArgumentGenerator InstructionContextGenerator[parse.ImmediateNode, ArgumentInfo]
	LabelArgumentGenerator     InstructionContextGenerator[parse.LabelNode, ArgumentInfo]
	GlobalArgumentGenerator    InstructionContextGenerator[parse.GlobalNode, ArgumentInfo]
}

func (*ArgumentGenerator) Generate

type ArgumentInfo

type ArgumentInfo interface {
	// The location where the argument appears in the source code.
	Declaration() *core.UnmanagedSourceView

	// Returns the argument string, as it should appear in the code code.
	String() string
}

type BasicBlockInfo

type BasicBlockInfo struct {
	*FunctionInfo

	Label        *LabelInfo
	Instructions []*InstructionInfo

	ForwardEdges  []*BasicBlockInfo
	BackwardEdges []*BasicBlockInfo

	NextBlock *BasicBlockInfo
}

func NewEmptyBasicBlockInfo

func NewEmptyBasicBlockInfo(function *FunctionInfo) *BasicBlockInfo

func (*BasicBlockInfo) AppendBasicBlock

func (b *BasicBlockInfo) AppendBasicBlock(otherBlock *BasicBlockInfo)

func (*BasicBlockInfo) AppendForwardEdge

func (b *BasicBlockInfo) AppendForwardEdge(otherBlock *BasicBlockInfo)

func (*BasicBlockInfo) AppendInstruction

func (b *BasicBlockInfo) AppendInstruction(instruction *InstructionInfo)

func (*BasicBlockInfo) PrependInstruction

func (b *BasicBlockInfo) PrependInstruction(instruction *InstructionInfo)

func (*BasicBlockInfo) RemoveInstruction

func (b *BasicBlockInfo) RemoveInstruction(
	instruction *InstructionInfo,
) (ok bool)

func (*BasicBlockInfo) SetLabel

func (b *BasicBlockInfo) SetLabel(label *LabelInfo)

func (*BasicBlockInfo) Size

func (b *BasicBlockInfo) Size() int

Returns the number of instructions in the basic block.

func (*BasicBlockInfo) String

func (i *BasicBlockInfo) String() string

func (*BasicBlockInfo) Validate

func (b *BasicBlockInfo) Validate() core.ResultList

type BranchToLabelArguments

type BranchToLabelArguments struct{}

func (BranchToLabelArguments) PossibleNextSteps

func (BranchToLabelArguments) PossibleNextSteps(info *InstructionInfo) (StepInfo, core.ResultList)

type BranchesToLabelArgumentsOrContinues

type BranchesToLabelArgumentsOrContinues struct{}

func (BranchesToLabelArgumentsOrContinues) PossibleNextSteps

type DescriptorGenerator

type DescriptorGenerator struct{}

func (*DescriptorGenerator) Generate

type FileContextGenerator

type FileContextGenerator[NodeT parse.Node, InfoT any] interface {
	Generate(
		ctx *FileGenerationContext,
		node NodeT,
	) (info InfoT, results core.ResultList)
}

type FileGenerationContext

type FileGenerationContext struct {
	*GenerationContext

	// The source code of the file that we are currently processing.
	core.SourceContext

	// A type manager that contains all types defined in the file,
	// and that the compiler can use to create new types when in processes
	// new type definitions.
	Types TypeManager

	// A type manager that contains all declared and defines globals in the file.
	// This includes function definitions and "extern" declarations.
	Globals GlobalManager
}

func (*FileGenerationContext) NewFunctionGenerationContext

func (ctx *FileGenerationContext) NewFunctionGenerationContext() *FunctionGenerationContext

type FileGenerator

type FileGenerator struct {
	NamedTypeGenerator      FileContextGenerator[parse.TypeDeclarationNode, *NamedTypeInfo]
	FunctionGenerator       FileContextGenerator[parse.FunctionNode, *FunctionInfo]
	FunctionGlobalGenerator FileContextGenerator[parse.FunctionNode, GlobalInfo]
}

func NewFileGenerator

func NewFileGenerator() FileGenerator

func (*FileGenerator) Generate

func (g *FileGenerator) Generate(
	ctx *GenerationContext,
	source core.SourceContext,
	node parse.FileNode,
) (*FileInfo, core.ResultList)

type FileInfo

type FileInfo struct {
	Functions map[string]*FunctionInfo
}

func NewFileInfo

func NewFileInfo() *FileInfo

func (*FileInfo) AppendFunction

func (i *FileInfo) AppendFunction(function *FunctionInfo)

func (*FileInfo) GetFunction

func (i *FileInfo) GetFunction(name string) *FunctionInfo

GetFunction returns the function with the given name, or nil if it does not exist.

func (*FileInfo) String

func (i *FileInfo) String() string

func (*FileInfo) Validate

func (i *FileInfo) Validate() core.ResultList

type FunctionContextGenerator

type FunctionContextGenerator[NodeT parse.Node, InfoT any] interface {
	Generate(
		ctx *FunctionGenerationContext,
		node NodeT,
	) (info InfoT, results core.ResultList)
}

func NewLabelDefinitionGenerator

func NewLabelDefinitionGenerator() FunctionContextGenerator[
	parse.LabelNode,
	*LabelInfo,
]

type FunctionGenerationContext

type FunctionGenerationContext struct {
	*FileGenerationContext

	// A register manager, which contains all active registers in the function.
	// The compiler can query register information from the register manager
	// when it encounters registers while processing, and can create new register
	// information structures and pass them to the manager, which stores them.
	Registers RegisterManager

	// A label manager, which stores and manages all labels defined in a function.
	Labels LabelManager
}

type FunctionGenerationScheme

type FunctionGenerationScheme interface {
	NewJumpInstruction(label *LabelInfo) *InstructionInfo
}

type FunctionGlobalGenerator

type FunctionGlobalGenerator struct{}

func (*FunctionGlobalGenerator) Generate

type FunctionGlobalInfo

type FunctionGlobalInfo struct {
	*FunctionInfo
}

func (*FunctionGlobalInfo) Declaration

func (f *FunctionGlobalInfo) Declaration() *core.UnmanagedSourceView

func (*FunctionGlobalInfo) Name

func (f *FunctionGlobalInfo) Name() string

type FunctionInfo

type FunctionInfo struct {
	*FileInfo

	Name        string
	Declaration *core.UnmanagedSourceView

	EntryBlock *BasicBlockInfo
	Registers  RegisterManager
	Labels     LabelManager
	Parameters []*RegisterInfo
	Targets    []ReferencedTypeInfo
}

func (*FunctionInfo) CollectBasicBlocks

func (f *FunctionInfo) CollectBasicBlocks() []*BasicBlockInfo

func (*FunctionInfo) CollectInstructions

func (f *FunctionInfo) CollectInstructions() []*InstructionInfo

func (*FunctionInfo) IsDefined

func (f *FunctionInfo) IsDefined() bool

FunctionInfo can contain information about a function that is defined, or only declared that will be linked later.

This method returns true if the function is defined and has a function body, and false if it is only declared and has only the signature, parameters and targets defined.

func (*FunctionInfo) Size

func (f *FunctionInfo) Size() int

Returns the number of instructions in the function.

func (*FunctionInfo) String

func (i *FunctionInfo) String() string

func (*FunctionInfo) Validate

func (i *FunctionInfo) Validate() core.ResultList

type GenerationContext

type GenerationContext struct {
	ManagerCreators

	// An instruction (definition) manager, which contains all instruction
	// definitions that are supported in the current architecture (ISA).
	//
	// When processing a new instruction from the source code, the compiler
	// talks with the instruction manager, retrieves the relevant instruction
	// definition, and uses it to farther process the instruction.
	Instructions InstructionManager

	// The size of a pointer type in the current target architecture.
	//
	// TODO: I'm not sure that we need this information in this step of the
	//   compilation. Can we compile without it, and leave it to the ISA?
	PointerSize *big.Int
}

This structure is the most broad level of generation context. It contains information that is used in different parts of the compilation, and which are essential across the whole pipeline.

It mainly contains information about the compilation target.

func (*GenerationContext) NewFileGenerationContext

func (ctx *GenerationContext) NewFileGenerationContext(
	source core.SourceContext,
) *FileGenerationContext

type Generator

type Generator[NodeT parse.Node, InfoT any] interface {
	Generate(
		ctx *GenerationContext,
		node NodeT,
	) (info InfoT, results core.ResultList)
}

type GlobalArgumentGenerator

type GlobalArgumentGenerator struct{}

func (*GlobalArgumentGenerator) Generate

type GlobalArgumentInfo

type GlobalArgumentInfo struct {
	GlobalInfo
	// contains filtered or unexported fields
}

func (*GlobalArgumentInfo) Declaration

func (g *GlobalArgumentInfo) Declaration() *core.UnmanagedSourceView

func (*GlobalArgumentInfo) String

func (g *GlobalArgumentInfo) String() string

type GlobalInfo

type GlobalInfo interface {
	Name() string
	Declaration() *core.UnmanagedSourceView

	// IsDefined returns true if the global variable is defined in the current
	// file. If false, it means that the global is externally defined and
	// expected to be linked in a later stage.
	IsDefined() bool
}

func NewFunctionGlobalInfo

func NewFunctionGlobalInfo(functionInfo *FunctionInfo) GlobalInfo

type GlobalManager

type GlobalManager interface {
	GetGlobal(name string) GlobalInfo
	NewGlobal(GlobalInfo) core.ResultList
	GetAllGlobals() []GlobalInfo
}

func NewGlobalMap

func NewGlobalMap(*GenerationContext) GlobalManager

type GlobalMap

type GlobalMap map[string]GlobalInfo

func (*GlobalMap) GetAllGlobals

func (m *GlobalMap) GetAllGlobals() []GlobalInfo

func (*GlobalMap) GetGlobal

func (m *GlobalMap) GetGlobal(name string) GlobalInfo

func (*GlobalMap) NewGlobal

func (m *GlobalMap) NewGlobal(global GlobalInfo) core.ResultList

type ImmediateArgumentGenerator

type ImmediateArgumentGenerator struct {
	ReferencedTypeGenerator FileContextGenerator[parse.TypeNode, ReferencedTypeInfo]
}

func (*ImmediateArgumentGenerator) Generate

type ImmediateInfo

type ImmediateInfo struct {
	Type  ReferencedTypeInfo
	Value *big.Int // TODO: Add floating types
	// contains filtered or unexported fields
}

func (*ImmediateInfo) Declaration

func (i *ImmediateInfo) Declaration() *core.UnmanagedSourceView

func (*ImmediateInfo) String

func (i *ImmediateInfo) String() string

type InstructionContextGenerator

type InstructionContextGenerator[NodeT parse.Node, InfoT any] interface {
	Generate(
		ctx *InstructionGenerationContext,
		node NodeT,
	) (info InfoT, results core.ResultList)
}

type InstructionDefinition

type InstructionDefinition interface {
	// This method is usd by the USM engine to generate the internal control
	// flow graph representation.
	//
	// Should return a non-empty slice. If the instruction does not have any
	// consecutive steps in the function (for example, a return statement),
	// then a special dedicated return step should be returned.
	PossibleNextSteps(*InstructionInfo) (StepInfo, core.ResultList)

	// Returns the string that represents the operator of the instruction.
	// For example, for the add instruction this method would return "ADD".
	//
	// This is required because some instructions may be generated automatically,
	// and we want to be able to display them in a human-readable format.
	Operator(*InstructionInfo) string

	// Validate the instruction information structure, according to the
	// expected arguments, targets, and other related information.
	//
	// Instruction validation should as one of the last steps in the compilation
	// process, and you should be able to assume that all relevant information
	// in the structures is filled in and propagated correctly.
	Validate(*InstructionInfo) core.ResultList
}

type InstructionGenerationContext

type InstructionGenerationContext struct {
	*FunctionGenerationContext

	// A (partial) instruction info type for which we are currently working on
	// generating.
	InstructionInfo *InstructionInfo
}

type InstructionGenerator

type InstructionGenerator struct {
	ArgumentGenerator InstructionContextGenerator[parse.ArgumentNode, ArgumentInfo]
	TargetGenerator   FunctionContextGenerator[parse.TargetNode, *TargetInfo]
}

func (*InstructionGenerator) Generate

Convert an instruction parsed node into an instruction that is in the instruction set. If new registers are defined in the instruction (by assigning values to instruction targets), the register is created and added to the generation context.

type InstructionInfo

type InstructionInfo struct {
	*BasicBlockInfo

	// The targets of the instruction.
	// TODO: is a pointer reference really required here?
	Targets []*TargetInfo

	// The arguments of the instruction.
	Arguments []ArgumentInfo

	// The actual instruction information, which is ISA specific.
	Definition InstructionDefinition

	// The location in which the instruction was defined in the source code.
	// Can be nil if the instruction was defined internally, for example,
	// in an optimization.
	Declaration *core.UnmanagedSourceView
}

func NewEmptyInstructionInfo

func NewEmptyInstructionInfo(
	declaration *core.UnmanagedSourceView,
) *InstructionInfo

func (*InstructionInfo) AppendArgument

func (i *InstructionInfo) AppendArgument(arguments ...ArgumentInfo)

func (*InstructionInfo) AppendTarget

func (i *InstructionInfo) AppendTarget(targets ...*TargetInfo)

Appends the given register(s) as a target(s) of the instruction, including updating the required instruction and register information fields.

func (*InstructionInfo) SetInstruction

func (i *InstructionInfo) SetInstruction(instruction InstructionDefinition)

Updates the internal instruction instance to the provided one.

This can be used to update the instruction, but keep the same arguments and targets, for example, as an optimization to a more specific operation which accepts the same arguments in certain cases.

func (*InstructionInfo) String

func (i *InstructionInfo) String() string

func (*InstructionInfo) SwitchTarget

func (i *InstructionInfo) SwitchTarget(
	target *TargetInfo,
	newRegister *RegisterInfo,
)

func (*InstructionInfo) Validate

func (i *InstructionInfo) Validate() core.ResultList

type InstructionManager

type InstructionManager interface {
	// Get the instruction definition that corresponds to the provided name.
	//
	// Instruction node is for extra context, if needed, especially for
	// generating nice error messages.
	GetInstructionDefinition(
		name string,
		node *parse.InstructionNode,
	) (InstructionDefinition, core.ResultList)
}

func NewInstructionMap

func NewInstructionMap(
	definitions []faststringmap.MapEntry[InstructionDefinition],
	caseSensitive bool,
) InstructionManager

type InstructionMap

type InstructionMap struct {
	faststringmap.Map[InstructionDefinition]
	// contains filtered or unexported fields
}

func (*InstructionMap) GetInstructionDefinition

func (m *InstructionMap) GetInstructionDefinition(
	name string,
	node *parse.InstructionNode,
) (InstructionDefinition, core.ResultList)

type LabelArgumentGenerator

type LabelArgumentGenerator struct{}

func (*LabelArgumentGenerator) Generate

type LabelArgumentInfo

type LabelArgumentInfo struct {
	Label *LabelInfo
	// contains filtered or unexported fields
}

func NewLabelArgumentInfo

func NewLabelArgumentInfo(
	label *LabelInfo,
) *LabelArgumentInfo

func (*LabelArgumentInfo) Declaration

func (i *LabelArgumentInfo) Declaration() *core.UnmanagedSourceView

func (*LabelArgumentInfo) String

func (i *LabelArgumentInfo) String() string

type LabelDefinitionGenerator

type LabelDefinitionGenerator struct{}

Generator for label *definition* nodes.

Will create and add the label to the function context, and return an error if a label with the same name already exists.

func (*LabelDefinitionGenerator) Generate

type LabelInfo

type LabelInfo struct {
	// The name of the label, as it appears in the source code.
	Name string

	// The basic block to which the instruction points.
	BasicBlock *BasicBlockInfo

	// A view of the label declaration in the source code.
	// TODO: make this not required, since we may generate labels?
	Declaration core.UnmanagedSourceView
}

func ArgumentToLabel

func ArgumentToLabel(arg ArgumentInfo) (*LabelInfo, core.ResultList)

func ArgumentsToLabels

func ArgumentsToLabels(arguments []ArgumentInfo) []*LabelInfo

func (*LabelInfo) String

func (i *LabelInfo) String() string

type LabelManager

type LabelManager interface {
	// Get a information about a label from its name.
	GetLabel(name string) *LabelInfo

	// Create a new label, provided it's information.
	// This should register the label in the label manager database as a valid
	// label, and future queries should be able to find it.
	NewLabel(info *LabelInfo) core.ResultList

	// Generate a new label that will be used to identify an unlabelled block.
	// This should create a new label with a unique name, but it SHOULDN'T add
	// it to the labels database (does not call NewLabel).
	GenerateLabel() *LabelInfo
}

type LabelMap

type LabelMap map[string]*LabelInfo

LabelMap is a naive and default implementation of the LabelManger interface. It uses a simple go builtin map to store label information, using label names as keys.

func (*LabelMap) GenerateLabel

func (m *LabelMap) GenerateLabel() *LabelInfo

func (*LabelMap) GetLabel

func (m *LabelMap) GetLabel(name string) *LabelInfo

func (*LabelMap) NewLabel

func (m *LabelMap) NewLabel(label *LabelInfo) core.ResultList

type ManagerCreators

type ManagerCreators struct {
	RegisterManagerCreator func(*FileGenerationContext) RegisterManager
	LabelManagerCreator    func(*FileGenerationContext) LabelManager
	TypeManagerCreator     func(*GenerationContext) TypeManager
	GlobalManagerCreator   func(*GenerationContext) GlobalManager
}

type NamedTypeGenerator

type NamedTypeGenerator struct {
	ReferencedTypeGenerator FileContextGenerator[parse.TypeNode, ReferencedTypeInfo]
}

func (*NamedTypeGenerator) Generate

type NamedTypeInfo

type NamedTypeInfo struct {
	// The full name of the type, including the "$" prefix.
	Name string

	// The size of the type in bits.
	Size *big.Int

	// The source view of the type declaration.
	// Should be nil only if it is a builtin type.
	Declaration *core.UnmanagedSourceView
}

A named type is a type that can has a distinct name. It either (1) a builtin type or (2) a type alias declared by the "type" keyword.

func NewNamedTypeInfo

func NewNamedTypeInfo(
	name string,
	size *big.Int,
	declaration *core.UnmanagedSourceView,
) *NamedTypeInfo

func (NamedTypeInfo) String

func (n NamedTypeInfo) String() string

type NonBranchingInstruction

type NonBranchingInstruction struct{}

func (NonBranchingInstruction) PossibleNextSteps

type ParameterGenerator

type ParameterGenerator struct {
	ReferencedTypeGenerator FileContextGenerator[parse.TypeNode, ReferencedTypeInfo]
}

func (*ParameterGenerator) Generate

Asserts that a register with the same name does not exist yet, creates the new register, registers it to the register manager, and returns the unique register info structure pointer.

type ReferencedTypeGenerator

type ReferencedTypeGenerator struct {
	DescriptorGenerator FileContextGenerator[parse.TypeDecoratorNode, TypeDescriptorInfo]
}

func (*ReferencedTypeGenerator) Generate

type ReferencedTypeInfo

type ReferencedTypeInfo struct {
	// A pointer to the base, named type that this type reference refers to.
	Base        *NamedTypeInfo
	Descriptors []TypeDescriptorInfo

	Declaration *core.UnmanagedSourceView
}

A referenced type is a combination of a basic type with (possibly zero) type decorators that wrap it. For example, if `$32“ is a basic named type, then `$32 *`, which is a pointer to that type is a referenced type with the `$32` named type as it's base type, and the pointer as a decorator.

func ArgumentToType

func ArgumentToType(arg ArgumentInfo) (ReferencedTypeInfo, core.ResultList)

func ArgumentsToTypes

func ArgumentsToTypes(
	arguments []ArgumentInfo,
) ([]ReferencedTypeInfo, core.ResultList)

func TargetToType

func TargetToType(target *TargetInfo) ReferencedTypeInfo

func (ReferencedTypeInfo) Equal

func (info ReferencedTypeInfo) Equal(other ReferencedTypeInfo) bool

func (ReferencedTypeInfo) IsPure

func (t ReferencedTypeInfo) IsPure() bool

func (ReferencedTypeInfo) String

func (t ReferencedTypeInfo) String() string

type RegisterArgumentGenerator

type RegisterArgumentGenerator struct {
	RegisterGenerator FunctionContextGenerator[parse.RegisterNode, *RegisterInfo]
}

func (*RegisterArgumentGenerator) Generate

type RegisterArgumentInfo

type RegisterArgumentInfo struct {
	Register *RegisterInfo
	// contains filtered or unexported fields
}

func NewRegisterArgumentInfo

func NewRegisterArgumentInfo(register *RegisterInfo) *RegisterArgumentInfo

func (*RegisterArgumentInfo) Declaration

func (i *RegisterArgumentInfo) Declaration() *core.UnmanagedSourceView

func (*RegisterArgumentInfo) String

func (i *RegisterArgumentInfo) String() string

func (*RegisterArgumentInfo) SwitchRegister

func (i *RegisterArgumentInfo) SwitchRegister(newRegister *RegisterInfo)

Switch the argument to use a different register, instead of the current one.

type RegisterGenerator

type RegisterGenerator struct{}

Used to convert parse.RegisterNode instances to *existing* register instances. Returns an error on generation if the provided register node references a register that does not exist.

func (*RegisterGenerator) Generate

type RegisterInfo

type RegisterInfo struct {
	// The name of the register, as it appears in the source code.
	Name string

	// The type of the register.
	Type ReferencedTypeInfo

	// Instructions in which the register is a target, and is defined or
	// assigned a new value.
	//
	// Note: This list is not a complete representation of all locations in which
	// the register is defined, since it can be defined as a function parameter.
	Definitions []*InstructionInfo

	// Instructions in which the register appears as a source, i.e. as an
	// read only argument.
	Usages []*InstructionInfo

	// The first location in the source code in which the register is declared
	// or assigned a value.
	// TODO: make this not required, for generated registers.
	Declaration core.UnmanagedSourceView
}

func ArgumentsToRegisters

func ArgumentsToRegisters(
	arguments []ArgumentInfo,
) []*RegisterInfo

func NewRegisterInfo

func NewRegisterInfo(name string, typ ReferencedTypeInfo) *RegisterInfo

func TargetsToRegisters

func TargetsToRegisters(targets []*TargetInfo) []*RegisterInfo

func (*RegisterInfo) AddDefinition

func (i *RegisterInfo) AddDefinition(info *InstructionInfo)

func (*RegisterInfo) AddUsage

func (i *RegisterInfo) AddUsage(info *InstructionInfo)

func (*RegisterInfo) RemoveDefinition

func (i *RegisterInfo) RemoveDefinition(info *InstructionInfo)

func (*RegisterInfo) String

func (i *RegisterInfo) String() string

Return the string that represents the register, as it should appear in the source code.

type RegisterManager

type RegisterManager interface {
	// Returns register information by its name, or nil if the register is
	// not managed by this register manager.
	GetRegister(name string) *RegisterInfo

	// Adds a new register to the register manager.
	// The implementation can assume that the register is not already registered
	// (i.e. GetRegister(reg.Name) == nil).
	NewRegister(reg *RegisterInfo) core.ResultList

	// Deletes a register from the register manager.
	// The method should succeed even if the register is not found.
	DeleteRegister(reg *RegisterInfo) core.ResultList

	// Returns the number of currently registered registers.
	Size() int

	// Returns all of the currently registered registers, as a slice.
	GetAllRegisters() []*RegisterInfo
}

type ReturningInstruction

type ReturningInstruction struct{}

func (ReturningInstruction) PossibleNextSteps

type StepInfo

type StepInfo struct {
	// A list of all branches that the execution might jump to after the
	// execution of the instruction.
	PossibleBranches []*LabelInfo

	// True if it is possible that execution after this instruction should
	// continue to the next instruction in the function.
	PossibleContinue bool

	// True if it is possible that execution after this instruction should
	// terminate the function execution. This can be used for termination of
	// the entire program, or a return from a function.
	PossibleReturn bool
}

func (*StepInfo) DefinitelyContinue

func (p *StepInfo) DefinitelyContinue() bool

func (*StepInfo) DefinitelyReturn

func (p *StepInfo) DefinitelyReturn() bool

func (*StepInfo) IsBranchPossible

func (p *StepInfo) IsBranchPossible() bool

type TargetGenerator

type TargetGenerator struct {
	ReferencedTypeGenerator FileContextGenerator[parse.TypeNode, ReferencedTypeInfo]
}

func (*TargetGenerator) Generate

The target generator creates returns the register information that matches the provided target node.

If the targe node does not have an explicit type, and the register has not been defined and processed yet, the generator will return nil.

type TargetInfo

type TargetInfo struct {
	Register    *RegisterInfo
	Declaration *core.UnmanagedSourceView
}

func NewTargetInfo

func NewTargetInfo(register *RegisterInfo) TargetInfo

func (*TargetInfo) String

func (i *TargetInfo) String() string

type TypeDescriptorInfo

type TypeDescriptorInfo struct {
	Type   TypeDescriptorType
	Amount *big.Int
}

func (TypeDescriptorInfo) String

func (i TypeDescriptorInfo) String() string

type TypeDescriptorType

type TypeDescriptorType uint8
const (
	PointerTypeDescriptor TypeDescriptorType = iota
	RepeatTypeDescriptor
)

func (TypeDescriptorType) String

func (t TypeDescriptorType) String() string

type TypeManager

type TypeManager interface {
	// Query a already seen before type, and get the type information if it
	// exists. Returns nil if the if a type with the provided name has not yet
	// been defined.
	//
	// The implementation should also return information about builtin types,
	// although the creation of such types can be possibly done lazily.
	GetType(name string) *NamedTypeInfo

	// Register a new type with the provided name and type information.
	// The generator will call this method when it encounters a new type
	// definition.
	//
	// The implementation should raise an error if the new registered type is
	// invalid. It can however assume that the type name is unique and has not
	// been defined before (GetType() returned nil on it).
	NewType(typ *NamedTypeInfo) core.Result
}

Jump to

Keyboard shortcuts

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