summaryrefslogtreecommitdiff
path: root/Scope.h
blob: e5adacd7ad065cbc46819cc9a94ea6510a0c8e2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#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;
};

Scope *scope_create(const Scope *parent);
int scope_insert(Scope *scope, const char *word, int value);