Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String representation of anonymous bitfield in units #1660

Open
awelzel opened this issue Jan 24, 2024 · 1 comment
Open

String representation of anonymous bitfield in units #1660

awelzel opened this issue Jan 24, 2024 · 1 comment
Labels
Enhancement Improvement of existing functionality

Comments

@awelzel
Copy link
Contributor

awelzel commented Jan 24, 2024

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.

@rsmmr
Copy link
Member

rsmmr commented Jan 25, 2024

I would have sworn that we were lifting this up now after the recent changes, but indeed I do see this in our baselines, too:

spicy.types.bitfield.anonymous-field:

[$<anon>=(15, 15), $<anon>=(not set)]

spicy-dump does lift it up. From the same test:

Test::Foo {
  x: 15
  y: 15
}

@rsmmr rsmmr added the Enhancement Improvement of existing functionality label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants