rsmmr / hilti

**NOTE**: This is outdated and no longer maintained. There's a new version at https://github.com/zeek/spicy.
Other
40 stars 22 forks source link

Setting the %bitorder globally for the module has no effect #40

Open dloss opened 7 years ago

dloss commented 7 years ago

Setting the bitorder globally for the module apparently has no effect:

# cat mini.spicy
module  Mini;

%bitorder=Spicy::BitOrder::MSB0;

export type Test = unit {
    bits : bitfield(8) {
        b0: 0;
        middle: 1..6;
        b7: 7;
        };

    on %done {
        print self;
    }
};
# printf "\x01" | spicy-driver mini.spicy
<bits=(b0=1, middle=0, b7=0)>

Expected output: <bits=(b0=0, middle=0, b7=1)>. Compare this with setting the bitorder for the field, which produces the desired result:

# cat mini-field.spicy
module  Mini;

export type Test = unit {
    bits : bitfield(8) {
        b0: 0;
        middle: 1..6;
        b7: 7;
        } &bitorder=Spicy::BitOrder::MSB0;

    on %done {
        print self;
    }
};
# printf "\x01" | spicy-driver mini-field.spicy
<bits=(b0=0, middle=0, b7=1)>