From e07ad3c86dc476c590e6d6498352ff8f632099b2 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Fri, 14 Oct 2022 17:20:46 +0200 Subject: [PATCH] Module changes, found Type_Incomplete error --- build.bat | 3 ++- core_codegen_c_language.cpp | 2 ++ core_main.cpp | 10 ++++++++++ core_typechecking.cpp | 2 -- modules/Arena.core | 19 ++++++++---------- modules/KERNEL32.core | 36 +++++++++++++++++++++++++++++++++++ modules/win32_multimedia.core | 2 +- 7 files changed, 59 insertions(+), 15 deletions(-) diff --git a/build.bat b/build.bat index 366f4e8..e16f901 100644 --- a/build.bat +++ b/build.bat @@ -2,9 +2,10 @@ pushd %~dp0 rem cl main.cpp -I.. user32.lib -rem clang core_main.cpp -O0 -Wall -Wno-unused-function -fno-exceptions -fdiagnostics-absolute-paths -g -o main.exe -Wl,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 +echo Building arms race call examples/arms_race/build_arms_race.bat rem main examples/arms_race/arms_race.core diff --git a/core_codegen_c_language.cpp b/core_codegen_c_language.cpp index 8f82fbc..82dc783 100644 --- a/core_codegen_c_language.cpp +++ b/core_codegen_c_language.cpp @@ -79,6 +79,8 @@ get_ctype_name_for_type(Ast_Type *type){ case TYPE_U64: return "uint64_t"; case TYPE_TUPLE: return "Tuple"; case TYPE_TYPE: return "int64_t"; + + case TYPE_INCOMPLETE: return "(Internal compiler error: [Type_Incomplete])"; invalid_default_case; } return ""; diff --git a/core_main.cpp b/core_main.cpp index 680bfeb..e78feed 100644 --- a/core_main.cpp +++ b/core_main.cpp @@ -14,6 +14,16 @@ Fix backlog - [ ] This error is valid error case when someone creates a compound out of basic type C:/AProgramming/cparse/compiler/examples/arms_race/arms_race.core:137 Internal compiler error: Invalid type was passed to the compound expression, should have been an array, struct or slice result := String{data, filesize} - [ ] Fix tuple being able to colapse into a single variable +- [ ] Fix Found multiple definitions of not showing multiple definitions in the error message +- [ ] Fix being able to cast -1 to *void +- [ ] How to cast from U64 to pointer? +- [ ] Fix returning literlas using multiple arguments ``` +C:/AProgramming/cparse/compiler/examples/arms_race/arms_race.core:141:35: error: cannot take the address of an rvalue of type 'int' + MemoryCopy(&S10_S11_S44_139.m0, &(0x0), sizeof(S10_S11_S44_139.m0)); + ^ ~~~ +C:/AProgramming/cparse/compiler/examples/arms_race/arms_race.core:142:35: error: cannot take the address of an rvalue of type 'unsigned long long' + MemoryCopy(&S10_S11_S44_139.m1, &(32ULL), sizeof(S10_S11_S44_139.m1)); +``` Future features diff --git a/core_typechecking.cpp b/core_typechecking.cpp index b091490..e0eec16 100644 --- a/core_typechecking.cpp +++ b/core_typechecking.cpp @@ -1618,8 +1618,6 @@ resolve_decl(Ast_Decl *ast){ ast->state = DECL_RESOLVING; { - // @idea: LAMBDAS maybe get rid of lambdas and replace them with a - // marker that signifies whether code switch(ast->kind){ CASE(LAMBDA, Decl){ Ast_Lambda *lambda = node->lambda; diff --git a/modules/Arena.core b/modules/Arena.core index 665f9a1..49c49bb 100644 --- a/modules/Arena.core +++ b/modules/Arena.core @@ -16,7 +16,14 @@ Init :: (a: *Arena) a.memory = OS.Reserve(DEFAULT_RESERVE_SIZE) a.alignment = DEFAULT_ALIGNMENT a.di = ArenaDI++ - // a.allocator.proc = arena_allocator_proc + +FromBuffer :: (buffer: []U8): Arena + a: Arena + a.memory.reserve = Len(buffer)->U64 + a.memory.commit = Len(buffer)->U64 + a.alignment = DEFAULT_ALIGNMENT + a.di = ArenaDI++ + return a PushSize :: (a: *Arena, size: Base.SizeU): *void generous_size := size + a.alignment @@ -31,15 +38,5 @@ PushSize :: (a: *Arena, size: Base.SizeU): *void a.len += size return result -// @todo: Make this compile time thing!!! -// This probably will wait till polymorphism stuff -// something like this: -// PushType :: (a: *Arena, type: $T): *T -// -PushType :: (a: *Arena, type: Type): *void - type_info := get_type_info(type) - Assert(type_info != 0) - return PushSize(a, type_info.size->Base.SizeU) - Release :: (a: *Arena) OS.Release(&a.memory) diff --git a/modules/KERNEL32.core b/modules/KERNEL32.core index 80550e2..30669a5 100644 --- a/modules/KERNEL32.core +++ b/modules/KERNEL32.core @@ -31,6 +31,9 @@ LARGE_INTEGER :: S64 PLARGE_INTEGER :: *LARGE_INTEGER LPOVERLAPPED :: *OVERLAPPED +LONG_PTR :: *S64 +ULONG_PTR :: *U64 + MEM_COMMIT :: 0x00001000 MEM_RESERVE :: 0x00002000 MEM_RESET :: 0x00080000 @@ -78,6 +81,12 @@ OVERLAPPED :: struct Pointer: PVOID hEvent: HANDLE +LPSECURITY_ATTRIBUTES :: *SECURITY_ATTRIBUTES +SECURITY_ATTRIBUTES :: struct + nLength: DWORD + lpSecurityDescriptor: LPVOID + bInheritHandle: BOOL + GENERIC_READ :: 0x80000000 GENERIC_WRITE :: 0x40000000 GENERIC_EXECUTE :: 0x20000000 @@ -92,3 +101,30 @@ TRUNCATE_EXISTING :: 5 FILE_SHARE_READ :: 0x00000001 FILE_SHARE_WRITE :: 0x00000002 FILE_SHARE_DELETE :: 0x00000004 + +// INVALID_HANDLE_VALUE :: ((-1)->LONG_PTR)->HANDLE +INVALID_HANDLE_VALUE :: (~(0->U64)) + + +FILE_ATTRIBUTE_READONLY :: 0x00000001 +FILE_ATTRIBUTE_HIDDEN :: 0x00000002 +FILE_ATTRIBUTE_SYSTEM :: 0x00000004 +FILE_ATTRIBUTE_DIRECTORY :: 0x00000010 +FILE_ATTRIBUTE_ARCHIVE :: 0x00000020 +FILE_ATTRIBUTE_DEVICE :: 0x00000040 +FILE_ATTRIBUTE_NORMAL :: 0x00000080 +FILE_ATTRIBUTE_TEMPORARY :: 0x00000100 +FILE_ATTRIBUTE_SPARSE_FILE :: 0x00000200 +FILE_ATTRIBUTE_REPARSE_POINT :: 0x00000400 +FILE_ATTRIBUTE_COMPRESSED :: 0x00000800 +FILE_ATTRIBUTE_OFFLINE :: 0x00001000 +FILE_ATTRIBUTE_NOT_CONTENT_INDEXED :: 0x00002000 +FILE_ATTRIBUTE_ENCRYPTED :: 0x00004000 +FILE_ATTRIBUTE_INTEGRITY_STREAM :: 0x00008000 +FILE_ATTRIBUTE_VIRTUAL :: 0x00010000 +FILE_ATTRIBUTE_NO_SCRUB_DATA :: 0x00020000 +FILE_ATTRIBUTE_EA :: 0x00040000 +FILE_ATTRIBUTE_PINNED :: 0x00080000 +FILE_ATTRIBUTE_UNPINNED :: 0x00100000 +FILE_ATTRIBUTE_RECALL_ON_OPEN :: 0x00040000 +FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS :: 0x00400000 \ No newline at end of file diff --git a/modules/win32_multimedia.core b/modules/win32_multimedia.core index aca9832..bb6671e 100644 --- a/modules/win32_multimedia.core +++ b/modules/win32_multimedia.core @@ -53,7 +53,7 @@ DestroyBitmap :: (b: *WIN32_Bitmap) ZeroMemory(b, SizeOf(WIN32_Bitmap)) DrawBitmapInCompatibleDC :: (b: *WIN32_Bitmap) - if(IsValidBitmap(b)) + 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)