mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 21:31:05 +00:00
94ec34c4d5
Separate between compilation and linker phases to allow deploy time linking and back-porting era compiler changes to fix #91. Unlinked contract binaries (caused by missing libraries or missing factory dependencies in turn) are emitted as raw ELF object. Few drive by fixes: - #98 - A compiler panic on missing libraries definitions. - Fixes some incosistent type forwarding in JSON output (empty string vs. null object). - Remove the unused fallback for size optimization setting. - Remove the broken `--lvm-ir` mode. - CI workflow fixes. --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> Signed-off-by: xermicus <bigcyrill@hotmail.com> Signed-off-by: xermicus <cyrill@parity.io>
48 lines
1.6 KiB
Rust
48 lines
1.6 KiB
Rust
//! The compiler common utils.
|
|
|
|
/// Deserializes a `serde_json` object from slice with the recursion limit disabled.
|
|
///
|
|
/// Must be used for all JSON I/O to avoid crashes due to the aforementioned limit.
|
|
pub fn deserialize_from_slice<O>(input: &[u8]) -> anyhow::Result<O>
|
|
where
|
|
O: serde::de::DeserializeOwned,
|
|
{
|
|
let deserializer = serde_json::Deserializer::from_slice(input);
|
|
deserialize(deserializer)
|
|
}
|
|
|
|
/// Deserializes a `serde_json` object from string with the recursion limit disabled.
|
|
///
|
|
/// Must be used for all JSON I/O to avoid crashes due to the aforementioned limit.
|
|
pub fn deserialize_from_str<O>(input: &str) -> anyhow::Result<O>
|
|
where
|
|
O: serde::de::DeserializeOwned,
|
|
{
|
|
let deserializer = serde_json::Deserializer::from_str(input);
|
|
deserialize(deserializer)
|
|
}
|
|
|
|
/// Deserializes a `serde_json` object from reader with the recursion limit disabled.
|
|
///
|
|
/// Must be used for all JSON I/O to avoid crashes due to the aforementioned limit.
|
|
pub fn deserialize_from_reader<R, O>(reader: R) -> anyhow::Result<O>
|
|
where
|
|
R: std::io::Read,
|
|
O: serde::de::DeserializeOwned,
|
|
{
|
|
let deserializer = serde_json::Deserializer::from_reader(reader);
|
|
deserialize(deserializer)
|
|
}
|
|
|
|
/// Runs the generic deserializer.
|
|
pub fn deserialize<'de, R, O>(mut deserializer: serde_json::Deserializer<R>) -> anyhow::Result<O>
|
|
where
|
|
R: serde_json::de::Read<'de>,
|
|
O: serde::de::DeserializeOwned,
|
|
{
|
|
deserializer.disable_recursion_limit();
|
|
let deserializer = serde_stacker::Deserializer::new(&mut deserializer);
|
|
let result = O::deserialize(deserializer)?;
|
|
Ok(result)
|
|
}
|