|
Ruby 4.1.0dev (2026-03-28 revision 6035121c933c965cebf93f624066c95dabbc6d1d)
|
A list of byte offsets of newlines in a string. More...
#include "prism/compiler/exported.h"#include "prism/compiler/nonnull.h"#include <stddef.h>#include <stdint.h>

Go to the source code of this file.
Data Structures | |
| struct | pm_line_offset_list_t |
| A list of offsets of the start of lines in a string. More... | |
| struct | pm_line_column_t |
| A line and column in a string. More... | |
Functions | |
| PRISM_EXPORTED_FUNCTION pm_line_column_t | pm_line_offset_list_line_column (const pm_line_offset_list_t *list, uint32_t cursor, int32_t start_line) PRISM_NONNULL(1) |
| Returns the line and column of the given offset. | |
A list of byte offsets of newlines in a string.
When compiling the syntax tree, it's necessary to know the line and column of many nodes. This is necessary to support things like error messages, tracepoints, etc.
It's possible that we could store the start line, start column, end line, and end column on every node in addition to the offsets that we already store, but that would be quite a lot of memory overhead.
Definition in file line_offset_list.h.
| PRISM_EXPORTED_FUNCTION pm_line_column_t pm_line_offset_list_line_column | ( | const pm_line_offset_list_t * | list, |
| uint32_t | cursor, | ||
| int32_t | start_line | ||
| ) |
Returns the line and column of the given offset.
If the offset is not in the list, the line and column of the closest offset less than the given offset are returned.
| list | The list to search. |
| cursor | The offset to search for. |
| start_line | The line to start counting from. |
If the offset is not in the list, the line and column of the closest offset less than the given offset are returned.
Definition at line 78 of file line_offset_list.c.