From e20edaa3a2f7b6063bb5dfb7f48437b91c2ca85d Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Sat, 31 Dec 2022 14:53:40 +0100 Subject: [PATCH] You can use compiler_interface hpp outside --- base.cpp | 1 + build.bat | 3 ++- core_compiler_interface.hpp | 31 +++++++++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/base.cpp b/base.cpp index c89f813..49adeb0 100644 --- a/base.cpp +++ b/base.cpp @@ -1,3 +1,4 @@ +#define CORE_BASE #if defined(__clang__) # define COMPILER_CLANG 1 diff --git a/build.bat b/build.bat index 2d22d51..d4e2460 100644 --- a/build.bat +++ b/build.bat @@ -5,8 +5,9 @@ rem cl main.cpp -I.. user32.lib clang core_main.cpp -O0 -Wall -Wno-unused-function -fno-exceptions -fdiagnostics-absolute-paths -g -o main.exe -Wl,user32.lib rem ubuntu run clang core_main.cpp -O0 -Wall -Wno-unused-function -fno-exceptions -fdiagnostics-absolute-paths -g -o core.out -rem main.exe -testing +clang test.cpp +rem main.exe -testing rem echo Building arms race rem call examples/arms_race/build_arms_race.bat rem main examples/arms_race/arms_race.core diff --git a/core_compiler_interface.hpp b/core_compiler_interface.hpp index a05dcd9..7120e3b 100644 --- a/core_compiler_interface.hpp +++ b/core_compiler_interface.hpp @@ -11,8 +11,8 @@ struct Ast_Lambda; struct Ast_Type; struct Ast_Expr; -#ifndef CORE_STRINGS -#define CORE_STRINGS +#ifndef CORE_BASE +#define CORE_BASE struct String{ uint8_t *str; int64_t len; @@ -25,6 +25,33 @@ union Intern_String{ // Basically just String int64_t len; }; }; + +template +struct Array { + void *allocator; + T *data; + int64_t cap; + int64_t len; +}; + +template +struct List_Node{ + List_Node *next; + List_Node *prev; + int cap; + int len; + T data[]; +}; + +template +struct List{ + int block_size = 0; + int allocation_multiplier = 0; + List_Node *first = 0; + List_Node *last = 0; + List_Node *first_free = 0; +}; + #endif enum Token_Kind{