Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking PR for v0.2 release #79

Merged
merged 133 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
4e61e3f
chore: update AirScript examples
tohrnii Nov 15, 2022
016f0d0
Merge pull request #74 from tohrnii/remove-examples
tohrnii Nov 22, 2022
f315607
feat: add Sub operation
Fumuran Nov 22, 2022
2081706
add DS_Store to gitignore
tohrnii Nov 15, 2022
f3ffa21
refactor(examples): refactor bitwise air constraints to have currentl…
tohrnii Nov 15, 2022
1d5c670
test: add bitwise air constraints with currently supported syntax
tohrnii Nov 25, 2022
642fb60
fix: doc rendering issue
tohrnii Nov 23, 2022
6006070
Merge pull request #80 from Overcastan/sub-operation
tohrnii Nov 25, 2022
d522c69
Merge pull request #81 from 0xPolygonMiden/tohrnii-formatting-issue
tohrnii Nov 25, 2022
0e1908d
Merge pull request #58 from tohrnii/bitwise
grjte Nov 25, 2022
a3b95be
feat(parser): add support for parsing of constants
tohrnii Nov 4, 2022
5738f0a
test: add tests for parsing and lexing of constants
tohrnii Nov 4, 2022
35a7f43
feat(parser): add support for constant access in constraints
tohrnii Nov 13, 2022
2e43644
refactor: Refactor constant parsing
tohrnii Nov 29, 2022
57ae403
fix(codegen): add missing auxiliary constraint degrees
grjte Dec 2, 2022
1d81ed8
feat(ir,codegen): make trace reference more general
grjte Dec 2, 2022
342e049
refactor: minor cleanup
grjte Dec 2, 2022
c1b9bd0
test: add more tests for edge cases for const parsing
tohrnii Dec 1, 2022
b78fb70
Merge pull request #63 from tohrnii/constants
tohrnii Dec 3, 2022
7b814ef
feat(parser): add variables to AST
tohrnii Dec 4, 2022
39eefb8
feat(parser): add variables parsing rules to grammar
tohrnii Dec 4, 2022
d673473
test: add lexer tests for variable parsing
tohrnii Dec 4, 2022
1209905
docs: add repo link to mdbook
tohrnii Dec 3, 2022
e4e3a98
test: add parser tests for variable parsing
tohrnii Dec 4, 2022
fc0faf5
refactor(parser): refactor boundary and transition constraints sections
tohrnii Dec 5, 2022
3e77d31
Merge pull request #91 from 0xPolygonMiden/grjte-fix-aux-codegen
tohrnii Dec 5, 2022
c14eedf
Merge pull request #92 from 0xPolygonMiden/grjte-ir-trace-ref
tohrnii Dec 5, 2022
3a7824e
Merge pull request #93 from 0xPolygonMiden/docs
tohrnii Dec 5, 2022
e16f684
Merge pull request #96 from 0xPolygonMiden/grjte-fix-aux-codegen
bobbinth Dec 5, 2022
90588ab
test: refactor tests to use enum variants directly
tohrnii Dec 5, 2022
ccb5a6a
Merge pull request #65 from tohrnii/variable_parsing
tohrnii Dec 6, 2022
a89345b
feat(ir): add constants to IR
tohrnii Dec 4, 2022
85ee0ac
test: add const declaration tests for IR
tohrnii Dec 5, 2022
d798392
feat(ir): add constant handling for transition constraints
tohrnii Dec 5, 2022
face797
feat(ir): add vector access and matrix access validation
tohrnii Dec 5, 2022
0cd1cbc
test: add tests for vector and matrix access
tohrnii Dec 5, 2022
a8f60f1
refactor(ir): Refactor IR
tohrnii Dec 6, 2022
3658319
test: add const declaration tests for IR
tohrnii Dec 5, 2022
55cda2f
feat(codegen): Add codegen for const declarations
tohrnii Dec 5, 2022
6c680fb
feat(codegen): Add codegen for const usage in constraints
tohrnii Dec 5, 2022
1cd8e70
test: add integration tests for constants codegen
tohrnii Dec 5, 2022
ef2e7a7
Merge pull request #94 from 0xPolygonMiden/tohrnii-constants-ir
tohrnii Dec 8, 2022
b7b2f10
Merge pull request #95 from 0xPolygonMiden/tohrnii-constants-codegen
tohrnii Dec 8, 2022
72bb90e
refactor(parser): move constant declarations to top of file
tohrnii Dec 15, 2022
e2a2e7d
Merge pull request #103 from 0xPolygonMiden/tohrnii-constants-refactor
tohrnii Dec 20, 2022
e4df490
feat(parser): add support for trace col grouping to parser
tohrnii Dec 10, 2022
e528374
test: add trace col group tests and refactor old tests
tohrnii Dec 10, 2022
7b970b5
refactor(parser): refactor trace columns AST
tohrnii Dec 16, 2022
2209932
Merge pull request #101 from 0xPolygonMiden/tohrnii-col-grouping-parser
tohrnii Dec 22, 2022
e5e8d41
feat(parser): add accessors for BoundaryVariables and TransitionVaria…
tohrnii Dec 10, 2022
1d743a7
feat(ir): add support for variables to IR
tohrnii Dec 10, 2022
6fc0cf5
test: add tests for variables to IR
tohrnii Dec 10, 2022
b7e0acf
feat(codegen): Add codegen for variable usage in constraints
tohrnii Dec 10, 2022
678c234
test: add integration test for variables
tohrnii Dec 10, 2022
f087117
refactor(ir): Refactor IR
tohrnii Dec 14, 2022
b9dd537
Merge pull request #100 from 0xPolygonMiden/tohrnii-variables-ir-codegen
tohrnii Dec 22, 2022
5007221
test: add trace col group tests and refactor old tests
tohrnii Dec 10, 2022
c036551
refactor(parser): refactor trace columns AST
tohrnii Dec 16, 2022
0402835
feat(ir): add support for trace col groups to IR
tohrnii Dec 14, 2022
c13bb22
test: add tests for trace column groups to IR
tohrnii Dec 14, 2022
2fdc6f1
test: add integration test for trace column groups
tohrnii Dec 14, 2022
9ffc6ca
Merge pull request #102 from 0xPolygonMiden/tohrnii-col-grouping-ir
tohrnii Jan 6, 2023
5004365
refactor: rename transition constraints to integrity constraints
tohrnii Dec 20, 2022
73d5939
refactor(ir): refactor constraint graph
tohrnii Jan 10, 2023
41170e2
Merge pull request #105 from 0xPolygonMiden/tohrnii-transition-constr…
tohrnii Jan 14, 2023
35e520a
refactor: refactor ConstraintRoot struct
tohrnii Jan 13, 2023
3269063
Merge pull request #111 from 0xPolygonMiden/tohrnii-validity-constraints
grjte Jan 18, 2023
11806e3
feat: add main and aux columns access by index
Fumuran Jan 11, 2023
5bd64f8
feat: add tests for column access
Fumuran Jan 18, 2023
9fa1763
feat: improve code
Fumuran Jan 18, 2023
ef18179
Merge pull request #112 from 0xPolygonMiden/andrew-main-aux-index-access
grjte Jan 19, 2023
f8fc616
feat: add new crate with core AirScript structs/types
grjte Jan 19, 2023
6251dc9
refactor: switch to core structs
grjte Jan 19, 2023
93143a0
Merge pull request #116 from 0xPolygonMiden/grjte-refactor-shared-types
grjte Jan 22, 2023
a5812b7
refactor: replace row_offset with ConstraintDomain
grjte Jan 18, 2023
ccb90ba
Merge pull request #117 from 0xPolygonMiden/grjte-refactor-constraint…
grjte Jan 23, 2023
5f25642
chore: update string formatting for clippy
grjte Jan 25, 2023
cc7072d
Merge pull request #121 from 0xPolygonMiden/grjte-clippy-fixes
grjte Jan 25, 2023
0a46017
refactor: allow expressions as exponent for exp expressions
tohrnii Jan 25, 2023
a4de554
Merge pull request #120 from 0xPolygonMiden/tohrnii-refactor-exp
grjte Jan 27, 2023
9abb772
feat: move boundary constraints into the graph
grjte Jan 25, 2023
6447ee9
refactor: simplify insertions into the constraint graph
grjte Jan 25, 2023
c31968a
chore: update winterfell code generation
grjte Jan 25, 2023
3f44c8c
test: update tests for boundary constraint changes
grjte Jan 26, 2023
2141470
Merge pull request #126 from 0xPolygonMiden/grjte-refactor-graph
grjte Jan 31, 2023
65c30fa
feat(core): add list comprehension structures to air-script-core
tohrnii Jan 31, 2023
e17d5a0
feat(parser): add list comprehension parsing rules to grammar
tohrnii Jan 31, 2023
a3dd07c
feat(parser): add list comprehension support to parser
tohrnii Jan 31, 2023
b6f9dc3
test: add list comprehension lexer tests
tohrnii Jan 31, 2023
580e060
test: add list comprehension parser tests
tohrnii Jan 31, 2023
bcd389b
feat(core): add list folding structures to air-script-core
tohrnii Jan 31, 2023
b0b0c97
feat(parser): add list folding parsing rules to grammar
tohrnii Jan 31, 2023
08763f9
feat(parser): add list folding support to parser
tohrnii Jan 31, 2023
0d3b94e
test: add list folding lexer and parser tests
tohrnii Jan 31, 2023
42e2648
Merge pull request #119 from 0xPolygonMiden/tohrnii-list-comprehension
tohrnii Jan 31, 2023
5844e8d
Merge pull request #127 from 0xPolygonMiden/tohrnii-list-folding
tohrnii Feb 1, 2023
da6a45f
feat: add parsing of rand values section, add parser tests
Fumuran Jan 26, 2023
6075ea5
feat: code refactor and tests improvement
Fumuran Feb 1, 2023
6446fd2
Merge pull request #129 from 0xPolygonMiden/andrew-parse-random-values
grjte Feb 2, 2023
1c8675b
feat: add random values to the IR
Fumuran Jan 26, 2023
5cb4acc
feat: add intergation test
Fumuran Feb 2, 2023
8e31a6b
feat: refactoring
Fumuran Feb 3, 2023
a7eb8a3
feat: add indexed access to random values by custom name
Fumuran Feb 3, 2023
dcaf137
feat: naming improvements
Fumuran Feb 6, 2023
3e541d7
Merge pull request #134 from 0xPolygonMiden/andrew-ir-random-values
tohrnii Feb 7, 2023
9396f3f
chore: remove Neg operation
Fumuran Feb 9, 2023
25095be
Merge pull request #141 from 0xPolygonMiden/andrew-remove-neg-operation
tohrnii Feb 9, 2023
77e49db
feat: add additional checks
Fumuran Feb 6, 2023
3cbb82b
Merge pull request #137 from 0xPolygonMiden/andrew-random-values-checks
grjte Feb 13, 2023
de4eb94
fix: boundary constraint validation
grjte Feb 12, 2023
970fa67
test: update tests based on graph changes
grjte Feb 13, 2023
5137ab5
Merge pull request #144 from 0xPolygonMiden/grjte-ir-bc-validation
grjte Feb 14, 2023
712c4c1
fix: restore public input support
grjte Feb 14, 2023
0fc7ea1
Merge pull request #145 from 0xPolygonMiden/grjte-ir-pub-inputs
tohrnii Feb 14, 2023
9c83bad
fix: fix codegen for aux transition constraints that use main cols
tohrnii Feb 16, 2023
df1e3bb
Merge pull request #148 from 0xPolygonMiden/tohrnii-codegen-fix
tohrnii Feb 17, 2023
4b56e26
chore: clippy fix
grjte Feb 17, 2023
963d91c
test: split ir tests into modules
grjte Feb 17, 2023
e74af8a
Merge pull request #151 from 0xPolygonMiden/grjte-ir-refactor-tests
grjte Feb 20, 2023
b3115de
fix(codegen): remove redundant parens from generated code
tohrnii Feb 19, 2023
e2f4371
test: update variable tests and add for variables in bc
grjte Feb 17, 2023
703227a
refactor: refactor binary_op_to_string
tohrnii Feb 20, 2023
a5b0ef4
Merge pull request #155 from 0xPolygonMiden/tohrnii-paren-fix
tohrnii Feb 21, 2023
0b167b9
feat: add support for boundary variables
grjte Feb 21, 2023
b8641d9
Merge pull request #160 from 0xPolygonMiden/grjte-ir-bc-variables
grjte Feb 22, 2023
6828ca7
feat(docs): update README.md with info about new crates
tohrnii Feb 22, 2023
b1d44a8
refactor(ir, air-script): rename from_source to new
tohrnii Feb 22, 2023
2c1c9b8
docs: add README.md for air-script-core crate
tohrnii Feb 22, 2023
dde783d
docs: update README.md for parser crate
tohrnii Feb 22, 2023
51bcddc
chore: add changelog for v0.1 and v0.2
grjte Feb 22, 2023
d219423
docs: update docs to include v0.2 features
tohrnii Feb 22, 2023
001db39
Merge pull request #152 from 0xPolygonMiden/tohrnii-docs
tohrnii Feb 22, 2023
29a2d51
Merge pull request #161 from 0xPolygonMiden/grjte-v02-changelog
grjte Feb 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: AirScript book
on:
push:
branches:
- main
- next

jobs:
deploy:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# will have compiled files and executables
/target/

# Remove system config files generated by mac os
**/.DS_Store

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

## 0.2.0 (2023-02-22)

- Added support for named constants (scalars, vectors, and matrices).
- Added support for intermediate variables in `boundary_constraints` and `integrity_constraints` sections (scalars, vectors, and matrices).
- Added support for binding identifier names to groups of trace columns (in addition to single columns, which were already supported).
- Added the `$main` and `$aux` built-ins for accessing columns in the execution trace by index.
- [BREAKING] Replaced the `$rand` built-in for accessing random values with an explicit `random_values` declaration section, enabling use of a custom identifier for the random values array.
- Added support for binding identifiers to specific random values or groups of random values.
- Made significant changes to the IR, including:
- Moved the boundary constraints into the algebraic constraint graph.
- Made the trace reference more general to support additional trace segments in the future.
- Added analysis to differentiate between validity and transition constraints.
- Added the `Sub` operation and removed the `Neg` operation.
- [FIX] Fixed a bug in the Winterfell codegen output for auxiliary transition constraints.
- Improved the Winterfell codegen by consolidating code generation for boundary and transition constraints and removing redundant parentheses.

## 0.1.0 (2022-11-10)

- Initial release of AirScript, including a minimal but complete implementation of the AirScript compiler for an initial basic set of language features.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ The project is organized into several crates as follows:
| [Parser](parser) | Contains the parser for AirScript. The parser is used to parse the constraints written in AirScript into an AST. |
| [IR](ir) | Contains the IR for AirScript, `AirIR`. `AirIR` is initialized with an AirScript AST, which it converts to an internal representation that can be optimized and used to generate code in multiple target languages. |
| [Winterfell code generator](codegen/winterfell/) | Contains a code generator targeting the [Winterfell prover](https://github.com/novifinancial/winterfell) Rust library. The Winterfell code generator converts a provided AirScript `AirIR` into Rust code that represents the AIR as a new custom struct that implements Winterfell's `Air` trait. |
| [AirScript Core](air-script-core) | Exports commonly used constants and structs used by the other crates. |
| [AirScript](air-script) | Aggregates all components of the AirScript compiler into a single place and provides a CLI as an executable to transpile AIRs defined in AirScript to the specified target language. Also contains integration tests for AirScript. |

## References

Expand Down
14 changes: 14 additions & 0 deletions air-script-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "air-script-core"
version = "0.1.0"
description="Core types for the AirScript compiler"
authors = ["miden contributors"]
readme="README.md"
license = "MIT"
repository = "https://github.com/0xPolygonMiden/air-script"
categories = ["compilers", "cryptography"]
keywords = ["air", "stark", "zero-knowledge", "zkp"]
edition = "2021"
rust-version = "1.65"

[dependencies]
14 changes: 14 additions & 0 deletions air-script-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# AirScript Core

This crate contains the core components used by other crates in AirScript. These components include:

- Access structures defined in [VectorAccess and MatrixAccess](./access.rs) structs
- Constant structure defined in [Constant](./constant.rs) struct
- Expression set defined in [Expression](./expression.rs) enum
- Identifier structure defined in [Identifier](./identifier.rs) struct
- Trace Access structures defined in [NamedTraceAccess and IndexedTraceAccess](./trace.rs) structs
- Variable structure and Variable types defined in [variables.rs](./variable.rs)

## License

This project is [MIT licensed](../LICENSE).
80 changes: 80 additions & 0 deletions air-script-core/src/access.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
use super::Identifier;

/// [VectorAccess] is used to represent an element inside vector at the specified index.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Clone)]
pub struct VectorAccess {
name: Identifier,
idx: usize,
}

impl VectorAccess {
/// Creates a new [VectorAccess] instance with the specified identifier name and index.
pub fn new(name: Identifier, idx: usize) -> Self {
Self { name, idx }
}

/// Returns the name of the vector.
pub fn name(&self) -> &str {
self.name.name()
}

/// Returns the index of the vector access.
pub fn idx(&self) -> usize {
self.idx
}
}

/// [MatrixAccess] is used to represent an element inside a matrix at the specified row and column
/// indices.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Clone)]
pub struct MatrixAccess {
name: Identifier,
row_idx: usize,
col_idx: usize,
}

impl MatrixAccess {
/// Creates a new [MatrixAccess] instance with the specified identifier name and indices.
pub fn new(name: Identifier, row_idx: usize, col_idx: usize) -> Self {
Self {
name,
row_idx,
col_idx,
}
}

/// Returns the name of the matrix.
pub fn name(&self) -> &str {
self.name.name()
}

/// Returns the row index of the matrix access.
pub fn row_idx(&self) -> usize {
self.row_idx
}

/// Returns the column index of the matrix access.
pub fn col_idx(&self) -> usize {
self.col_idx
}
}

#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Range {
start: usize,
end: usize,
}

impl Range {
pub fn new(start: usize, end: usize) -> Self {
Self { start, end }
}

pub fn start(&self) -> usize {
self.start
}

pub fn end(&self) -> usize {
self.end
}
}
42 changes: 42 additions & 0 deletions air-script-core/src/constant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use super::Identifier;

// CONSTANTS
// ================================================================================================

/// Stores a constant's name and value. There are three types of constants:
/// - Scalar: 123
/// - Vector: \[1, 2, 3\]
/// - Matrix: \[\[1, 2, 3\], \[4, 5, 6\]\]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Constant {
name: Identifier,
value: ConstantType,
}

impl Constant {
/// Returns a new instance of a [Constant]
pub fn new(name: Identifier, value: ConstantType) -> Self {
Self { name, value }
}

/// Returns the name of the [Constant]
pub fn name(&self) -> &Identifier {
&self.name
}

/// Returns the value of the [Constant]
pub fn value(&self) -> &ConstantType {
&self.value
}
}

/// Type of constant. Constants can be of 3 types:
/// - Scalar: 123
/// - Vector: \[1, 2, 3\]
/// - Matrix: \[\[1, 2, 3\], \[4, 5, 6\]\]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ConstantType {
Scalar(u64),
Vector(Vec<u64>),
Matrix(Vec<Vec<u64>>),
}
33 changes: 33 additions & 0 deletions air-script-core/src/expression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use super::{
Identifier, IndexedTraceAccess, ListComprehension, MatrixAccess, NamedTraceAccess, VectorAccess,
};

/// Arithmetic expressions for evaluation of constraints.
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum Expression {
Const(u64),
/// Represents any named constant or variable.
Elem(Identifier),
/// Represents an element inside a constant or variable vector. [VectorAccess] contains the
/// name of the vector and the index of the element to access.
VectorAccess(VectorAccess),
/// Represents an element inside a constant or variable matrix. [MatrixAccess] contains the
/// name of the matrix and indices of the element to access.
MatrixAccess(MatrixAccess),
IndexedTraceAccess(IndexedTraceAccess),
NamedTraceAccess(NamedTraceAccess),
/// Represents a random value provided by the verifier. The first inner value is the name of
/// the random values array and the second is the index of this random value in that array
Rand(Identifier, usize),
Add(Box<Expression>, Box<Expression>),
Sub(Box<Expression>, Box<Expression>),
Mul(Box<Expression>, Box<Expression>),
Exp(Box<Expression>, Box<Expression>),
ListFolding(ListFoldingType),
}

#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ListFoldingType {
Sum(ListComprehension),
Prod(ListComprehension),
}
18 changes: 18 additions & 0 deletions air-script-core/src/identifier.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::fmt;

/// [Identifier] is used to represent variable names.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Clone)]
pub struct Identifier(pub String);

impl Identifier {
/// Returns the name of the identifier.
pub fn name(&self) -> &str {
&self.0
}
}

impl fmt::Display for Identifier {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", &self.0)
}
}
17 changes: 17 additions & 0 deletions air-script-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
mod access;
pub use access::{MatrixAccess, Range, VectorAccess};

mod constant;
pub use constant::{Constant, ConstantType};

mod expression;
pub use expression::{Expression, ListFoldingType};

mod identifier;
pub use identifier::Identifier;

mod trace;
pub use trace::{IndexedTraceAccess, NamedTraceAccess, TraceSegment};

mod variable;
pub use variable::{Iterable, ListComprehension, Variable, VariableType};
76 changes: 76 additions & 0 deletions air-script-core/src/trace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
use super::Identifier;

// TYPES
// ================================================================================================
pub type TraceSegment = u8;

/// [IndexedTraceAccess] is used to represent accessing an element in the execution trace during
/// constraint evaluation. The trace_segment specifies
/// how many trace commitments have preceded the specified segment. `col_idx` specifies the index
/// of the column within that trace segment, and `row_offset` specifies the offset from the current
/// row. For example, an element in the "next" row of the "main" trace would be specified by
/// a trace_segment of 0 and a row_offset of 1.
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub struct IndexedTraceAccess {
trace_segment: TraceSegment,
col_idx: usize,
row_offset: usize,
}

impl IndexedTraceAccess {
pub fn new(trace_segment: TraceSegment, col_idx: usize, row_offset: usize) -> Self {
Self {
trace_segment,
col_idx,
row_offset,
}
}

/// Gets the trace segment of this [IndexedTraceAccess].
pub fn trace_segment(&self) -> TraceSegment {
self.trace_segment
}

/// Gets the column index of this [IndexedTraceAccess].
pub fn col_idx(&self) -> usize {
self.col_idx
}

/// Gets the row offset of this [IndexedTraceAccess].
pub fn row_offset(&self) -> usize {
self.row_offset
}
}

/// [NamedTraceAccess] is used to indicate a column in the trace by specifying its index within a
/// set of trace columns with the given identifier. If the identifier refers to a single column
/// then the index is always zero.
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct NamedTraceAccess {
name: Identifier,
idx: usize,
row_offset: usize,
}

impl NamedTraceAccess {
pub fn new(name: Identifier, idx: usize, row_offset: usize) -> Self {
Self {
name,
idx,
row_offset,
}
}

pub fn name(&self) -> &str {
self.name.name()
}

pub fn idx(&self) -> usize {
self.idx
}

/// Gets the row offset of this [NamedTraceAccess].
pub fn row_offset(&self) -> usize {
self.row_offset
}
}
Loading