From c3fe9367986520b08a36bf693e6c74eb309377c5 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sat, 23 Oct 2021 16:00:11 +0200 Subject: Cleanup macros for arithmetic ops --- src/bytecode/darray.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/bytecode/darray.h') 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 { // Return the last element of the array. Can be used to build stacks. #define array_pop(ARR) (ARR)[--array_head(ARR)->size] +// Return the value stored at the OFFSET position from the tail of the array. +#define array_peek(ARR, OFFSET) (ARR)[array_head(ARR)->size - 1 - (OFFSET)] + // Insert N bytes from the SRC array into the ARR dynamic array. #define array_insert(ARR, SRC, N) \ ((ARR) = _array_insert(ARR, SRC, N, sizeof(*(ARR)))) -- cgit v1.2.1