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

Method call_dict

compiler/src/modules/vm/builtins/container.rs:107–123  ·  view source on GitHub ↗

Operand packs kw<<8 | pos; keep counts distinct.

(&mut self, op: u16)

Source from the content-addressed store, hash-verified

105
106 // Operand packs kw<<8 | pos; keep counts distinct.
107 pub fn call_dict(&mut self, op: u16) -> Result<(), VmErr> {
108 let pos = (op & 0xFF) as usize;
109 let kw = (op >> 8) as usize;
110 if pos > 1 {
111 return Err(cold_type("dict expected at most 1 argument"));
112 }
113 // Keyword pairs sit above the positional source.
114 let kw_flat = self.pop_n(kw * 2)?;
115 let mut dm = if pos == 1 {
116 let src = self.pop()?;
117 self.dict_from_source(src)?
118 } else {
119 DictMap::with_capacity(kw)
120 };
121 for pair in kw_flat.chunks(2) { dm.insert(pair[0], pair[1], &self.heap); }
122 self.alloc_and_push_dict(dm)
123 }
124
125 // dict(mapping) copies; dict(iterable) builds from pairs.
126 fn dict_from_source(&mut self, src: Val) -> Result<DictMap, VmErr> {

Callers 2

handle_functionMethod · 0.80
dispatch_nativeMethod · 0.80

Calls 6

cold_typeFunction · 0.85
pop_nMethod · 0.80
dict_from_sourceMethod · 0.80
insertMethod · 0.80
alloc_and_push_dictMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected