From 05540fc6038f452f5dc5f18412c918c33ad96027 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Thu, 16 Feb 2023 14:32:56 -0800 Subject: changed project structure --- src/scope.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/scope.c (limited to 'src/scope.c') 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 +#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; +} -- cgit v1.3.1