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

Slices #99

Closed
mikeday opened this issue Feb 23, 2018 · 0 comments
Closed

Slices #99

mikeday opened this issue Feb 23, 2018 · 0 comments
Assignees
Labels
A-type-system C-feature E-medium obsolete Cleaning up the backlog on 2020-10-09.

Comments

@mikeday
Copy link
Contributor

mikeday commented Feb 23, 2018

Based on our discussion today about offsets and slices:

Add a binary type for slices that takes a length, the binary type that it should be parsed as, and some optional flags. A slice occupies the same space as [u8; len] but will be parsed as a different binary type. The optional flags can specify whether this binary type must occupy the entire slice or whether there can be trailing bytes left over, and whether links from within the slice can go outside of it. Parsing an entire file can then be considered equivalent to parsing a self-contained slice of the same size.

A label or address type is a zero-length binary type which evaluates to the host value of the current address. An address value can be used as the base address of an offset to create a link.

A link type is a zero-length binary type which takes an address and another binary type to parse at that address. This other binary type can potentially be a slice, so you could have:

offset: u32,
length: u32,
table: link(make_address(base, offset), slice(length, table_type(tag), SelfContained))

Assuming that table_type is a type-level function that maps tag values to binary types, make_address is an expression-level function that combines an address with an integer to make a new address, and SelfContained is a flag indicating that links within this slice cannot go outside it.

brendanzab added a commit that referenced this issue Jul 27, 2018
Some ickiness left over from #99
brendanzab added a commit that referenced this issue Aug 13, 2018
Some ickiness left over from #99
@toothbrush toothbrush added the obsolete Cleaning up the backlog on 2020-10-09. label Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system C-feature E-medium obsolete Cleaning up the backlog on 2020-10-09.
Projects
None yet
Development

No branches or pull requests

4 participants