Collect top-level StoreName bindings as module attrs; `seen` keeps the latest per bare name. */
(chunk: &SSAChunk, slots: &[Val])
| 7 | |
| 8 | /* Collect top-level StoreName bindings as module attrs; `seen` keeps the latest per bare name. */ |
| 9 | fn collect_module_attrs(chunk: &SSAChunk, slots: &[Val]) -> Vec<(String, Val)> { |
| 10 | let mut attrs: Vec<(String, Val)> = Vec::new(); |
| 11 | let mut seen: crate::util::fx::FxHashSet<String> = crate::util::fx::FxHashSet::default(); |
| 12 | for ins in &chunk.instructions { |
| 13 | if !matches!(ins.opcode, OpCode::StoreName) { continue; } |
| 14 | let Some(name) = chunk.names.get(ins.operand as usize) else { continue; }; |
| 15 | let bare = ssa_strip(name).to_string(); |
| 16 | // Skip `_`-prefixed names, mirroring `from m import *` semantics. |
| 17 | if bare.starts_with('_') { continue; } |
| 18 | if !seen.insert(bare.clone()) { continue; } |
| 19 | if let Some(&v) = slots.get(ins.operand as usize) && !v.is_undef() |
| 20 | { |
| 21 | attrs.push((bare, v)); |
| 22 | } |
| 23 | } |
| 24 | attrs |
| 25 | } |
| 26 | |
| 27 | impl<'a> VM<'a> { |
| 28 |