ZKAOPMCHBGP7J7NQB233AQJQDX6TBD7REPLF3KN3EIKZK6TZZMBQC
2U7P5SFQG3AVALKMPJF4WMZE6PXIXXZYOMZ3RZKILBUJ4UMFXVIAC
JAGXXSR7DR5FG77VKBF62BW7Q3JMVHCLHF4VB2PSLIZF4RLE553QC
YG4DZB3AW3Z3LB5CFBZZ4ORJOLZFN3G4CA2YTAMSUOQX3USVNVEAC
DKX3RO3LHLWUVHRUI23CN4A4IP3EPIUIVB6I5PPHMBU4PN2GOM2QC
Q7TKZCJP2Z75EICZYKCEZDHKGERSOKZGMTSU3UXETBHTF663T66AC
OBKF6SIIFFHHY7YWKPPX75N23NAVUD5662DKIHXSSIDPKKXQ5ZDQC
FMYCPGKDAPOUFLQOCXXKZ6TR75HT3TNCG4X3GAJDM4ARWKNWOSWAC
XTKRT6OQYN4LARQRDLI2KBSAJTOFZNT4AMBZ46CPUDZXD7IDYYWQC
4RYULBDDDIVSJTIOTBBSQAWMSN6ZBZEFJ6UR7P6ECEXEXTGPMUOAC
QYRJIOYPM7SAB3OHMALL67K44U5HPBRQ2AFNWUKATPXM6BUYRKBQC
LVX6U4EKYXM6H32X5SZS4UBIM5PW4ND4F4QQOF5EQDX3DUHBYFGAC
Hash hash;
hash.variant = (uint8_t)bincode_getu32(binstat);
switch (hash.variant) {
pos->change.variant = (uint8_t)bincode_getu32(binstat);
switch (pos->change.variant) {
case HASH_BLAKE3:
bincode_getbytes(
binstat, (uint8_t *)&pos->change.bytes,
BLAKE3_BYTES
);
break;
dump_buf("newedge", binstat->buf, binstat->avail);
previous = bincode_getu8(binstat);
flag = bincode_getu8(binstat);
printf("previous = %u, flag = %u\n", previous, flag);
ishash = bincode_getu8(binstat);
if (ishash) {
hash->variant = (uint8_t)bincode_getu32(binstat);
switch (hash->variant) {
case HASH_BLAKE3:
bincode_getbytes(
binstat, (uint8_t *)hash->bytes, BLAKE3_BYTES
);
break;
case HASH_NONE:
break;
default:
abort();
}
printf("introduced_by: ");
if (ishash) {
printf("Some(");
hashprint(hash);
printf(")\n");
} else {
printf("None\n");
}
}
}
static void
change_decode_newedge(Bincode *binstat, Edge *edge)
{
edge->previous = bincode_getu8(binstat);
edge->flag = bincode_getu8(binstat);
printf("previous = %u, flag = %u\n", edge->previous, edge->flag);
/* from: Position<Change = Option<Hash>> */
change_decode_position(binstat);
change_decode_position(binstat, &edge->from);
change_decode_vertex(binstat, &edge->to);
change_decode_introducedby(binstat, &edge->introducedby);
}
static void
change_decode_positionlist(Bincode *binstat, Positionlist *poslist)
{
size_t len;
int i;
/* to: V(Some(HASH)[range?]) */
/* introduced_by: Option<Hash> */
poslist->len = len = bincode_getu64(binstat);
if (len > 1)
poslist->entries = xmalloc(sizeof(Position) * (len - 1));
if (len > 0) {
change_decode_position(binstat, &poslist->first);
for (i = 0; i < len - 1; i++)
change_decode_position(binstat, &poslist->entries[i]);
}
uint64_t edges_len;
/* Fields: upcontext: Vec<Position>, downcontext: Vec<Position>, flag, start, end: ChangePosition, inode: Position */
printf("Decoding Newvertex\n");
change_decode_positionlist(binstat, &newvertex->upcontext);
change_decode_positionlist(binstat, &newvertex->downcontext);
newvertex->flag = bincode_getu8(binstat);
newvertex->start = bincode_getu64(binstat);
newvertex->end = bincode_getu64(binstat);
change_decode_position(binstat, &newvertex->inode);
}
static void
change_decode_atom(Bincode *binstat, Atom *atom)
{
edges_len = bincode_getu64(binstat);
printf("EdgeMap (%lu elements)\n", edges_len);
for (i = 0; i < edges_len; i++) {
change_decode_newedge(binstat);
break; /* FIXME remove this */
atom->atomtype = EDGE_MAP;
atom->edgemap.edges.len = bincode_getu64(binstat);
atom->edgemap.edges.entries =
xmalloc(sizeof(Edge) * atom->edgemap.edges.len);
printf("EdgeMap (%lu elements)\n", atom->edgemap.edges.len);
for (i = 0; i < atom->edgemap.edges.len; i++) {
change_decode_newedge(
binstat, &atom->edgemap.edges.entries[i]
);
}
}
static void
change_decode_local(Bincode *binstat, Local *local)
{
uint64_t len;
len = bincode_getu64(binstat);
local->path = bincode_getstr(binstat, len);
local->line = bincode_getu64(binstat);
}
static void
change_decode_encoding(Bincode *binstat, char **encoding)
{
/* This is an optional field - basically just an Option<String> */
if (bincode_getu8(binstat)) {
uint64_t len = bincode_getu64(binstat);
*encoding = bincode_getstr(binstat, len);
basehunktype hunk_type = bincode_getu32(binstat);
printf("%d. %s\n", i + 1, hunk_basehunk_type_str(hunk_type));
Basehunk *bhunk = &hashed->hunks.entries[i];
bhunk->hunktype = bincode_getu32(binstat);
/* printf("%d. %s\n", i + 1, hunk_basehunk_type_str(bhunk->hunktype)); */
printf("Edit. change: Atom, local: Local, encoding: Option<Encoding>\n"
);
change_decode_atom(binstat); /* the change field */
/* change_decode_local */
/* change_decode_encoding (maybe) */
/* An edit is a (1) Atom (2) Local (3) Option<Encoding> */
change_decode_atom(
binstat, &bhunk->edit.change
); /* the change field */
change_decode_local(binstat, &bhunk->edit.local);
change_decode_encoding(binstat, &bhunk->edit.encoding);
printf("%d. Edit in %s:%d\n", i + 1,
bhunk->edit.local.path, bhunk->edit.local.line);
Hash upcontext; /* FIXME Option<Hash> */
Hash downcontext;
uint8_t previous;
uint8_t flag;
Position from;
Vertex to;
Hash introducedby; /* FIXME Should be Option */
} Edge;
typedef struct {
size_t len;
Edge *entries;
} Edgelist;
typedef struct {
Positionlist upcontext;
Positionlist downcontext;