diff --git a/.gitignore b/.gitignore index 69fae58..8fc490d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,10 @@ *.rdbg *.out *.c +*.lib +*.o +*.sublime-* tests/ backup* start.bat diff --git a/build.bat b/build.bat index e448fef..366f4e8 100644 --- a/build.bat +++ b/build.bat @@ -2,9 +2,10 @@ pushd %~dp0 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 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 +call examples/arms_race/build_arms_race.bat rem main examples/arms_race/arms_race.core popd diff --git a/core_main.cpp b/core_main.cpp index 854e84a..cbe9394 100644 --- a/core_main.cpp +++ b/core_main.cpp @@ -1,26 +1,41 @@ /* -Current: - -- [ ] Maybe wait to implement WASM / bytecode emitter before doing this? - Probably need some UInt Int types and those should be default, target - decides the size of these +Fix backlog - [ ] Fix invalid error message: AlmostLinearToSRGB :: (a: Color);; return {sqrtf(a.r), sqrtf(a.g), sqrtf(a.b), a.a} - [ ] Fix untyped literal going to codegen stage, example in arms_race -- [ ] Fix and decide what to do when initializing global variable using not constants +- [ ] Fix and decide what to do when initializing global variable using not constants C:/AProgramming/cparse/compiler/modules/Language.core:180:28: error: initializer element is not a compile-time constant - [ ] Fix adressing void is possible, maybe make it possible to address void using bytes * a.void + 10 * a.void[10] -- [ ] String declaration in Language.core -- [ ] Way to import and force evaluate #import_lazy #import ? - [ ] Test and bulletproof any, slices - [ ] Need tests that make sure stuff errors out -Memory: +Future features + +- [ ] Add some directive that passes metadata arguments to compiler, stores them + in array and then those can be searched etc. Then we could add the link thing there +- [ ] The ability for a type to also be a namespace seems like a good idea, a common pattern + emerges. Not sure how to execute it though without complications. Data for sure needs + to be nicely visible in a struct and those functions should be separate +- [ ] Other kinds of casts, a cast from structs of same layout, a cast without conversion +- [ ] Inject symbols into a declaration / namespace ?? +- [ ] Using directive to bring symbols into local scope + +### + +- [ ] Maybe wait to implement WASM / bytecode emitter before doing this? + Probably need some UInt Int types and those should be default, target + decides the size of these + +- [ ] String declaration in Language.core +- [ ] Way to import and force evaluate #import_lazy #import ? + +Redesign: - [ ] Redesign Type map to use List and reduce wasting space - [ ] Redesign lexing to minimize memory usage, we got rid of heap but in a naive way! - [ ] Probably need to move all the global data into the context if we want to use this as library or not? +- [ ] Casting In the future @@ -28,7 +43,6 @@ In the future - [ ] Add ability to do i: int = 0 inside for loops for i: int = 0, i < 10, i+=1 - [ ] Complicated c declaration generation -- [ ] Other kinds of casts, a cast from structs of same layout, a cast without conversion - [ ] Expand macros - [ ] Defer diff --git a/modules/LibC.core b/modules/LibC.core index 01f3249..f08a1f6 100644 --- a/modules/LibC.core +++ b/modules/LibC.core @@ -1,5 +1,17 @@ -size_t :: U64 +size_t :: U64 // @todo(Krzosa): Need this type +long :: #strict int // @todo(Krzosa): Need this type malloc :: #foreign (size: size_t): *void realloc :: #foreign (ptr: *void, size: size_t): *void free :: #foreign (ptr: *void) + +FILE :: #strict U64 // Doesnt matter the type just handle +fopen :: #foreign (file: *char, mode: *char): *FILE +fclose :: #foreign (file: *FILE): int +fseek :: #foreign (public_stream: *FILE, offset: long, whence: int): int +ftell :: #foreign (public_stream: *FILE): long +fread :: #foreign (buffer: *void, element_size: size_t, element_count: size_t, stream: *FILE): size_t + +SEEK_CUR :: 1 +SEEK_END :: 2 +SEEK_SET :: 0 diff --git a/modules/win32_multimedia.core b/modules/win32_multimedia.core index a7e74ec..1bdf5b8 100644 --- a/modules/win32_multimedia.core +++ b/modules/win32_multimedia.core @@ -5,24 +5,24 @@ #import "Windows.core" Platform :: struct - bitmap: Bitmap + bitmap: WIN32_Bitmap window_dc: HDC window: HWND good_scheduling: Bool -Bitmap :: struct +WIN32_Bitmap :: struct size: Vec2I data: *U32 hdc: HDC dib: HBITMAP compatible_dc: HDC -IsValidBitmap :: (b: *Bitmap): Bool +IsValidBitmap :: (b: *WIN32_Bitmap): Bool result := b.data != 0 return result -CreateBitmap :: (for_dc: HDC, size: Vec2I, bottom_up: Bool = true): Bitmap - result: Bitmap = {size = size} +CreateBitmap :: (for_dc: HDC, size: Vec2I, bottom_up: Bool = true): WIN32_Bitmap + result: WIN32_Bitmap = {size = size} if bottom_up == false result.size.y = -result.size.y @@ -46,13 +46,13 @@ CreateBitmap :: (for_dc: HDC, size: Vec2I, bottom_up: Bool = true): Bitmap result.compatible_dc = for_dc return result -DestroyBitmap :: (b: *Bitmap) +DestroyBitmap :: (b: *WIN32_Bitmap) if IsValidBitmap(b) DeleteDC(b.hdc) DeleteObject(b.dib) - ZeroMemory(b, SizeOf(Bitmap)) + ZeroMemory(b, SizeOf(WIN32_Bitmap)) -DrawBitmapInCompatibleDC :: (b: *Bitmap) +DrawBitmapInCompatibleDC :: (b: *WIN32_Bitmap) if(IsValidBitmap(b)) SelectObject(b.hdc, b.dib) BitBlt(b.compatible_dc, 0, 0, b.size.x->int, b.size.y->int, b.hdc, 0, 0, SRCCOPY)