Misc changes

This commit is contained in:
Krzosa Karol
2022-10-13 20:46:03 +02:00
parent 022f874c32
commit 16a2fe659e
5 changed files with 50 additions and 20 deletions

3
.gitignore vendored
View File

@@ -7,7 +7,10 @@
*.rdbg *.rdbg
*.out *.out
*.c *.c
*.lib
*.o
*.sublime-*
tests/ tests/
backup* backup*
start.bat start.bat

View File

@@ -2,9 +2,10 @@
pushd %~dp0 pushd %~dp0
rem cl main.cpp -I.. user32.lib 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 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 rem main examples/arms_race/arms_race.core
popd popd

View File

@@ -1,26 +1,41 @@
/* /*
Current: Fix backlog
- [ ] 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 invalid error message: AlmostLinearToSRGB :: (a: Color);; return {sqrtf(a.r), sqrtf(a.g), sqrtf(a.b), a.a} - [ ] 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 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 - [ ] Fix adressing void is possible, maybe make it possible to address void
using bytes using bytes
* a.void + 10 * a.void + 10
* 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 - [ ] Test and bulletproof any, slices
- [ ] Need tests that make sure stuff errors out - [ ] 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 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! - [ ] 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? - [ ] 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 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 - [ ] Add ability to do i: int = 0 inside for loops for i: int = 0, i < 10, i+=1
- [ ] Complicated c declaration generation - [ ] Complicated c declaration generation
- [ ] Other kinds of casts, a cast from structs of same layout, a cast without conversion
- [ ] Expand macros - [ ] Expand macros
- [ ] Defer - [ ] Defer

View File

@@ -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 malloc :: #foreign (size: size_t): *void
realloc :: #foreign (ptr: *void, size: size_t): *void realloc :: #foreign (ptr: *void, size: size_t): *void
free :: #foreign (ptr: *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

View File

@@ -5,24 +5,24 @@
#import "Windows.core" #import "Windows.core"
Platform :: struct Platform :: struct
bitmap: Bitmap bitmap: WIN32_Bitmap
window_dc: HDC window_dc: HDC
window: HWND window: HWND
good_scheduling: Bool good_scheduling: Bool
Bitmap :: struct WIN32_Bitmap :: struct
size: Vec2I size: Vec2I
data: *U32 data: *U32
hdc: HDC hdc: HDC
dib: HBITMAP dib: HBITMAP
compatible_dc: HDC compatible_dc: HDC
IsValidBitmap :: (b: *Bitmap): Bool IsValidBitmap :: (b: *WIN32_Bitmap): Bool
result := b.data != 0 result := b.data != 0
return result return result
CreateBitmap :: (for_dc: HDC, size: Vec2I, bottom_up: Bool = true): Bitmap CreateBitmap :: (for_dc: HDC, size: Vec2I, bottom_up: Bool = true): WIN32_Bitmap
result: Bitmap = {size = size} result: WIN32_Bitmap = {size = size}
if bottom_up == false if bottom_up == false
result.size.y = -result.size.y 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 result.compatible_dc = for_dc
return result return result
DestroyBitmap :: (b: *Bitmap) DestroyBitmap :: (b: *WIN32_Bitmap)
if IsValidBitmap(b) if IsValidBitmap(b)
DeleteDC(b.hdc) DeleteDC(b.hdc)
DeleteObject(b.dib) DeleteObject(b.dib)
ZeroMemory(b, SizeOf(Bitmap)) ZeroMemory(b, SizeOf(WIN32_Bitmap))
DrawBitmapInCompatibleDC :: (b: *Bitmap) DrawBitmapInCompatibleDC :: (b: *WIN32_Bitmap)
if(IsValidBitmap(b)) if(IsValidBitmap(b))
SelectObject(b.hdc, b.dib) SelectObject(b.hdc, b.dib)
BitBlt(b.compatible_dc, 0, 0, b.size.x->int, b.size.y->int, b.hdc, 0, 0, SRCCOPY) BitBlt(b.compatible_dc, 0, 0, b.size.x->int, b.size.y->int, b.hdc, 0, 0, SRCCOPY)