MCPcopy Create free account
hub / github.com/argumentcomputer/ix / deserialize_syntax_inner

Function deserialize_syntax_inner

crates/compile/src/decompile.rs:345–391  ·  view source on GitHub ↗

Recursive inner deserializer for Syntax.

(
  buf: &mut &[u8],
  stt: &CompileState,
)

Source from the content-addressed store, hash-verified

343 addr: &Address,
344 stt: &CompileState,
345) -> Result<String, DecompileError> {
346 let bytes = read_blob(addr, stt)?;
347 String::from_utf8(bytes).map_err(|_| DecompileError::BadBlobFormat {
348 addr: addr.clone(),
349 expected: "UTF-8 string".into(),
350 })
351}
352
353/// Read a Constant from the const store, materializing the lazy entry.
354fn read_const(
355 addr: &Address,
356 stt: &CompileState,
357) -> Result<Arc<Constant>, DecompileError> {
358 stt.env.get_const(addr).ok_or(DecompileError::MissingAddress(addr.clone()))
359}
360
361// ===========================================================================
362// DataValue and KVMap decompilation
363// ===========================================================================
364
365/// Decompile an Ixon DataValue (Address-based) to a Lean DataValue.
366fn decompile_data_value(
367 dv: &DataValue,
368 stt: &CompileState,
369) -> Result<LeanDataValue, DecompileError> {
370 match dv {
371 DataValue::OfString(addr) => {
372 let s = read_string(addr, stt)?;
373 Ok(LeanDataValue::OfString(s))
374 },
375 DataValue::OfBool(b) => Ok(LeanDataValue::OfBool(*b)),
376 DataValue::OfName(addr) => {
377 let name = decompile_name(addr, stt)?;
378 Ok(LeanDataValue::OfName(name))
379 },
380 DataValue::OfNat(addr) => {
381 let n = read_nat(addr, stt)?;
382 Ok(LeanDataValue::OfNat(n))
383 },
384 DataValue::OfInt(addr) => {
385 let bytes = read_blob(addr, stt)?;
386 let int = deserialize_int(&bytes)?;
387 Ok(LeanDataValue::OfInt(int))
388 },
389 DataValue::OfSyntax(addr) => {
390 let bytes = read_blob(addr, stt)?;
391 let syntax = deserialize_syntax(&bytes, stt)?;
392 Ok(LeanDataValue::OfSyntax(Box::new(syntax)))
393 },
394 }

Callers 1

deserialize_syntaxFunction · 0.85

Calls 10

deserialize_source_infoFunction · 0.85
read_addr_bytesFunction · 0.85
decompile_nameFunction · 0.85
read_tag0Function · 0.85
NodeClass · 0.85
read_stringFunction · 0.85
deserialize_substringFunction · 0.85
deserialize_preresolvedFunction · 0.85
pushMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected