Core: Add defer

This commit is contained in:
Krzosa Karol
2023-04-22 14:23:08 +02:00
parent d9a7882f8c
commit ad301153d4
8 changed files with 61 additions and 48 deletions

View File

@@ -11,51 +11,6 @@ struct Ast_Lambda;
struct Ast_Type;
struct Ast_Expr;
#ifndef CORE_BASE
#define CORE_BASE
struct Allocator {
typedef void *Allocate(Allocator *, size_t);
typedef void Deallocate(Allocator *, void *p);
Allocate *allocate;
Deallocate *deallocate;
};
struct String {
uint8_t *str;
int64_t len;
};
typedef String Intern_String;
template <class T>
struct Array {
void *allocator;
T *data;
int64_t cap;
int64_t len;
};
template <class T>
struct List_Node {
List_Node<T> *next;
List_Node<T> *prev;
int cap;
int len;
T data[];
};
template <class T>
struct List {
int block_size = 0;
int allocation_multiplier = 0;
List_Node<T> *first = 0;
List_Node<T> *last = 0;
List_Node<T> *first_free = 0;
};
#endif
enum Token_Kind {
TK_End,
/*#
@@ -582,6 +537,7 @@ struct Ast_Scope : Ast {
List<Ast_Scope *> implicit_imports;
List<Ast_Decl *> decls;
Array<Ast *> stmts;
Array<Ast_Defer *> defers;
uint32_t scope_id;
Ast_Scope *file; // Self referential for file and module