Fix parsing of symbol table

This commit is contained in:
2024-02-10 17:08:34 +01:00
parent 7a8554d313
commit ff9bda49c2
6 changed files with 880 additions and 111 deletions

View File

@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
use eyre::{bail, Context};
use serde::Serialize;
use serde_json::Value;
use serde_json::{Map, Value};
#[derive(Default)]
pub struct Output {
@@ -17,6 +17,22 @@ impl Output {
}
Ok(())
}
pub fn write_append(&mut self, key: &'static str, v: &impl Serialize) -> eyre::Result<()> {
let Value::Object(mut v) =
serde_json::to_value(v).wrap_err("failed to serialize output")?
else {
bail!("tried to append non-object");
};
let Value::Object(entry) = self.elements.entry(key).or_insert(Map::new().into()) else {
bail!("tried to append to non-object");
};
entry.append(&mut v);
Ok(())
}
}
impl Drop for Output {