summaryrefslogtreecommitdiff
path: root/Scope.h
blob: f4fc4987ab8f91d7869bf5e9698be4d02a0485f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once
#include <xxhash.h>

#define SCOPE_WORD_MAX 256

/* member strings are borrowed and shouldn't be freed by the node */
typedef struct Scope Scope;
struct Scope {
	int used;
	const char *words[SCOPE_WORD_MAX];
	int values[SCOPE_WORD_MAX];
	XXH32_hash_t words_hash[SCOPE_WORD_MAX];
	const Scope *parent;
};

/* created pointer shall be manualy freed by caller */
Scope *scope_create(const Scope *parent);
int scope_insert(Scope *scope, const char *word, int value);