Recursive inner deserializer for Syntax.
( buf: &mut &[u8], stt: &CompileState, )
| 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. |
| 354 | fn 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. |
| 366 | fn 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 | } |
no test coverage detected