mesh

package
v0.0.0-...-0b552ba Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch Mesh

a Branch is a Mesh, but only has one path

type Mesh

type Mesh struct {
	Start MeshNode
	// Pathes is incremented on each merge
	Pathes uint64
	Nodes  []*MeshNode
	// IDcounter, increment on new MeshNode
	ID uint64
}

a Mesh connects Nodes, using one or more pathes

func (*Mesh) CreateNode

func (m *Mesh) CreateNode(nop bool) *MeshNode

CreateNode - Create a new node, but don't add it to the mesh

func (*Mesh) InsertTraceLogIntoMesh

func (m *Mesh) InsertTraceLogIntoMesh(tles []tracelog.TraceLogEntry, FirmwareOptions map[string]uint64) error

InsertTraceLogIntoMesh - Inserts a complete tracelog into the mesh It first creates a new branch and then merges the branch into the mesh using LCS Every created node on the branch gets assigned a FirmwareOptions slice On merge FirmwareOptions slices are also merged

func (*Mesh) LastNode

func (m *Mesh) LastNode() *MeshNode

LastNode - returns the last node in a mesh The last node is the last element of the likeliest path

func (m *Mesh) MergeMeshNodesAndUnlink(b *MeshNode, keep *MeshNode)

MergeMeshNodesAndUnlink - merge b into m

func (*Mesh) MeshNodeFromTraceLogEntry

func (m *Mesh) MeshNodeFromTraceLogEntry(tle tracelog.TraceLogEntry) (*MeshNode, error)

MeshNodeFromTraceLogEntry - Generate mesh node ftom tracelog entry

func (*Mesh) OptimiseMeshByAddingNops

func (m *Mesh) OptimiseMeshByAddingNops() error

OptimiseMeshByAddingNops - Try to insert nops to reduce the number of edges This leads to prettier code generation

func (*Mesh) OptimiseMeshByRemovingFirmwareOptions

func (m *Mesh) OptimiseMeshByRemovingFirmwareOptions(allFirmwareOptions map[string][]uint64) error

OptimiseMeshByRemovingFirmwareOptions - If a node has all options a FirmwareOption can have, remove it as it doesn't depend on the config

func (*Mesh) OptimiseMeshByRemovingNodes

func (m *Mesh) OptimiseMeshByRemovingNodes() error

OptimiseMeshByRemovingNodes - Try to remove duplicated nodes. The branch merging only working for all pathes below the branch point Start at the end of the mesh and merge duplicated nodes into one

func (*Mesh) WriteDot

func (m *Mesh) WriteDot(filename string) error

WriteDot - Convert mesh to dot and write it to file

type MeshNode

type MeshNode struct {
	// Id is incremented for each node added. It's unique in the mesh.
	Id uint64
	// Propability is incremented with each merged path if the node is part
	// of the merged path. By dividing it with Mesh.Pathes it gives the
	// propability
	Propability     uint64
	Next, Prev      []*MeshNode
	Hash            string
	TLE             tracelog.TraceLogEntry
	FirmwareOptions []map[string]uint64
	// a Noop meshnode doesn't generate code. It just makes the code generation prettier
	IsNoop bool
}

MeshNode - Describes a node in the Mesh

func (*MeshNode) AnyPathesContainNode

func (mn *MeshNode) AnyPathesContainNode(find *MeshNode) bool

AnyPathesContainNode - returns true if one of the pathes contains the meshnode to find

func (*MeshNode) CommonMergePoint

func (mn *MeshNode) CommonMergePoint() *MeshNode

CommonMergePoint - returns the merge point of all branches starting from this node

func (*MeshNode) FirstPath

func (mn *MeshNode) FirstPath() []*MeshNode

FirstPath - returns first path starting at the children of the given node

func (*MeshNode) LenFirstPath

func (mn *MeshNode) LenFirstPath() uint

LenFirstPath - Returns the length of the first path through the mesh

func (*MeshNode) NextPath

func (mn *MeshNode) NextPath(lastPath []*MeshNode) []*MeshNode

NextPath - returns the next path starting at the children of the given node. You have to pass the last path (returned by FirstPath or NextPath) as argument

func (*MeshNode) OptimiseNodeByRemovingFirmwareOptions

func (mn *MeshNode) OptimiseNodeByRemovingFirmwareOptions(allFirmwareOptions map[string][]uint64) error

OptimiseNodeByRemovingFirmwareOptions - If a node has all options a FirmwareOption can have, remove it as it doesn't depend on the config

Jump to

Keyboard shortcuts

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