_state and regex change to catch edge case

This commit is contained in:
Rowan Torbitzky-Lane 2025-04-28 19:39:08 -05:00
parent 1617f7cdfc
commit fd7b1340ca
3 changed files with 6 additions and 2 deletions

View File

@ -25,7 +25,7 @@ def run_cargo_expand(binary_name, path_to_module):
def extract_functions_with_push_state(code):
"""Extract function names that have &mut PushState as their only parameter."""
# Look for function definitions with pattern: pub fn name(state: &mut PushState)
pattern = r'pub fn ([a-zA-Z0-9_]+)\s*\(\s*state\s*:\s*&mut\s+PushState\s*\)'
pattern = r'pub fn ([a-zA-Z0-9_]+)\s*\(\s*_?state\s*:\s*&mut\s+PushState\s*\)'
matches = re.findall(pattern, code)
return matches

View File

@ -464,7 +464,7 @@ fn _reverse(a: Gene) -> Option<Gene> {
macro_rules! noop {
($stack:ident, $name:ident) => {
paste::item! {
pub fn [< $stack $name >] (_: &mut PushState) {
pub fn [< $stack $name >] (_state: &mut PushState) {
()
}
}

View File

@ -380,6 +380,8 @@ pub fn code_instructions() -> Vec<fn(&mut PushState)> {
code_insert,
code_first_position,
code_reverse,
code_noop,
code_noop_block,
code_from_int,
code_from_float,
code_from_string,
@ -435,6 +437,8 @@ pub fn exec_instructions() -> Vec<fn(&mut PushState)> {
exec_insert,
exec_first_position,
exec_reverse,
exec_noop,
exec_noop_block,
exec_pop,
exec_dup,
exec_dup_times,