pub(crate) fn collect_defines<'a>(
        stmt: &'a AstStmt,
        result: &mut HashMap<&'a str, Visibility>,
    ) {
        match &stmt.node {
            Stmt::Assign(dest, _) | Stmt::AssignModify(dest, _, _) => {
                Expr::collect_defines_lvalue(dest, result);
            }
            Stmt::For(dest, box (_, body)) => {
                Expr::collect_defines_lvalue(dest, result);
                Stmt::collect_defines(body, result);
            }
            Stmt::Def(name, ..) => {
                result.insert(&name.node, Visibility::Public);
            }
            Stmt::Load(_, names, vis) => {
                for (name, _) in names {
                    // If we are in the map as Public and Private, then Public wins.
                    // Everything but Load is definitely Public.
                    // So only insert if it wasn't already there.
                    result.entry(&name.node).or_insert(*vis);
                }
            }
            _ => stmt.node.visit_stmt(|x| Stmt::collect_defines(x, result)),
        }
    }
// Collect all the variables that are defined in this scope
Collect all the variables that are defined in this scope
Collect all the variables that are defined in this scope
pub(crate) fn collect_defines<'a>(
        stmt: &'a AstStmt,
        result: &mut HashMap<&'a str, Visibility>,
    ) {
        match &stmt.node {
            Stmt::Assign(dest, _) | Stmt::AssignModify(dest, _, _) => {
                Expr::collect_defines_lvalue(dest, result);
            }
            Stmt::For(dest, box (_, body)) => {
                Expr::collect_defines_lvalue(dest, result);
                Stmt::collect_defines(body, result);
            }
            Stmt::Def(name, ..) => {
                result.insert(&name.node, Visibility::Public);
            }
            Stmt::Load(_, names, vis) => {
                for (name, _) in names {
                    // If we are in the map as Public and Private, then Public wins.
                    // Everything but Load is definitely Public.
                    // So only insert if it wasn't already there.
                    result.entry(&name.node).or_insert(*vis);
                }
            }
            _ => stmt.node.visit_stmt(|x| Stmt::collect_defines(x, result)),
        }
    }
pub ( crate ) fn collect_defines < ' a > ( stmt : & ' a AstStmt , result : & mut HashMap < & ' a str , Visibility > , ) { match & stmt . node { Stmt :: Assign ( dest , _ ) | Stmt :: AssignModify ( dest , _ , _ ) => { Expr :: collect_defines_lvalue ( dest , result ) ; } Stmt :: For ( dest , box ( _ , body ) ) => { Expr :: collect_defines_lvalue ( dest , result ) ; Stmt :: collect_defines ( body , result ) ; } Stmt :: Def ( name , .. ) => { result . insert ( & name . node , Visibility :: Public ) ; } Stmt :: Load ( _ , names , vis ) => { for ( name , _ ) in names { // If we are in the map as Public and Private, then Public wins. // Everything but Load is definitely Public. // So only insert if it wasn't already there. result . entry ( & name . node ) . or_insert ( * vis ) ; } } _ => stmt . node . visit_stmt ( | x | Stmt :: collect_defines ( x , result ) ) , } }
Collect all the variables that are defined in this scope
Collect all the variables that are defined in this scope
stmt
&'a AstStmt
result
&mut HashMap<&'a str, Visibility>
stmt
&'a AstStmt
result
&mut HashMap<&'a str, Visibility>