| 205 | } |
| 206 | |
| 207 | void builtin_table_get_key ( void * result, const Table & tab, const void * value_ptr, int32_t value_stride, int32_t key_stride, Context * __context__, LineInfoArg * at ) { |
| 208 | const char * vp = (const char *)value_ptr; |
| 209 | if ( vp < tab.data || vp >= tab.data + tab.capacity * value_stride ) { |
| 210 | __context__->throw_error_at(at, "get_key: value pointer is not inside the table"); |
| 211 | return; |
| 212 | } |
| 213 | ptrdiff_t offset = vp - tab.data; |
| 214 | if ( offset % value_stride != 0 ) { |
| 215 | __context__->throw_error_at(at, "get_key: value pointer is not aligned to value stride"); |
| 216 | return; |
| 217 | } |
| 218 | ptrdiff_t index = offset / value_stride; |
| 219 | if ( !tableLiveSlot(tab, (uint64_t)index) ) { |
| 220 | __context__->throw_error_at(at, "get_key: value points to an empty or deleted table slot"); |
| 221 | return; |
| 222 | } |
| 223 | memcpy(result, tab.keys + index * key_stride, key_stride); |
| 224 | } |
| 225 | |
| 226 | // delete |
| 227 |
nothing calls this directly
no test coverage detected