dada_ir_sym/check/debug/
export.rs1use std::{borrow::Cow, panic::Location};
4
5use serde::Serialize;
6
7use crate::ir::indices::InferVarIndex;
8
9#[derive(Serialize, Debug)]
10pub struct Log<'a> {
11 pub events_flat: Vec<Event<'a>>,
12 pub nested_event: NestedEvent,
13 pub infers: Vec<Infer>,
14 pub tasks: Vec<Task>,
15 pub root_event_info: RootEventInfo<'a>,
17 pub total_events: usize,
18}
19
20#[derive(Serialize, Debug)]
22pub struct RootEventInfo<'a> {
23 pub compiler_location: CompilerLocation<'a>,
24 pub description: String,
25}
26
27#[derive(Serialize, Debug)]
28pub struct Event<'a> {
29 pub compiler_location: CompilerLocation<'a>,
31
32 pub task: TaskId,
34
35 pub kind: &'a str,
37
38 pub value: Cow<'a, str>,
40
41 pub spawns: Option<TaskId>,
43
44 pub infer: Option<InferVarIndex>,
46}
47
48#[derive(Serialize, Debug)]
49pub struct CompilerLocation<'a> {
50 pub file: &'a str,
51 pub line: u32,
52 pub column: u32,
53}
54
55impl<'a> From<&'a Location<'a>> for CompilerLocation<'a> {
56 fn from(location: &'a Location<'a>) -> Self {
57 Self {
58 file: location.file(),
59 line: location.line(),
60 column: location.column(),
61 }
62 }
63}
64
65#[derive(Copy, Clone, Serialize, Debug)]
66pub struct TimeStamp {
67 pub index: usize,
68}
69
70#[derive(Serialize, Debug)]
71pub struct Task {
72 pub spawned_at: TimeStamp,
73 pub description: String,
74 pub events: Vec<TimeStamp>,
75}
76
77#[derive(Copy, Clone, Debug, Serialize)]
78pub struct TaskId {
79 pub index: usize,
80}
81
82#[derive(Serialize, Debug)]
83pub struct NestedEvent {
84 pub timestamp: TimeStamp,
86
87 pub children: Vec<NestedEvent>,
91}
92
93#[derive(Copy, Clone, Serialize, Debug)]
94pub struct InferId {
95 pub index: usize,
96}
97
98#[derive(Serialize, Debug)]
100pub struct Infer {
101 pub created_at: TimeStamp,
103
104 pub events: Vec<TimeStamp>,
106}