diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2023-02-16 14:32:56 -0800 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2023-02-16 14:32:56 -0800 |
| commit | 05540fc6038f452f5dc5f18412c918c33ad96027 (patch) | |
| tree | bb9f572a1cc6f3a66cbf9835593f62db87481e0a /src/scope.c | |
| parent | 10a1f7e4ad1bc90436f58269a52cddfd0587be33 (diff) | |
changed project structure
Diffstat (limited to 'src/scope.c')
| -rw-r--r-- | src/scope.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/scope.c b/src/scope.c new file mode 100644 index 0000000..afb9d5c --- /dev/null +++ b/src/scope.c @@ -0,0 +1,20 @@ +#include <stdlib.h> +#include "scope.h" +#include "hashtable.h" + +scope_t* init_scope(scope_t parent) { + scope_t* scope = malloc(sizeof(scope_t)); + scope->hashtable = init_hashtable(1000); + *(scope->parent) = parent; + return scope; +} +pair_t* get_pair_global(scope_t* scope, char* key) { + while (scope->parent != NULL) { + pair_t* pair = hashtable_get_pair(scope->hashtable, key); + if (pair != NULL) { + return pair; + } + scope = scope->parent; + } + return NULL; +} |
