Skip to content

Commit 73587fd

Browse files
committed
compiler: small function name changes
1 parent 2db6ecf commit 73587fd

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

crates/leanVm/src/intermediate_bytecode/intermediate_value.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl IntermediateValue {
2828
pub fn try_into_mem_or_fp(&self, compiler: &Compiler) -> Result<MemOrFp, String> {
2929
match self {
3030
Self::MemoryAfterFp { offset } => Ok(MemOrFp::MemoryAfterFp {
31-
offset: offset.eval_const_expression_usize(compiler),
31+
offset: offset.eval_usize(compiler),
3232
}),
3333
Self::Fp => Ok(MemOrFp::Fp),
3434
Self::Constant(_) => Err(format!("Cannot convert {self:?} to MemOrFp")),
@@ -41,7 +41,7 @@ impl IntermediateValue {
4141
}
4242
if let Self::MemoryAfterFp { offset } = self {
4343
return Ok(MemOrConstant::MemoryAfterFp {
44-
offset: offset.eval_const_expression_usize(compiler),
44+
offset: offset.eval_usize(compiler),
4545
});
4646
}
4747
Err(format!("Cannot convert {self:?} to MemOrConstant"))
@@ -50,7 +50,7 @@ impl IntermediateValue {
5050
#[must_use]
5151
pub fn try_as_constant(&self, compiler: &Compiler) -> Option<F> {
5252
if let Self::Constant(c) = self {
53-
Some(c.eval_const_expression(compiler))
53+
Some(c.eval(compiler))
5454
} else {
5555
None
5656
}

crates/leanVm/src/intermediate_bytecode/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ impl IntermediateBytecode {
7474
}
7575
if let IntermediateValue::MemoryAfterFp { offset } = value {
7676
return Some(MemOrConstant::MemoryAfterFp {
77-
offset: offset.eval_const_expression_usize(&compiler),
77+
offset: offset.eval_usize(&compiler),
7878
});
7979
}
8080
None
8181
};
8282

8383
let try_as_mem_or_fp = |value: &IntermediateValue| match value {
8484
IntermediateValue::MemoryAfterFp { offset } => Some(MemOrFp::MemoryAfterFp {
85-
offset: offset.eval_const_expression_usize(&compiler),
85+
offset: offset.eval_usize(&compiler),
8686
}),
8787
IntermediateValue::Fp => Some(MemOrFp::Fp),
8888
IntermediateValue::Constant(_) => None,
@@ -145,17 +145,17 @@ impl IntermediateBytecode {
145145
res,
146146
} => {
147147
low_level_bytecode.push(Instruction::Deref(DerefInstruction {
148-
shift_0: shift_0.eval_const_expression_usize(&compiler),
149-
shift_1: shift_1.eval_const_expression_usize(&compiler),
148+
shift_0: shift_0.eval_usize(&compiler),
149+
shift_1: shift_1.eval_usize(&compiler),
150150
res: match res {
151151
IntermediaryMemOrFpOrConstant::MemoryAfterFp { offset } => {
152152
MemOrFpOrConstant::MemoryAfterFp {
153-
offset: offset.eval_const_expression_usize(&compiler),
153+
offset: offset.eval_usize(&compiler),
154154
}
155155
}
156156
IntermediaryMemOrFpOrConstant::Fp => MemOrFpOrConstant::Fp,
157157
IntermediaryMemOrFpOrConstant::Constant(c) => {
158-
MemOrFpOrConstant::Constant(c.eval_const_expression(&compiler))
158+
MemOrFpOrConstant::Constant(c.eval(&compiler))
159159
}
160160
},
161161
}));
@@ -213,7 +213,7 @@ impl IntermediateBytecode {
213213
arg0: arg0.try_into_mem_or_constant(&compiler).unwrap(),
214214
arg1: arg1.try_into_mem_or_constant(&compiler).unwrap(),
215215
res: res.try_into_mem_or_fp(&compiler).unwrap(),
216-
size: size.eval_const_expression_usize(&compiler),
216+
size: size.eval_usize(&compiler),
217217
}));
218218
}
219219
IntermediateInstruction::MultilinearEval {
@@ -227,7 +227,7 @@ impl IntermediateBytecode {
227227
coeffs: coeffs.try_into_mem_or_constant(&compiler).unwrap(),
228228
point: point.try_into_mem_or_constant(&compiler).unwrap(),
229229
res: res.try_into_mem_or_fp(&compiler).unwrap(),
230-
n_vars: n_vars.eval_const_expression_usize(&compiler),
230+
n_vars: n_vars.eval_usize(&compiler),
231231
},
232232
));
233233
}
@@ -255,7 +255,7 @@ impl IntermediateBytecode {
255255
} => {
256256
let size = try_as_mem_or_constant(&size).unwrap();
257257
let hint = Hint::RequestMemory {
258-
offset: offset.eval_const_expression_usize(&compiler),
258+
offset: offset.eval_usize(&compiler),
259259
vectorized,
260260
size,
261261
};

crates/leanVm/src/lang/const_expr.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ impl ConstExpression {
7575
)
7676
}
7777

78-
#[must_use] pub fn eval_const_expression(&self, compiler: &Compiler) -> F {
79-
self.eval_with(&|cst| Some(F::from_usize(cst.eval_constant_value(compiler))))
78+
#[must_use]
79+
pub fn eval(&self, compiler: &Compiler) -> F {
80+
self.eval_with(&|cst| Some(F::from_usize(cst.eval(compiler))))
8081
.unwrap()
8182
}
8283

83-
#[must_use] pub fn eval_const_expression_usize(&self, compiler: &Compiler) -> usize {
84-
self.eval_const_expression(compiler)
84+
#[must_use]
85+
pub fn eval_usize(&self, compiler: &Compiler) -> usize {
86+
self.eval(compiler)
8587
.as_canonical_biguint()
8688
.try_into()
8789
.unwrap()

crates/leanVm/src/lang/constant_value.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub enum ConstantValue {
1616
}
1717

1818
impl ConstantValue {
19-
#[must_use] pub fn eval_constant_value(&self, compiler: &Compiler) -> usize {
19+
#[must_use]
20+
pub fn eval(&self, compiler: &Compiler) -> usize {
2021
match self {
2122
Self::Scalar(scalar) => *scalar,
2223
Self::PublicInputStart => PUBLIC_INPUT_START.offset,

0 commit comments

Comments
 (0)