aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/darray.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-23 16:00:11 +0200
committerBad Diode <bd@badd10de.dev>2021-10-23 16:00:11 +0200
commitc3fe9367986520b08a36bf693e6c74eb309377c5 (patch)
tree1974c0cb59a61131c9440fb58757109090ad4cd6 /src/bytecode/darray.h
parent13f795f8f8aa302ee36ca3974fb80dba29240240 (diff)
downloadbdl-c3fe9367986520b08a36bf693e6c74eb309377c5.tar.gz
bdl-c3fe9367986520b08a36bf693e6c74eb309377c5.zip
Cleanup macros for arithmetic ops
Diffstat (limited to 'src/bytecode/darray.h')
-rwxr-xr-xsrc/bytecode/darray.h3
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))))