Skip to content

Commit 11e985d

Browse files
committed
feat: add BigInt to the capnproto binary format
1 parent f28e827 commit 11e985d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

runtime_tracing/src/capnptrace.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ fn conv_valuerecord(
211211
let mut q_place = qcell.init_place();
212212
q_place.set_p(place.0);
213213
}
214+
crate::ValueRecord::BigInt { b, negative, type_id } => {
215+
let mut qbigint = bldr.init_bigint();
216+
let mut bigint_b = qbigint.reborrow().init_b(b.len().try_into().unwrap());
217+
for i in 0..=b.len() {
218+
bigint_b.set(i.try_into().unwrap(), b[i]);
219+
}
220+
qbigint.set_negative(*negative);
221+
let mut q_typ_id = qbigint.init_type_id();
222+
q_typ_id.set_i(type_id.0.try_into().unwrap());
223+
}
214224
}
215225
}
216226

@@ -389,6 +399,11 @@ fn get_value_record(
389399
Ok(trace::value_record::Which::Cell(q)) => Ok(crate::ValueRecord::Cell {
390400
place: crate::Place(q.get_place()?.get_p()),
391401
}),
402+
Ok(trace::value_record::Which::Bigint(q)) => Ok(crate::ValueRecord::BigInt {
403+
b: q.get_b()?.as_slice().unwrap().to_vec(),
404+
negative: q.get_negative(),
405+
type_id: crate::TypeId(q.get_type_id()?.get_i().try_into().unwrap()),
406+
}),
392407
Err(_) => panic!(),
393408
}
394409
}

runtime_tracing/src/trace.capnp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ struct Trace {
226226
cell :group {
227227
place @26 :Place;
228228
}
229+
bigint :group {
230+
b @28 :List(UInt8);
231+
negative @29 :Bool;
232+
typeId @30 :TypeId;
233+
}
229234
}
230235
}
231236

0 commit comments

Comments
 (0)