aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-01-16 11:27:23 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2025-01-16 11:27:23 +0200
commit8b8ed7282a0fa5e17b83f0eaae404aa5f231b66a (patch)
tree15ce178c691d2df7829973e595ebdb84732276b1 /include
parent4d812e9b9bcf2530ab5a3275be85365ee277bea8 (diff)
downloadek-8b8ed7282a0fa5e17b83f0eaae404aa5f231b66a.tar.gz
ek-8b8ed7282a0fa5e17b83f0eaae404aa5f231b66a.zip
start adding exported defs
Diffstat (limited to 'include')
-rw-r--r--include/ek/compiler.h2
-rw-r--r--include/ek/scope.h26
-rw-r--r--include/ek/sptree.h3
3 files changed, 16 insertions, 15 deletions
diff --git a/include/ek/compiler.h b/include/ek/compiler.h
index cbe34e2..4afddb6 100644
--- a/include/ek/compiler.h
+++ b/include/ek/compiler.h
@@ -31,6 +31,6 @@ int compile(const char *input);
* @param file File to process.
* @return \c 0 if compilation was succesful, otherwise some non-zero value.
*/
-int process_file(struct scope **parent, int public, const char *file);
+struct scope *process_file(const char *file);
#endif /* EK_COMPILER_H */
diff --git a/include/ek/scope.h b/include/ek/scope.h
index ab27cc6..d8a5974 100644
--- a/include/ek/scope.h
+++ b/include/ek/scope.h
@@ -55,6 +55,11 @@ static inline int expanded_key_cmp(struct expanded_key a, struct expanded_key b)
#define MAP_NAME expanded
#include "map.h"
+#define SPTREE_TYPE struct ast *
+#define SPTREE_CMP(a, b) ((uintptr_t)(a) - (uintptr_t)(b))
+#define SPTREE_NAME exported
+#include "sptree.h"
+
/**
* Scope.
* Responsible for keeping track of visibilities and
@@ -87,6 +92,10 @@ struct scope {
struct visible symbols;
struct visible macros;
struct visible types;
+
+ struct exported exported_symbols;
+ struct exported exported_macros;
+ struct exported exported_types;
};
/**
@@ -105,15 +114,6 @@ struct scope *create_scope();
void destroy_scope(struct scope *scope);
/**
- * Add a scratch AST node.
- *
- * @param scope Scope to add scratch AST node to.
- * @param scratch Scratch node to add to \p scope.
- * @return \c 0 when successful, non-zero otherwise.
- */
-int scope_add_scratch(struct scope *scope, struct ast *scratch);
-
-/**
* Set scope flags.
*
* @param scope Scope to set flags for.
@@ -336,10 +336,8 @@ struct ast *file_scope_find_trait(struct scope *scope, char *id);
struct ast *file_scope_find_expd_struct(struct scope *scope, struct ast *def,
struct type *types);
-#define foreach_visible(iter, init) \
- for (struct visible *iter = init; iter; iter = iter->next)
-
-#define foreach_expanded(iter, init) \
- for (struct expanded *iter = init; iter; iter = iter->next)
+bool is_exported_type(struct scope *scope, struct ast *def);
+bool is_exported_symbol(struct scope *scope, struct ast *def);
+bool is_exported_macro(struct scope *scope, struct ast *def);
#endif /* SCOPE_H */
diff --git a/include/ek/sptree.h b/include/ek/sptree.h
index 8dfdfbf..8ba6d6c 100644
--- a/include/ek/sptree.h
+++ b/include/ek/sptree.h
@@ -73,6 +73,9 @@ static inline struct SPNODE *SPTREE(last)(struct SPNODE *n)
static inline SPTREE_TYPE *SPTREE(begin)(struct SPROOT *s)
{
+ if (SPTREE(len)(s) == 0)
+ return NULL;
+
return &SPTREE(first)(s->root)->data;
}