MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / collect_module_attrs

Function collect_module_attrs

compiler/src/modules/vm/init.rs:9–25  ·  view source on GitHub ↗

Collect top-level StoreName bindings as module attrs; `seen` keeps the latest per bare name. */

(chunk: &SSAChunk, slots: &[Val])

Source from the content-addressed store, hash-verified

7
8/* Collect top-level StoreName bindings as module attrs; `seen` keeps the latest per bare name. */
9fn 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
27impl<'a> VM<'a> {
28

Callers 1

init_modulesMethod · 0.85

Calls 5

ssa_stripFunction · 0.85
insertMethod · 0.80
is_undefMethod · 0.80
pushMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected