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

Bitfield improvements #1492

Merged
merged 9 commits into from
Aug 22, 2023
Merged

Bitfield improvements #1492

merged 9 commits into from
Aug 22, 2023

Commits on Aug 14, 2023

  1. Fix comparison for resolved operators.

    The `isEqual` method was implemented in the base class, which led to
    wrong template types being used.
    
    A subsequent commit will depend on this working correctly, including a test
    breaking if not.
    rsmmr committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    8fb825b View commit details
    Browse the repository at this point in the history
  2. Move bitfield type from Spicy to HILTI.

    This prepares for making `bitfield` a fully-supported HILTI type. This
    change only moves existing code over to HILTI without breaking
    Spicy-side functionality. There are still HILTI-side pieces missing
    for providing full support, which will come next.
    rsmmr committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    901679f View commit details
    Browse the repository at this point in the history
  3. Implement remaining pieces to make bitfield a full HILTI type.

    We keep representing bitfields as a C++ tuple behind the scenes, but
    no longer map it into a HILTI-side tuple as well. Instead `Bitfield`
    is now a regular type with corresponding operators and runtime
    functionality.
    
    The one change to the C++ tuple representation is that we add an
    additional hidden tuple element at the end that stores the original
    integer value. That allows for displaying it (which we will do for now
    only inside Spicy debug output) and could later also facilitate modifying
    fields and reconstructing an integer.
    rsmmr committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    0f6ac48 View commit details
    Browse the repository at this point in the history
  4. Switch Spicy over to use the new HILTI-side bitfield type.

    Closes #1032. Using a typedef with bitfields works now.
    Closes #1484. `&convert` can now refer to individual bitfields.
    rsmmr committed Aug 14, 2023
    Configuration menu
    Copy the full SHA
    e55296b View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2023

  1. Allow to directly access members of anonymous bitfields.

    This works now:
    
        type Foo = unit {
          : bitfield(8) {
            x: 0..3;
            y: 4..7;
          };
    
          on %done {
            print self.x, self.y;
          }
    };
    
    Closes #1468.
    rsmmr committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    f3a8bdf View commit details
    Browse the repository at this point in the history
  2. Include a flag into a unit field's type information indicating if it'…

    …s anonymous.
    
    This preservers the information if a field had a name even though
    internally we do carry a generated dummy name around in that case. For
    now, we just adapt `spicy-dump` to not print the dummy name in that
    case in its text output. Later, Zeek will leverage this when
    auto-generating record types.
    rsmmr committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    cf081d4 View commit details
    Browse the repository at this point in the history
  3. [spicy-dump] Change format how bitfields are printed.

    We now render them as key/value form in both text and JSON output.
    rsmmr committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    d8b7734 View commit details
    Browse the repository at this point in the history
  4. [spicy-dump] Make offsets in JSON output useful.

    We were including offsets into spicy-dumps JSON output, but there was
    no information in there saying which offsets belong to what field.
    Turning `__offsets` from an array into a map indexed by field name now.
    rsmmr committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    a7c99a6 View commit details
    Browse the repository at this point in the history
  5. [spicy-dump] Level up anonymous bitfields.

    Spicy-dump now renders items of anonymous bitfields at the parent
    level. Offsets are added accordingly as well if requested.
    rsmmr committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    33f5855 View commit details
    Browse the repository at this point in the history