|
libsnobol4 1.0.2
High-performance SNOBOL4-style pattern matching library
|
Dynamic pattern objects and canonical cache keys. More...


Go to the source code of this file.
Classes | |
| struct | dynamic_pattern |
| struct | dynamic_pattern_cache_key_t |
| struct | dynamic_pattern_cache_entry |
| struct | dynamic_pattern_cache_t |
Typedefs | |
| typedef struct snobol_table | snobol_table_t |
| Associative table (opaque handle). | |
| typedef struct dynamic_pattern | dynamic_pattern_t |
| typedef struct dynamic_pattern_cache_entry | dynamic_pattern_cache_entry_t |
Functions | |
| dynamic_pattern_t * | dynamic_pattern_create (const char *source, uint8_t *bc, size_t bc_len) |
| Create a new dynamic pattern object. | |
| dynamic_pattern_t * | dynamic_pattern_retain (dynamic_pattern_t *pattern) |
| Increment dynamic pattern reference count. | |
| void | dynamic_pattern_release (dynamic_pattern_t *pattern) |
| Decrement reference count and free if zero. | |
| const dynamic_pattern_cache_key_t * | dynamic_pattern_compute_key (const char *source, size_t source_len, dynamic_pattern_cache_key_t *out_key) |
| Compute canonical cache key from source string. | |
| bool | dynamic_pattern_cache_init (dynamic_pattern_cache_t *cache, size_t max_size) |
| Initialize dynamic pattern cache. | |
| void | dynamic_pattern_cache_destroy (dynamic_pattern_cache_t *cache) |
| Destroy cache and free all entries. | |
| dynamic_pattern_t * | dynamic_pattern_cache_get (dynamic_pattern_cache_t *cache, const char *source, int source_len) |
| Look up a pattern in the cache. | |
| bool | dynamic_pattern_cache_put (dynamic_pattern_cache_t *cache, const char *source, dynamic_pattern_t *pattern) |
| Insert a pattern into the cache. | |
| bool | dynamic_pattern_cache_remove (dynamic_pattern_cache_t *cache, const char *source, int source_len) |
| Remove a pattern from the cache. | |
| void | dynamic_pattern_cache_clear (dynamic_pattern_cache_t *cache) |
| Clear all entries from the cache. | |
| void | dynamic_pattern_cache_stats (const dynamic_pattern_cache_t *cache, size_t *out_size, size_t *out_max) |
| Get cache statistics. | |
| uint32_t | dynamic_pattern_hash_source (const char *source, size_t len) |
| Hash function for pattern sources. | |
Dynamic pattern objects and canonical cache keys.
Ownership/Lifetime Rules:
Retain/Release Semantics:
Cache Ownership Rules:
Execution Lifecycle (VM):
Success Path:
Failure Path:
Definition in file dynamic_pattern.h.
| typedef struct dynamic_pattern_cache_entry dynamic_pattern_cache_entry_t |
Dynamic pattern cache entry
| typedef struct dynamic_pattern dynamic_pattern_t |
Dynamic pattern object
Represents a pattern that was compiled at runtime from a string or AST. The bytecode is owned by this object and freed when refcount reaches 0.
| typedef struct snobol_table snobol_table_t |
Associative table (opaque handle).
Runtime-owned string-keyed hash table for table-backed substitutions.
Definition at line 65 of file dynamic_pattern.h.
| void dynamic_pattern_cache_clear | ( | dynamic_pattern_cache_t * | cache | ) |
Clear all entries from the cache.
| cache | Cache to clear |
| void dynamic_pattern_cache_destroy | ( | dynamic_pattern_cache_t * | cache | ) |
Destroy cache and free all entries.
| cache | Cache to destroy |
| dynamic_pattern_t * dynamic_pattern_cache_get | ( | dynamic_pattern_cache_t * | cache, |
| const char * | source, | ||
| int | source_len ) |
Look up a pattern in the cache.
| cache | Cache to query |
| source | Source string |
| source_len | Length of source (or -1 for strlen) |
Ownership: Caller must call dynamic_pattern_release() when done
| bool dynamic_pattern_cache_init | ( | dynamic_pattern_cache_t * | cache, |
| size_t | max_size ) |
Initialize dynamic pattern cache.
| cache | Cache to initialize |
| max_size | Maximum entries before eviction (0 = default) |
| bool dynamic_pattern_cache_put | ( | dynamic_pattern_cache_t * | cache, |
| const char * | source, | ||
| dynamic_pattern_t * | pattern ) |
Insert a pattern into the cache.
| cache | Cache to modify |
| source | Source string (copied) |
| pattern | Pattern to cache (reference retained) |
Ownership: Cache retains its own reference to the pattern
| bool dynamic_pattern_cache_remove | ( | dynamic_pattern_cache_t * | cache, |
| const char * | source, | ||
| int | source_len ) |
Remove a pattern from the cache.
| cache | Cache to modify |
| source | Source string to remove |
| source_len | Length of source (or -1 for strlen) |
| void dynamic_pattern_cache_stats | ( | const dynamic_pattern_cache_t * | cache, |
| size_t * | out_size, | ||
| size_t * | out_max ) |
Get cache statistics.
| cache | Cache to query |
| out_size | Output: current number of entries |
| out_max | Output: maximum entries |
| const dynamic_pattern_cache_key_t * dynamic_pattern_compute_key | ( | const char * | source, |
| size_t | source_len, | ||
| dynamic_pattern_cache_key_t * | out_key ) |
Compute canonical cache key from source string.
| source | Source string |
| source_len | Length of source (or -1 for strlen) |
| out_key | Output: cache key structure |
| dynamic_pattern_t * dynamic_pattern_create | ( | const char * | source, |
| uint8_t * | bc, | ||
| size_t | bc_len ) |
Create a new dynamic pattern object.
| source | Source string (copied) |
| bc | Compiled bytecode (ownership transferred) |
| bc_len | Length of bytecode |
Ownership: Caller owns the returned pattern and must call dynamic_pattern_release() The bytecode pointer is adopted by the pattern (do not free separately)
| uint32_t dynamic_pattern_hash_source | ( | const char * | source, |
| size_t | len ) |
Hash function for pattern sources.
| source | Source string |
| len | Length of source |
| void dynamic_pattern_release | ( | dynamic_pattern_t * | pattern | ) |
Decrement reference count and free if zero.
| pattern | Pattern to release |
| dynamic_pattern_t * dynamic_pattern_retain | ( | dynamic_pattern_t * | pattern | ) |
Increment dynamic pattern reference count.
| pattern | Pattern to retain |