usize max stack size
This commit is contained in:
parent
4ea42a5b72
commit
3add0dc9aa
@ -28,7 +28,7 @@ pub fn gene_to_stack(state: &mut PushState, gene: Gene) {
|
|||||||
|
|
||||||
/// Where a push program's exec stack is interpreted to completion.
|
/// Where a push program's exec stack is interpreted to completion.
|
||||||
/// TODO: Decide where to place loading in a push program.
|
/// TODO: Decide where to place loading in a push program.
|
||||||
pub fn interpret_program(state: &mut PushState, step_limit: usize, max_stack_size: isize) {
|
pub fn interpret_program(state: &mut PushState, step_limit: usize, max_stack_size: usize) {
|
||||||
let mut steps: usize = 0;
|
let mut steps: usize = 0;
|
||||||
while state.exec.len() > 0 && steps < step_limit {
|
while state.exec.len() > 0 && steps < step_limit {
|
||||||
if let Some(gene) = state.exec.pop() {
|
if let Some(gene) = state.exec.pop() {
|
||||||
@ -62,10 +62,7 @@ mod tests {
|
|||||||
assert_eq!(vec![true], test_state.boolean);
|
assert_eq!(vec![true], test_state.boolean);
|
||||||
test_state.boolean.clear();
|
test_state.boolean.clear();
|
||||||
|
|
||||||
gene_to_stack(
|
gene_to_stack(&mut test_state, Gene::GeneString(vec!['t', 'e', 's', 't']));
|
||||||
&mut test_state,
|
|
||||||
Gene::GeneString(vec!['t', 'e', 's', 't']),
|
|
||||||
);
|
|
||||||
assert_eq!(vec![vec!['t', 'e', 's', 't']], test_state.string);
|
assert_eq!(vec![vec!['t', 'e', 's', 't']], test_state.string);
|
||||||
test_state.string.clear();
|
test_state.string.clear();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user