aboutsummaryrefslogtreecommitdiff
path: root/flatcc/src/compiler/hash_tables/symbol_table.c
blob: bc13d8ad674df1854302270523c5fbef49322635 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 /* Note: only one hash table can be implemented a single file. */
#include "../symbols.h"
#include "hash/hash_table_def.h"
DEFINE_HASH_TABLE(fb_symbol_table)
#include "hash/hash_table_impl.h"

static inline int ht_match(const void *key, size_t len, fb_symbol_t *sym)
{
    return len == ht_key_len(sym) && memcmp(key, ht_key(sym), len) == 0;
}

static inline const void *ht_key(fb_symbol_t *sym)
{
    return sym->ident->text;
}

static inline size_t ht_key_len(fb_symbol_t *sym)
{
    fb_token_t *ident = sym->ident;

    return (size_t)ident->len;
}