Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
- func Column2String[F fmt.Stringer](col Column[F]) string
- func Module2String[F fmt.Stringer](module Module[F]) string
- func NumberOfColumns[F any](tr Trace[F]) uint
- func QualifiedColumnName(module ModuleName, column string) string
- type ArrayColumn
- type ArrayModule
- func (p ArrayModule[W]) Column(id uint) Column[W]
- func (p ArrayModule[W]) ColumnOf(name string) Column[W]
- func (p *ArrayModule[W]) FillColumn(cid uint, data array.MutArray[W]) bool
- func (p ArrayModule[W]) FindLast(keys ...W) uint
- func (p ArrayModule[W]) Height() uint
- func (p ArrayModule[W]) Keys() uint
- func (p ArrayModule[W]) Name() ModuleName
- func (p *ArrayModule[W]) Pad(front uint, back uint)
- func (p *ArrayModule[W]) Resize()
- func (p *ArrayModule[W]) String() string
- func (p ArrayModule[W]) Width() uint
- type ArrayTrace
- func (p *ArrayTrace[W]) Builder() array.Builder[W]
- func (p *ArrayTrace[W]) Column(cref ColumnRef) Column[W]
- func (p *ArrayTrace[W]) HasModule(module ModuleName) (uint, bool)
- func (p *ArrayTrace[W]) Module(module uint) Module[W]
- func (p *ArrayTrace[W]) Modules() iter.Iterator[Module[W]]
- func (p *ArrayTrace[W]) Pad(module uint, front uint, back uint)
- func (p *ArrayTrace[W]) RawModule(module uint) *ArrayModule[W]
- func (p *ArrayTrace[W]) String() string
- func (p *ArrayTrace[W]) Width() uint
- type CellRef
- type Column
- type ColumnAccessId
- func (p ColumnAccessId) BitWidth() uint
- func (p ColumnAccessId) Cmp(o ColumnAccessId) int
- func (p ColumnAccessId) Id() ColumnId
- func (p ColumnAccessId) Mask(mask uint) ColumnAccessId
- func (p ColumnAccessId) MaskWidth() uint
- func (p ColumnAccessId) RelativeShift() int
- func (p ColumnAccessId) Shift(shift int) ColumnAccessId
- func (p ColumnAccessId) Unwrap() uint
- type ColumnId
- func (p ColumnId) AccessOf(bitwidth uint) ColumnAccessId
- func (p ColumnId) Cmp(o ColumnId) int
- func (p *ColumnId) GobDecode(data []byte) error
- func (p ColumnId) GobEncode() (data []byte, err error)
- func (p ColumnId) Id() ColumnId
- func (p ColumnId) IsUsed() bool
- func (p ColumnId) String() string
- func (p ColumnId) Unwrap() uint
- type ColumnRef
- func (p ColumnRef) Cmp(q ColumnRef) int
- func (p ColumnRef) Column() ColumnId
- func (p *ColumnRef) GobDecode(data []byte) error
- func (p ColumnRef) GobEncode() (data []byte, err error)
- func (p ColumnRef) Index(nModules uint) uint
- func (p ColumnRef) Module() ModuleId
- func (p ColumnRef) Register() ColumnId
- type Module
- type ModuleId
- type ModuleName
- type Trace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Column2String ¶
Column2String returns a string representation of a column which is primiarily useful for debugging.
func Module2String ¶
Module2String returns a string representation of a module which is primiarily useful for debugging.
func NumberOfColumns ¶
NumberOfColumns returns the total number of all columns in the given trace.
func QualifiedColumnName ¶
func QualifiedColumnName(module ModuleName, column string) string
QualifiedColumnName returns the fully qualified name of a given column.
Types ¶
type ArrayColumn ¶
type ArrayColumn[T any] struct { // contains filtered or unexported fields }
ArrayColumn describes an individual column of data within a trace table.
func NewArrayColumn ¶
NewArrayColumn constructs a with the give name, data and padding. The given data is permitted to be nil, and this is used to signal a computed column.
func (*ArrayColumn[W]) Data ¶
func (p *ArrayColumn[W]) Data() array.Array[W]
Data provides access to the underlying data of this column
func (*ArrayColumn[W]) Get ¶
func (p *ArrayColumn[W]) Get(row int) W
Get the value at a given row in this column. If the row is out-of-bounds, then the column's padding value is returned instead. Thus, this function always succeeds.
func (*ArrayColumn[W]) Height ¶
func (p *ArrayColumn[W]) Height() uint
Height determines the height of this column.
func (*ArrayColumn[W]) Name ¶
func (p *ArrayColumn[W]) Name() string
Name returns the name of the given column.
func (*ArrayColumn[W]) Padding ¶
func (p *ArrayColumn[W]) Padding() W
Padding returns the value which will be used for padding this column.
func (*ArrayColumn[W]) String ¶
func (p *ArrayColumn[W]) String() string
type ArrayModule ¶
ArrayModule describes an individual module within a trace.
func NewArrayModule ¶
func NewArrayModule[W word.Word[W]](name ModuleName, keys uint, columns []ArrayColumn[W]) ArrayModule[W]
NewArrayModule constructs a module with the given name and an (as yet) unspecified height.
func (ArrayModule[W]) Column ¶
func (p ArrayModule[W]) Column(id uint) Column[W]
Column returns a specific column within this trace module.
func (ArrayModule[W]) ColumnOf ¶
func (p ArrayModule[W]) ColumnOf(name string) Column[W]
ColumnOf returns a specific column within this trace module.
func (*ArrayModule[W]) FillColumn ¶
func (p *ArrayModule[W]) FillColumn(cid uint, data array.MutArray[W]) bool
FillColumn sets the data and padding for the given column. This will panic if the data is already set. Also, if the module height is updated then this returns true to signal a height recalculation is required.
func (ArrayModule[W]) FindLast ¶
func (p ArrayModule[W]) FindLast(keys ...W) uint
FindLast implementation for the trace.Module interface.
func (ArrayModule[W]) Height ¶
func (p ArrayModule[W]) Height() uint
Height returns the height of this module, meaning the number of assigned rows.
func (ArrayModule[W]) Keys ¶
func (p ArrayModule[W]) Keys() uint
Keys implementation for the trace.Module interface.
func (ArrayModule[W]) Name ¶
func (p ArrayModule[W]) Name() ModuleName
Name returns the name of this module.
func (*ArrayModule[W]) Pad ¶
func (p *ArrayModule[W]) Pad(front uint, back uint)
Pad prepends (front) and appends (back) all columns in this module with a given number of padding rows.
func (*ArrayModule[W]) Resize ¶
func (p *ArrayModule[W]) Resize()
Resize the height of this module on the assumption it has been reset whilst filling a column (as above). This will panic if either: the module height was not previously reset; or, if the column heights are inconsistent.
func (*ArrayModule[W]) String ¶
func (p *ArrayModule[W]) String() string
func (ArrayModule[W]) Width ¶
func (p ArrayModule[W]) Width() uint
Width returns the number of columns in this module.
type ArrayTrace ¶
ArrayTrace provides an implementation of Trace which stores columns as an array.
func NewArrayTrace ¶
func NewArrayTrace[W word.Word[W]](builder array.Builder[W], modules []ArrayModule[W]) *ArrayTrace[W]
NewArrayTrace constructs a trace from a given set of indexed modules and columns.
func (*ArrayTrace[W]) Builder ¶
func (p *ArrayTrace[W]) Builder() array.Builder[W]
Builder implementation for Trace interface.
func (*ArrayTrace[W]) Column ¶
func (p *ArrayTrace[W]) Column(cref ColumnRef) Column[W]
Column accesses a given column directly via a reference.
func (*ArrayTrace[W]) HasModule ¶
func (p *ArrayTrace[W]) HasModule(module ModuleName) (uint, bool)
HasModule determines whether this trace has a module with the given name and, if so, what its module index is.
func (*ArrayTrace[W]) Module ¶
func (p *ArrayTrace[W]) Module(module uint) Module[W]
Module returns a specific module in this trace.
func (*ArrayTrace[W]) Modules ¶
func (p *ArrayTrace[W]) Modules() iter.Iterator[Module[W]]
Modules returns an iterator over the modules in this trace.
func (*ArrayTrace[W]) Pad ¶
func (p *ArrayTrace[W]) Pad(module uint, front uint, back uint)
Pad prepends (front) and appends (back) a given module with a given number of padding rows.
func (*ArrayTrace[W]) RawModule ¶
func (p *ArrayTrace[W]) RawModule(module uint) *ArrayModule[W]
RawModule returns a specific module in this trace.
func (*ArrayTrace[W]) String ¶
func (p *ArrayTrace[W]) String() string
func (*ArrayTrace[W]) Width ¶
func (p *ArrayTrace[W]) Width() uint
Width returns number of columns in this trace.
type CellRef ¶
type CellRef struct {
// Column index for the cell
Column ColumnRef
// Row index for the cell
Row int
}
CellRef identifies a unique cell within a given table.
func NewCellRef ¶
NewCellRef constructs a new cell reference.
type Column ¶
type Column[T any] interface { // Holds the name of this column Name() string // Get the value at a given row in this column. If the row is // out-of-bounds, then the column's padding value is returned instead. // Thus, this function always succeeds. Get(row int) T // Access the underlying data array for this column. This is useful in // situations where we want to clone the entire column, etc. Data() array.Array[T] // Padding returns the value which will be used for padding this column. Padding() T }
Column describes an individual column of data within a trace table.
type ColumnAccessId ¶
type ColumnAccessId struct {
// contains filtered or unexported fields
}
ColumnAccessId is a wrapper around a column Id which adds a "relative shift" and a "bitwidth access". That is, it identifies a column on a relative row from the given row. It also enables direct column casting.
func (ColumnAccessId) BitWidth ¶
func (p ColumnAccessId) BitWidth() uint
BitWidth returns the declared bitwidth of the variable being accessed. Observe that the actual width of this access may be smaller than this if a mask is being applied.
func (ColumnAccessId) Cmp ¶
func (p ColumnAccessId) Cmp(o ColumnAccessId) int
Cmp implementation for the Comparable interface
func (ColumnAccessId) Id ¶
func (p ColumnAccessId) Id() ColumnId
Id returns returns the underlying register id.
func (ColumnAccessId) Mask ¶
func (p ColumnAccessId) Mask(mask uint) ColumnAccessId
Mask masks the given column access by a given number of bits.
func (ColumnAccessId) MaskWidth ¶
func (p ColumnAccessId) MaskWidth() uint
MaskWidth returns the portion of the underlying column / register actually read by this access. For example, given a register of type u16 we might only be accessing the first u8 portion.
func (ColumnAccessId) RelativeShift ¶
func (p ColumnAccessId) RelativeShift() int
RelativeShift returns the relative shift for this register.
func (ColumnAccessId) Shift ¶
func (p ColumnAccessId) Shift(shift int) ColumnAccessId
Shift shifts the given column access by a given (relative) amount.
func (ColumnAccessId) Unwrap ¶
func (p ColumnAccessId) Unwrap() uint
Unwrap returns the underlying Column index.
type ColumnId ¶
type ColumnId struct {
// contains filtered or unexported fields
}
ColumnId captures the notion of a column index. That is, for each module, every Column is allocated a given index starting from 0. The purpose of the wrapper is avoid confusion between uint values and things which are expected to identify Columns.
func NewColumnId ¶
NewColumnId constructs a new Column ID from a given raw index.
func NewUnusedColumnId ¶
func NewUnusedColumnId() ColumnId
NewUnusedColumnId constructs something akin to a null reference. This is used in some situations where we may (or may not) want to refer to a specific Column.
func (ColumnId) AccessOf ¶
func (p ColumnId) AccessOf(bitwidth uint) ColumnAccessId
AccessOf constructs a relative column identifier from this identifier by including a bitwidth and relative shift.
func (ColumnId) GobEncode ¶
GobEncode an option. This allows it to be marshalled into a binary form.
type ColumnRef ¶
type ColumnRef struct {
// contains filtered or unexported fields
}
ColumnRef abstracts a complete (i.e. global) Column identifier.
func NewColumnRef ¶
NewColumnRef constructs a new Column reference from the given module and Column identifiers.
func NewIndexedColumnRef ¶
NewIndexedColumnRef constructs a new Column reference from the given column index computed using Index() and the given width.
func (ColumnRef) Cmp ¶
Cmp implementation for the set.Comparable interface. This allows a CellRef to be used in an AnySortedSet.
func (ColumnRef) GobEncode ¶
GobEncode an option. This allows it to be marshalled into a binary form.
func (ColumnRef) Index ¶
Index returns a unique index for this column, assuming a given number of modules.
type Module ¶
type Module[T any] interface { // Module name Name() ModuleName // Access a given column in this module. Column(uint) Column[T] // Access a given column by its name. ColumnOf(string) Column[T] // Keys returns the number n of key columns in this module. Key columns are // always the first n columns in a module. Such columns have the property // that they can be used in conjunction with Find. Keys() uint // FindLast finds the last row with matching keys. If no such row exists, // this returns math.MaxUint. Otherwise, it returns the last (i.e. highest) // matching row. Furthermore, if too few or too many keys are provided then // this will panic. FindLast(...T) uint // Returns the number of columns in this module. Width() uint // Returns the height of this module. Height() uint }
Module describes a module within the trace. Every module is composed of some number of columns, and has a specific height.
func ModuleAdapter ¶
ModuleAdapter provides a generic mechanism for making a trace module in one field look like a trace module in another field. Whether or not this is safe to do depends upon the fields in question, and is the caller's responsibility.
type ModuleName ¶
type ModuleName struct {
// Name of the module (excluding multiplier)
Name string
// Multiplier for the module
Multiplier uint
}
ModuleName abstracts the notion of a module name, since this is made up of two distinct components.
func ParseModuleName ¶
func ParseModuleName(name string) ModuleName
ParseModuleName parses a string formatted as a module name into a ModuleName structure. This will panic if the string is malformed.
func (ModuleName) String ¶
func (p ModuleName) String() string
type Trace ¶
type Trace[F any] interface { // Provides agnostic mechanism for constructing arrays Builder() array.Builder[F] // Access a given column difrtly via a reference. Column(ColumnRef) Column[F] // Determine whether this trace has a module with the given name and, if so, // what its module index is. HasModule(name ModuleName) (uint, bool) // Access a given module in this trace. Module(ModuleId) Module[F] // Returns an iterator over the contained modules Modules() iter.Iterator[Module[F]] // Returns the number of modules in this trace. Width() uint }
Trace describes a set of named columns. Columns are not required to have the same height and can be either "data" columns or "computed" columns.