aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ast.h8
-rw-r--r--include/compiler.h2
-rw-r--r--include/parser.h4
-rw-r--r--include/std/buffer.h4
4 files changed, 15 insertions, 3 deletions
diff --git a/include/ast.h b/include/ast.h
index 29a0b64..7911a59 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -15,6 +15,7 @@ typedef struct String String;
typedef struct Variable Variable;
typedef struct Number Number;
typedef struct Binop Binop;
+typedef struct Scope Scope;
typedef union {
FunctionDecl *func_decl;
@@ -89,15 +90,20 @@ struct Binop {
bool grouped;
};
+struct Scope {
+ Buffer ast_objects;
+};
+
Ast ast_none();
CHECK_RESULT int funcdecl_init(FunctionDecl *self, ScopedAllocator *allocator);
-CHECK_RESULT int funcdecl_add_to_body(FunctionDecl *self, Ast ast);
CHECK_RESULT int funccall_init(FunctionCall *self, BufferView name, ScopedAllocator *allocator);
void lhsexpr_init(LhsExpr *self, int isConst, BufferView var_name);
void import_init(Import *self, BufferView path);
CHECK_RESULT int string_init(String *self, BufferView str);
void number_init(Number *self, i64 value, bool is_integer);
void binop_init(Binop *self);
+CHECK_RESULT int scope_init(Scope *self, ScopedAllocator *allocator);
+void scope_resolve(Scope *self);
#endif
diff --git a/include/compiler.h b/include/compiler.h
index d01c756..d7314cc 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -21,10 +21,12 @@ struct amal_compiler {
int usable_thread_count;
bool started;
amal_mutex mutex;
+ int resolve_ast_index;
};
CHECK_RESULT int amal_compiler_init(amal_compiler *self);
CHECK_RESULT int amal_compiler_deinit(amal_compiler *self);
+/* Not thread-safe */
CHECK_RESULT int amal_compiler_load_file(amal_compiler *self, BufferView filepath);
/* TODO: amal_compiler_unload_file */
diff --git a/include/parser.h b/include/parser.h
index b9fb3b7..5c055d9 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -1,11 +1,11 @@
#ifndef AMALGAM_PARSER_H
#define AMALGAM_PARSER_H
-#include "std/buffer.h"
#include "std/buffer_view.h"
#include "std/scoped_allocator.h"
#include "std/thread.h"
#include "tokenizer.h"
+#include "ast.h"
#include "defs.h"
#include <setjmp.h>
@@ -34,7 +34,7 @@ typedef enum {
typedef struct {
Tokenizer tokenizer;
- Buffer ast_objects;
+ Scope scope;
ScopedAllocator *allocator; /* borrowed. Copied from @compiler for faster access to allocator */
amal_compiler *compiler;
bool started;
diff --git a/include/std/buffer.h b/include/std/buffer.h
index 02cc20a..a60def9 100644
--- a/include/std/buffer.h
+++ b/include/std/buffer.h
@@ -19,5 +19,9 @@ CHECK_RESULT int buffer_init(Buffer *self, struct ScopedAllocator *allocator);
CHECK_RESULT int buffer_append(Buffer *self, void *data, usize size);
void* buffer_get(Buffer *self, usize index, usize type_size);
CHECK_RESULT int buffer_pop(Buffer *self, void *data, usize size);
+void* buffer_start(Buffer *self);
+void *buffer_end(Buffer *self);
+usize __buffer_get_size(Buffer *self, usize type_size);
+#define buffer_get_size(self, type) __buffer_get_size((self), sizeof(type))
#endif