use crate::annotations::coverage::{SourceCodeSpan, SourceFileFullPath};
use crate::annotations::impl_helpers::impl_namespace;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::collections::HashMap;
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum VersionedDebuggerAnnotations {
V1(DebuggerAnnotationsV1),
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct DebuggerAnnotationsV1 {
pub functions_info: HashMap<SierraFunctionId, FunctionDebugInfo>,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct FunctionDebugInfo {
pub function_file_path: SourceFileFullPath,
pub function_code_span: SourceCodeSpan,
pub sierra_to_cairo_variable: HashMap<SierraVarId, (CairoVariableName, SourceCodeSpan)>,
}
type CairoVariableName = String;
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct SierraFunctionId(pub u64);
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct SierraVarId(pub u64);
impl Serialize for VersionedDebuggerAnnotations {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match self {
VersionedDebuggerAnnotations::V1(v1) => v1.serialize(serializer),
}
}
}
impl<'de> Deserialize<'de> for VersionedDebuggerAnnotations {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
DebuggerAnnotationsV1::deserialize(deserializer).map(VersionedDebuggerAnnotations::V1)
}
}
impl_namespace!(
"github.com/software-mansion-labs/cairo-debugger",
DebuggerAnnotationsV1,
VersionedDebuggerAnnotations
);