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

Method exec_build_module

compiler/src/modules/vm/dispatch.rs:985–1006  ·  view source on GitHub ↗
(&mut self, op: u16)

Source from the content-addressed store, hash-verified

983
984 #[inline(never)]
985 fn exec_build_module(&mut self, op: u16) -> Result<(), VmErr> {
986 let total = (op as usize) * 2 + 1;
987 let mut frame = self.pop_n(total)?;
988 let module_name_val = frame.pop().ok_or(cold_runtime("BuildModule: empty stack"))?;
989 let module_name = match self.heap.get(module_name_val) {
990 HeapObj::Str(s) => s.clone(),
991 _ => return Err(cold_runtime("BuildModule: module name not a string")),
992 };
993 let mut attrs: Vec<(String, Val)> = Vec::with_capacity(op as usize);
994 let mut it = frame.into_iter();
995 while let Some(name_v) = it.next() {
996 let val = it.next().ok_or(cold_runtime("BuildModule: malformed attr stack"))?;
997 let n = match self.heap.get(name_v) {
998 HeapObj::Str(s) => s.clone(),
999 _ => return Err(cold_runtime("BuildModule: attr name not a string")),
1000 };
1001 attrs.push((n, val));
1002 }
1003 let m = self.heap.alloc(HeapObj::Module(module_name, attrs))?;
1004 self.push(m);
1005 Ok(())
1006 }
1007}

Callers 1

dispatchMethod · 0.80

Calls 7

cold_runtimeFunction · 0.85
pop_nMethod · 0.80
nextMethod · 0.80
pushMethod · 0.80
popMethod · 0.45
getMethod · 0.45
allocMethod · 0.45

Tested by

no test coverage detected