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

Adds binary eexp subfield span accessors #850

Merged
merged 2 commits into from
Nov 7, 2024
Merged

Adds binary eexp subfield span accessors #850

merged 2 commits into from
Nov 7, 2024

Conversation

zslayton
Copy link
Contributor

@zslayton zslayton commented Nov 7, 2024

For use in tooling, particularly ion inspect. These methods allow an application to access the encoded subfields of a binary 1.1 e-expression.

Related to amazon-ion/ion-cli#181.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor Author

@zslayton zslayton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ PR tour

@@ -18,32 +18,6 @@ use crate::lazy::text::raw::v1_1::arg_group::{EExpArg, EExpArgExpr};
use crate::lazy::text::raw::v1_1::reader::MacroIdRef;
use crate::{try_or_some_err, v1_1, Environment, HasRange, HasSpan, IonResult, Span};

#[derive(Copy, Clone)]
pub struct BinaryEExpHeader {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ This type was created to offer methods like those added in this PR, but it was never completed or used.

// will be the beginning of the encoded arguments.
// This index is the first position after the opcode and address.
// If the e-expression has a length prefix, it will begin at this position in `input`.
length_offset: u8,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ This type had 6 bytes of padding, so adding another u8 field did not increase its size.

Comment on lines +966 to +968
// There is no length prefix, so we re-use the bitmap_offset as the first position
// beyond the opcode and address subfields.
bitmap_offset as u8,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ This is in the parser for e-expressions with combined opcode+address bytes. There is never a length prefix.

@@ -996,6 +999,7 @@ impl<'a> BinaryBuffer<'a> {
})?
.reference();
// Offset from `self`, not offset from the beginning of the stream.
let length_offset = (input_after_address.offset() - self.offset()) as u8;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ This is in the parser for 0xF5, e-expression w/length prefix.

Comment on lines 92 to 93
// If these offsets are equal, there are no bytes representing the length.
self.length_offset == self.bitmap_offset
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// If these offsets are equal, there are no bytes representing the length.
self.length_offset == self.bitmap_offset
// If these offsets are equal, there are no bytes representing the length.
self.length_offset != self.bitmap_offset

If I'm reading this correctly. Though this function does appear unused.

src/lazy/binary/raw/v1_1/e_expression.rs Outdated Show resolved Hide resolved
@zslayton zslayton merged commit d665f9b into main Nov 7, 2024
33 checks passed
@zslayton zslayton deleted the encoded-eexp branch November 7, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants