MCPcopy Index your code
hub / github.com/endbasic/endbasic / push

Method push

core/src/mem.rs:250–261  ·  view source on GitHub ↗

Allocates `datum` in the heap and returns its pointer.

(&mut self, datum: HeapDatum)

Source from the content-addressed store, hash-verified

248
249 /// Allocates `datum` in the heap and returns its pointer.
250 pub(crate) fn push(&mut self, datum: HeapDatum) -> Result<u64, HeapOverflowError> {
251 if matches!(&datum, HeapDatum::Text(s) if s.is_empty()) {
252 return Ok(self.empty_text_ptr());
253 }
254
255 let index = U24::try_from(self.len()).map_err(|_| HeapOverflowError)?;
256 if self.len() >= unchecked_u24_as_usize(self.max_entries) {
257 return Err(HeapOverflowError);
258 }
259 self.data.push(datum);
260 Ok(DatumPtr::for_heap(u32::from(index)))
261 }
262
263 /// Returns the heap entry at `index`.
264 pub(crate) fn get(&self, index: usize) -> &HeapDatum {

Callers 15

get_file_aclsMethod · 0.80
runFunction · 0.80
argspans_to_exprsFunction · 0.80
apply1Method · 0.80
apply2Method · 0.80
parse_untilMethod · 0.80
parse_builtin_callMethod · 0.80
parse_dataMethod · 0.80
parse_exprMethod · 0.80
parse_if_unilineMethod · 0.80

Calls 2

empty_text_ptrMethod · 0.80
lenMethod · 0.45

Tested by 15

execMethod · 0.64
test_buildMethod · 0.64
add_testFunction · 0.64
finish_sourceFunction · 0.64
read_sourcesFunction · 0.64
execMethod · 0.64
execMethod · 0.64
execMethod · 0.64
execMethod · 0.64
execMethod · 0.64