diff options
Diffstat (limited to 'src/scope.h')
-rw-r--r-- | src/scope.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/scope.h b/src/scope.h new file mode 100644 index 0000000..bce3567 --- /dev/null +++ b/src/scope.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2023 Carlos Maniero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +#include "ast.h" +#include "string_view.h" +#include "vector.h" + +typedef struct scope_t +{ + vector_t *stack; +} scope_t; + +typedef struct scope_item_t +{ + ast_identifier_t *identifier; + ast_node_t *node; +} scope_item_t; + +scope_t * +scope_new(); + +void +scope_destroy(scope_t *scope); + +void +scope_enter(scope_t *scope); +void +scope_leave(scope_t *scope); + +ast_node_t * +scope_get(scope_t *scope, ast_identifier_t *identifier); +void +scope_push(scope_t *scope, ast_identifier_t *identifier, ast_node_t *node); |