aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ast.h9
-rw-r--r--include/compiler.h17
-rw-r--r--include/parser.h3
3 files changed, 23 insertions, 6 deletions
diff --git a/include/ast.h b/include/ast.h
index 56795cd..eaf2352 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -79,7 +79,7 @@ struct Scope {
};
struct FileScopeReference {
- Scope *scope;
+ Parser *parser;
Buffer canonical_path;
};
@@ -113,9 +113,6 @@ struct LhsExpr {
Variable type;
Ast *rhs_expr;
/*
- A mutex is only available if the LhsExpr is public, because other threads (files)
- can access it. It's used to prevent usage of unresolved data and also to decide which
- thread has responsibility of resolving data.
TODO: Find a better way to store this. This most likely will use too much memory.
*/
amal_mutex *mutex;
@@ -136,6 +133,7 @@ struct Number {
f64 floating;
} value;
bool is_integer;
+ BufferView code_ref;
};
struct Binop {
@@ -149,6 +147,7 @@ struct Binop {
typedef struct {
jmp_buf env;
Parser *parser;
+ amal_compiler *compiler;
Scope *scope;
} AstCompilerContext;
@@ -162,7 +161,7 @@ void structfield_init(StructField *self, BufferView name, BufferView type_name);
CHECK_RESULT int lhsexpr_init(LhsExpr *self, bool is_pub, bool is_const, BufferView var_name, ScopedAllocator *allocator);
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 number_init(Number *self, i64 value, bool is_integer, BufferView code_ref);
void variable_init(Variable *self, BufferView name);
void binop_init(Binop *self);
diff --git a/include/compiler.h b/include/compiler.h
index a7fbb34..b80d7c1 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -13,7 +13,24 @@
/* General error */
#define AMAL_COMPILER_ERR -1
+typedef struct {
+ LhsExpr *i8;
+ LhsExpr *i16;
+ LhsExpr *i32;
+ LhsExpr *i64;
+ LhsExpr *u8;
+ LhsExpr *u16;
+ LhsExpr *u32;
+ LhsExpr *u64;
+ LhsExpr *isize;
+ LhsExpr *usize;
+ LhsExpr *f32;
+ LhsExpr *f64;
+ LhsExpr *str;
+} amal_default_types;
+
struct amal_compiler {
+ amal_default_types default_types;
ScopedAllocator allocator;
Scope root_scope;
Buffer/*<Parser*>*/ parsers;
diff --git a/include/parser.h b/include/parser.h
index 92e6d46..a203b7d 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -35,7 +35,8 @@ typedef enum {
struct Parser {
Tokenizer tokenizer;
- Scope scope;
+ StructDecl struct_decl;
+ LhsExpr file_decl;
Scope *current_scope;
ScopedAllocator *allocator; /* borrowed. Copied from @compiler for faster access to allocator */
amal_compiler *compiler;