diff options
Diffstat (limited to 'scope.c')
| -rw-r--r-- | scope.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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(char* key, scope_t* scope) { + while (scope->parent != NULL) { + pair_t* pair = hashtable_get_pair(scope->hashtable, key); + if (pair != NULL) { + return pair; + } + scope = scope->parent; + } + return NULL; +} |
