Skip to content

Instantly share code, notes, and snippets.

@paniq
Last active August 20, 2024 09:58
Show Gist options
  • Save paniq/1fbaa66c70b48edbccdb706656117d66 to your computer and use it in GitHub Desktop.
Save paniq/1fbaa66c70b48edbccdb706656117d66 to your computer and use it in GitHub Desktop.
arcmem heap object format (human-readable)
// top level is a throwaway heap object
// first heap object to be declared at the top level is the root object
// aligned concat (using alignment of token2)
<token1> , <token2>
// 1-byte packed concat (token2 alignment is treated as if 1)
<token1> <token2>
// zero-pad stream to largest aligned member since last statement or beginning of scope (struct alignment)
;
// concat zero-terminated string token (1 byte al)
"bleh"
// concat unterminated string token (1 byte al)
'bleh'
// concat little-endian integer (variable al); default is `s32`
// 0x, 0b select base 16, 2; suffix :s16 :u16 etc. selects alignment, sign-extension
1234
// concat float or double (4/8 byte al); default is `f32`
// 0x selects base 16
1234.0:f32, 1234.0:f64
// allocates one heap object and concat pointer to it to the parent (8 byte al)
{ ... }
// concat null pointer (8 byte al)
null
// declare a pointer label to this offset within an object, concat nothing
*label
// concat a hard pointer (8-byte al)
label
// concat a soft pointer (8-byte al)
~label
// concat a hard offset pointer (8-byte al)
label+<offset>
// concat a soft offset pointer (8-byte al)
~label+<offset>
// concat inline from pointered data from byte offset `start` to end of object
label[<start>:]
// concat inline `end` bytes from pointered data
label[:<end>]
// concat inline a slice from pointered data
label[<start>:<end>]
// concat inline pointered data until next label
label[:]
// concat inline pointered data entirely
label[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment