Skip to content

Commit 3b5d8d8

Browse files
nickysnalehander92
authored andcommitted
feat: support TraceLowLevelEvent::Assignment in write_trace()
1 parent 4f1b60d commit 3b5d8d8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

runtime_tracing/src/capnptrace.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ impl From<crate::EventLogKind> for trace::EventLogKind {
131131
}
132132
}
133133

134+
impl From<crate::PassBy> for trace::PassBy {
135+
fn from(value: crate::PassBy) -> Self {
136+
match value {
137+
crate::PassBy::Value => trace::PassBy::Value,
138+
crate::PassBy::Reference => trace::PassBy::Reference,
139+
}
140+
}
141+
}
142+
134143

135144
fn conv_valuerecord(
136145
bldr: crate::trace_capnp::trace::value_record::Builder,
@@ -380,6 +389,26 @@ pub fn write_trace(q: &[crate::TraceLowLevelEvent], output: &mut impl std::io::W
380389
let mut ret_place = ret.init_place();
381390
ret_place.set_p(bindvarrec.place.0.try_into().unwrap());
382391
}
392+
TraceLowLevelEvent::Assignment(assrec) => {
393+
let mut ret = event.init_assignment();
394+
let mut ret_to = ret.reborrow().init_to();
395+
ret_to.set_i(assrec.to.0.try_into().unwrap());
396+
ret.set_pass_by(assrec.pass_by.clone().into());
397+
let ret_from = ret.init_from();
398+
match &assrec.from {
399+
crate::RValue::Simple(variable_id) => {
400+
let mut ret_from_simple = ret_from.init_simple();
401+
ret_from_simple.set_i(variable_id.0.try_into().unwrap());
402+
},
403+
crate::RValue::Compound(variable_ids) => {
404+
let mut ret_from_compound = ret_from.init_compound(variable_ids.len().try_into().unwrap());
405+
for i in 0..variable_ids.len() {
406+
let mut r = ret_from_compound.reborrow().get(i.try_into().unwrap());
407+
r.set_i(variable_ids[i].0.try_into().unwrap());
408+
}
409+
},
410+
}
411+
}
383412
_ => {
384413
eprintln!("Not yet implemented: {:?}", qq);
385414
}

0 commit comments

Comments
 (0)