diff options
author | Bad Diode <bd@badd10de.dev> | 2021-10-23 16:00:11 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-10-23 16:00:11 +0200 |
commit | c3fe9367986520b08a36bf693e6c74eb309377c5 (patch) | |
tree | 1974c0cb59a61131c9440fb58757109090ad4cd6 /src/bytecode/darray.h | |
parent | 13f795f8f8aa302ee36ca3974fb80dba29240240 (diff) | |
download | bdl-c3fe9367986520b08a36bf693e6c74eb309377c5.tar.gz bdl-c3fe9367986520b08a36bf693e6c74eb309377c5.zip |
Cleanup macros for arithmetic ops
Diffstat (limited to 'src/bytecode/darray.h')
-rwxr-xr-x | src/bytecode/darray.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/bytecode/darray.h b/src/bytecode/darray.h index db6234d..e8cdc36 100755 --- a/src/bytecode/darray.h +++ b/src/bytecode/darray.h | |||
@@ -25,6 +25,9 @@ typedef struct ArrayHeader { | |||
25 | // Return the last element of the array. Can be used to build stacks. | 25 | // Return the last element of the array. Can be used to build stacks. |
26 | #define array_pop(ARR) (ARR)[--array_head(ARR)->size] | 26 | #define array_pop(ARR) (ARR)[--array_head(ARR)->size] |
27 | 27 | ||
28 | // Return the value stored at the OFFSET position from the tail of the array. | ||
29 | #define array_peek(ARR, OFFSET) (ARR)[array_head(ARR)->size - 1 - (OFFSET)] | ||
30 | |||
28 | // Insert N bytes from the SRC array into the ARR dynamic array. | 31 | // Insert N bytes from the SRC array into the ARR dynamic array. |
29 | #define array_insert(ARR, SRC, N) \ | 32 | #define array_insert(ARR, SRC, N) \ |
30 | ((ARR) = _array_insert(ARR, SRC, N, sizeof(*(ARR)))) | 33 | ((ARR) = _array_insert(ARR, SRC, N, sizeof(*(ARR)))) |