| 
    Prism Ruby parser
    
   | 
 
A data structure that stores a set of strings. More...
#include "prism/defines.h"#include <assert.h>#include <stdbool.h>#include <stdint.h>#include <stdlib.h>#include <string.h>

Go to the source code of this file.
Data Structures | |
| struct | pm_constant_id_list_t | 
| A list of constant IDs.  More... | |
| struct | pm_constant_pool_bucket_t | 
| A bucket in the hash map.  More... | |
| struct | pm_constant_t | 
| A constant in the pool which effectively stores a string.  More... | |
| struct | pm_constant_pool_t | 
| The overall constant pool, which stores constants found while parsing.  More... | |
Macros | |
| #define | PM_CONSTANT_ID_UNSET 0 | 
| When we allocate constants into the pool, we reserve 0 to mean that the slot is not yet filled.   | |
Typedefs | |
| typedef uint32_t | pm_constant_id_t | 
| A constant id is a unique identifier for a constant in the constant pool.  | |
| typedef unsigned int | pm_constant_pool_bucket_type_t | 
| The type of bucket in the constant pool hash map.   | |
Functions | |
| void | pm_constant_id_list_init (pm_constant_id_list_t *list) | 
| Initialize a list of constant ids.   | |
| void | pm_constant_id_list_init_capacity (pm_constant_id_list_t *list, size_t capacity) | 
| Initialize a list of constant ids with a given capacity.   | |
| bool | pm_constant_id_list_append (pm_constant_id_list_t *list, pm_constant_id_t id) | 
| Append a constant id to a list of constant ids.   | |
| void | pm_constant_id_list_insert (pm_constant_id_list_t *list, size_t index, pm_constant_id_t id) | 
| Insert a constant id into a list of constant ids at the specified index.   | |
| bool | pm_constant_id_list_includes (pm_constant_id_list_t *list, pm_constant_id_t id) | 
| Checks if the current constant id list includes the given constant id.   | |
| void | pm_constant_id_list_free (pm_constant_id_list_t *list) | 
| Free the memory associated with a list of constant ids.   | |
| bool | pm_constant_pool_init (pm_constant_pool_t *pool, uint32_t capacity) | 
| Initialize a new constant pool with a given capacity.   | |
| pm_constant_t * | pm_constant_pool_id_to_constant (const pm_constant_pool_t *pool, pm_constant_id_t constant_id) | 
| Return a pointer to the constant indicated by the given constant id.   | |
| pm_constant_id_t | pm_constant_pool_find (const pm_constant_pool_t *pool, const uint8_t *start, size_t length) | 
| Find a constant in a constant pool.   | |
| pm_constant_id_t | pm_constant_pool_insert_shared (pm_constant_pool_t *pool, const uint8_t *start, size_t length) | 
| Insert a constant into a constant pool that is a slice of a source string.   | |
| pm_constant_id_t | pm_constant_pool_insert_owned (pm_constant_pool_t *pool, uint8_t *start, size_t length) | 
| Insert a constant into a constant pool from memory that is now owned by the constant pool.   | |
| pm_constant_id_t | pm_constant_pool_insert_constant (pm_constant_pool_t *pool, const uint8_t *start, size_t length) | 
| Insert a constant into a constant pool from memory that is constant.   | |
| void | pm_constant_pool_free (pm_constant_pool_t *pool) | 
| Free the memory associated with a constant pool.   | |
A data structure that stores a set of strings.
Each string is assigned a unique id, which can be used to compare strings for equality. This comparison ends up being much faster than strcmp, since it only requires a single integer comparison.
| #define PM_CONSTANT_ID_UNSET 0 | 
When we allocate constants into the pool, we reserve 0 to mean that the slot is not yet filled.
This constant is reused in other places to indicate the lack of a constant id.
| typedef unsigned int pm_constant_pool_bucket_type_t | 
The type of bucket in the constant pool hash map.
This determines how the bucket should be freed.
| void pm_constant_id_list_init | ( | pm_constant_id_list_t * | list | ) | 
Initialize a list of constant ids.
| list | The list to initialize. | 
| void pm_constant_id_list_init_capacity | ( | pm_constant_id_list_t * | list, | 
| size_t | capacity | ||
| ) | 
Initialize a list of constant ids with a given capacity.
| list | The list to initialize. | 
| capacity | The initial capacity of the list. | 
| bool pm_constant_id_list_append | ( | pm_constant_id_list_t * | list, | 
| pm_constant_id_t | id | ||
| ) | 
Append a constant id to a list of constant ids.
Returns false if any potential reallocations fail.
| list | The list to append to. | 
| id | The id to append. | 
Returns false if any potential reallocations fail.
| void pm_constant_id_list_insert | ( | pm_constant_id_list_t * | list, | 
| size_t | index, | ||
| pm_constant_id_t | id | ||
| ) | 
Insert a constant id into a list of constant ids at the specified index.
| list | The list to insert into. | 
| index | The index at which to insert. | 
| id | The id to insert. | 
| bool pm_constant_id_list_includes | ( | pm_constant_id_list_t * | list, | 
| pm_constant_id_t | id | ||
| ) | 
Checks if the current constant id list includes the given constant id.
| list | The list to check. | 
| id | The id to check for. | 
| void pm_constant_id_list_free | ( | pm_constant_id_list_t * | list | ) | 
Free the memory associated with a list of constant ids.
| list | The list to free. | 
| bool pm_constant_pool_init | ( | pm_constant_pool_t * | pool, | 
| uint32_t | capacity | ||
| ) | 
Initialize a new constant pool with a given capacity.
| pool | The pool to initialize. | 
| capacity | The initial capacity of the pool. | 
| pm_constant_t * pm_constant_pool_id_to_constant | ( | const pm_constant_pool_t * | pool, | 
| pm_constant_id_t | constant_id | ||
| ) | 
Return a pointer to the constant indicated by the given constant id.
| pool | The pool to get the constant from. | 
| constant_id | The id of the constant to get. | 
| pm_constant_id_t pm_constant_pool_find | ( | const pm_constant_pool_t * | pool, | 
| const uint8_t * | start, | ||
| size_t | length | ||
| ) | 
Find a constant in a constant pool.
Returns the id of the constant, or 0 if the constant is not found.
| pool | The pool to find the constant in. | 
| start | A pointer to the start of the constant. | 
| length | The length of the constant. | 
Returns the id of the constant, or 0 if the constant is not found.
| pm_constant_id_t pm_constant_pool_insert_shared | ( | pm_constant_pool_t * | pool, | 
| const uint8_t * | start, | ||
| size_t | length | ||
| ) | 
Insert a constant into a constant pool that is a slice of a source string.
Returns the id of the constant, or 0 if any potential calls to resize fail.
| pool | The pool to insert the constant into. | 
| start | A pointer to the start of the constant. | 
| length | The length of the constant. | 
Insert a constant into a constant pool that is a slice of a source string.
Returns the id of the constant, or PM_CONSTANT_ID_UNSET if any potential calls to resize fail.
| pm_constant_id_t pm_constant_pool_insert_owned | ( | pm_constant_pool_t * | pool, | 
| uint8_t * | start, | ||
| size_t | length | ||
| ) | 
Insert a constant into a constant pool from memory that is now owned by the constant pool.
Returns the id of the constant, or 0 if any potential calls to resize fail.
| pool | The pool to insert the constant into. | 
| start | A pointer to the start of the constant. | 
| length | The length of the constant. | 
Returns the id of the constant, or PM_CONSTANT_ID_UNSET if any potential calls to resize fail.
| pm_constant_id_t pm_constant_pool_insert_constant | ( | pm_constant_pool_t * | pool, | 
| const uint8_t * | start, | ||
| size_t | length | ||
| ) | 
Insert a constant into a constant pool from memory that is constant.
Returns the id of the constant, or 0 if any potential calls to resize fail.
| pool | The pool to insert the constant into. | 
| start | A pointer to the start of the constant. | 
| length | The length of the constant. | 
Returns the id of the constant, or PM_CONSTANT_ID_UNSET if any potential calls to resize fail.
| void pm_constant_pool_free | ( | pm_constant_pool_t * | pool | ) | 
Free the memory associated with a constant pool.
| pool | The pool to free. |