82 {
83
87
88
89
90
91
92 for (;;) {
94
95
96 int len = snprintf(nullptr, 0, "gensym_%" PRIu64, id);
97 PANIC_IF(len < 0,
"This should never happen!");
98
99
101 (void)snprintf(name, len + 1, "gensym_%" PRIu64, id);
102
105
109 continue;
110 }
111
112
113
114
116
119 return sym;
120 }
121}
void * srn_allocate(const srn_context_t *ctx, size_t size, size_t alignment)
#define AS_STRING(value_ref)
srn_object_id_t srn_allocate_object_id(srn_engine_t *engine)
hmap_t hmap_insert(const hmap_t *hmap, hmap_key_t *k, void *v)
Insert the given key k with the value v in the given hash hmap and return the new map.
void * hmap_lookup(const hmap_t *hmap, const hmap_key_t *k, void *default_value)
Lookup the given k in the given hmap and return the value if it's been found.
srn_value_t * srn_string_make(srn_context_t *ctx, srn_metadata_t *metadata, const char *src)
Create a string from a null terminated C string.
Note: For key equality we use the memcpy function.
srn_engine_t * engine
Long term state of the compiler.
srn_context_t * root_context
hmap_t sym_table
A mapping symbol names to (srn_value_t with type symbol).
srn_spinlock_t sym_table_lock
srn_value_t * srn_symbol_make(srn_context_t *ctx, srn_metadata_t *metadata, srn_namespace_t *ns, srn_string_t *name)
Create a new symbol. IT DOES NOT INTERNALIZE THE SYMBOL.
#define PANIC_IF_NULL(ptr)
static void srn_spinlock_lock(srn_spinlock_t *lock)
#define PANIC_IF(cond, msg)
static void srn_spinlock_unlock(srn_spinlock_t *lock)