spicy
spicy copied to clipboard
String representation of anonymous bitfield in units
module Test;
import spicy;
public type Header = unit {
: bitfield(16) {
fin: 0;
rsv: 1..3;
opcode: 4..7;
remaining: 8..15;
} &bit-order=spicy::BitOrder::MSB0;
on %done {
print "fin", self.fin, "opcode", self.opcode;
print self;
}
};
$ printf "\x82\xff" | spicy-driver ./test.spicy
fin, 1, opcode, 2
[$<anon>=(1, 0, 2, 255)]
As discussed in Slack, it's a bit surprising that the "lifted" fields are not shown in the string representation of the unit and instead the $<anon>
part shows up.