Skip to content

Commit 917e0fb

Browse files
committed
lang: mv ConstantValue to a dedicated file
1 parent 690127a commit 917e0fb

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use std::fmt;
2+
3+
use crate::Label;
4+
5+
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6+
pub enum ConstantValue {
7+
Scalar(usize),
8+
PublicInputStart,
9+
PointerToZeroVector, // In the memory of chunks of 8 field elements
10+
FunctionSize { function_name: Label },
11+
Label(Label),
12+
}
13+
14+
impl fmt::Display for ConstantValue {
15+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16+
match self {
17+
Self::Scalar(scalar) => write!(f, "{scalar}"),
18+
Self::PublicInputStart => write!(f, "@public_input_start"),
19+
Self::PointerToZeroVector => write!(f, "@pointer_to_zero_vector"),
20+
Self::FunctionSize { function_name } => {
21+
write!(f, "@function_size_{function_name}")
22+
}
23+
Self::Label(label) => write!(f, "{label}"),
24+
}
25+
}
26+
}

crates/leanVm/src/lang/mod.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,18 @@ use crate::{
77
bytecode::precompiles::Precompile,
88
constant::F,
99
intermediate_bytecode::HighLevelOperation,
10-
lang::{boolean::Boolean, simple_expr::SimpleExpr},
10+
lang::{boolean::Boolean, constant_value::ConstantValue, simple_expr::SimpleExpr},
1111
};
1212

1313
pub mod boolean;
14+
pub mod constant_value;
1415
pub mod function;
1516
pub mod program;
1617
pub mod simple_expr;
1718

1819
pub type Var = String;
1920
pub type ConstMallocLabel = usize;
2021

21-
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
22-
pub enum ConstantValue {
23-
Scalar(usize),
24-
PublicInputStart,
25-
PointerToZeroVector, // In the memory of chunks of 8 field elements
26-
FunctionSize { function_name: Label },
27-
Label(Label),
28-
}
29-
3022
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3123
pub enum ConstExpression {
3224
Value(ConstantValue),
@@ -392,20 +384,6 @@ impl Line {
392384
}
393385
}
394386

395-
impl fmt::Display for ConstantValue {
396-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
397-
match self {
398-
Self::Scalar(scalar) => write!(f, "{scalar}"),
399-
Self::PublicInputStart => write!(f, "@public_input_start"),
400-
Self::PointerToZeroVector => write!(f, "@pointer_to_zero_vector"),
401-
Self::FunctionSize { function_name } => {
402-
write!(f, "@function_size_{function_name}")
403-
}
404-
Self::Label(label) => write!(f, "{label}"),
405-
}
406-
}
407-
}
408-
409387
impl fmt::Display for ConstExpression {
410388
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
411389
match self {

0 commit comments

Comments
 (0)