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

Method alloc_set_result

compiler/src/modules/vm/ops.rs:153–158  ·  view source on GitHub ↗

Alloc a set-algebra result; frozen picks frozenset (left-operand type rule). */

(&mut self, items: Vec<Val>, frozen: bool)

Source from the content-addressed store, hash-verified

151
152 /* Alloc a set-algebra result; frozen picks frozenset (left-operand type rule). */
153 pub(crate) fn alloc_set_result(&mut self, items: Vec<Val>, frozen: bool) -> Result<Val, VmErr> {
154 let mut s = ValSet::with_capacity(items.len());
155 for v in items { s.insert(v, &self.heap); }
156 if frozen { self.heap.alloc(HeapObj::FrozenSet(Rc::new(s))) }
157 else { self.heap.alloc(HeapObj::Set(Rc::new(RefCell::new(s)))) }
158 }
159
160 /* Set bitwise ops (|, &, ^) over set/frozenset; result frozen iff `a` is frozen. */
161 // Union/intersection/symmetric-diff items; content membership lets alloc dedup distinct-handle equals.

Callers 2

set_binop_and_pushMethod · 0.80
sub_valsMethod · 0.80

Calls 3

insertMethod · 0.80
lenMethod · 0.45
allocMethod · 0.45

Tested by

no test coverage detected