-
Notifications
You must be signed in to change notification settings - Fork 158
/
mod.rs
39 lines (33 loc) · 1.17 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use super::{
errors::{InputError, OutputError},
Felt, ToElements,
};
use crate::utils::{ByteWriter, Serializable};
mod inputs;
pub use inputs::StackInputs;
mod outputs;
pub use outputs::StackOutputs;
// CONSTANTS
// ================================================================================================
/// Represents:
/// - Number of elements that can be initialized at the start of execution and remain populated at
/// the end of execution.
/// - Number of elements that can be accessed directly via instructions.
/// - Number of elements that remain visible to the callee when the context is switched via `call`
/// or `syscall` instructions.
/// - Number of elements below which the depth of the stack never drops.
pub const MIN_STACK_DEPTH: usize = 16;
// HELPER FUNCTIONS
// ================================================================================================
/// Get the number of non-zero stack elements.
fn get_stack_values_num(values: &[Felt]) -> u8 {
let mut acc = 0;
for v in values.iter().rev() {
if v.as_int() == 0 {
acc += 1;
} else {
break;
}
}
(MIN_STACK_DEPTH - acc) as u8
}