diff options
| author | Carson Fleming <cflems@cflems.net> | 2026-03-26 20:27:19 -0700 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2026-03-26 20:28:40 -0700 |
| commit | 21f688c1eac5fb09ae68fd9b3cfcff687de36601 (patch) | |
| tree | 66b819149532a58cec305cec73b916f9d3025f88 /scope.c | |
| parent | 59a0cdabe9a67d5c3f296f85d29f43dcadace363 (diff) | |
| download | ccc-21f688c1eac5fb09ae68fd9b3cfcff687de36601.tar.gz | |
scope inheritance
Diffstat (limited to 'scope.c')
| -rw-r--r-- | scope.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -84,10 +84,13 @@ bool scope_get_type( struct type_def* p_entry, const char* name ) { - struct type_def* type_def = *type_cell(scope, name); - if (type_def == NULL) return false; - *p_entry = *type_def; - return true; + for (; scope != NULL; scope = scope->next_out) { + struct type_def* type_def = *type_cell(scope, name); + if (type_def == NULL) continue; + *p_entry = *type_def; + return true; + } + return false; } void scope_define_type(struct scope* scope, struct type_def type) { @@ -109,10 +112,13 @@ bool scope_get_var( struct var_def* p_entry, const char* name ) { - struct var_def* var_def = *var_cell(scope, name); - if (var_def == NULL) return false; - *p_entry = *var_def; - return true; + for (; scope != NULL; scope = scope->next_out) { + struct var_def* var_def = *var_cell(scope, name); + if (var_def == NULL) continue; + *p_entry = *var_def; + return true; + } + return false; } void scope_define_var(struct scope* scope, struct var_def var) { |
