Process a single statement, updating `scope` with any variable assignments, narrowing, or control-flow effects.
(
stmt: &'b Statement<'b>,
scope: &mut ScopeState,
ctx: &ForwardWalkCtx<'_>,
)
| 2940 | /// Process a single statement, updating `scope` with any variable |
| 2941 | /// assignments, narrowing, or control-flow effects. |
| 2942 | fn process_statement<'b>( |
| 2943 | stmt: &'b Statement<'b>, |
| 2944 | scope: &mut ScopeState, |
| 2945 | ctx: &ForwardWalkCtx<'_>, |
| 2946 | ) { |
| 2947 | match stmt { |
| 2948 | Statement::Expression(expr_stmt) => { |
| 2949 | process_expression_statement(expr_stmt, scope, ctx); |
| 2950 | } |
| 2951 | Statement::Foreach(foreach) => { |
| 2952 | process_foreach(foreach, scope, ctx); |
| 2953 | } |
| 2954 | Statement::If(if_stmt) => { |
| 2955 | process_if(if_stmt, stmt, scope, ctx); |
| 2956 | } |
| 2957 | Statement::While(while_stmt) => { |
| 2958 | process_while(while_stmt, scope, ctx); |
| 2959 | } |
| 2960 | Statement::For(for_stmt) => { |
| 2961 | process_for(for_stmt, scope, ctx); |
| 2962 | } |
| 2963 | Statement::DoWhile(dw) => { |
| 2964 | process_do_while(dw, scope, ctx); |
| 2965 | } |
| 2966 | Statement::Try(try_stmt) => { |
| 2967 | process_try(try_stmt, scope, ctx); |
| 2968 | } |
| 2969 | Statement::Switch(switch) => { |
| 2970 | process_switch(switch, scope, ctx); |
| 2971 | } |
| 2972 | Statement::Block(block) => { |
| 2973 | walk_body_forward(block.statements.iter(), scope, ctx); |
| 2974 | } |
| 2975 | Statement::Unset(unset_stmt) => { |
| 2976 | for val in unset_stmt.values.iter() { |
| 2977 | if let Expression::Variable(Variable::Direct(dv)) = val { |
| 2978 | scope.remove(dv.name); |
| 2979 | } |
| 2980 | } |
| 2981 | } |
| 2982 | Statement::Namespace(ns) => { |
| 2983 | walk_body_forward(ns.statements().iter(), scope, ctx); |
| 2984 | } |
| 2985 | Statement::Global(global) => { |
| 2986 | for var in global.variables.iter() { |
| 2987 | if let Variable::Direct(dv) = var { |
| 2988 | let var_name = dv.name.to_string(); |
| 2989 | if let Some(top_scope) = &ctx.top_level_scope { |
| 2990 | if let Some(types) = top_scope.get(&atom(&var_name)) { |
| 2991 | scope.set(&var_name, types.clone()); |
| 2992 | } else { |
| 2993 | scope.set_empty(&var_name); |
| 2994 | } |
| 2995 | } else { |
| 2996 | scope.set_empty(&var_name); |
| 2997 | } |
| 2998 | } |
| 2999 | } |
no test coverage detected