Working on modules finding bugs
This commit is contained in:
@@ -10,6 +10,10 @@ Fix backlog
|
||||
* a.void[10]
|
||||
- [ ] Test and bulletproof any, slices
|
||||
- [ ] Need tests that make sure stuff errors out
|
||||
- [ ] String declaration in Language.core this way we can compound create it and access fields and stuff
|
||||
- [ ] 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
|
||||
|
||||
Future features
|
||||
|
||||
@@ -28,7 +32,6 @@ Future features
|
||||
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:
|
||||
|
||||
@@ -94,7 +94,7 @@ Raymarcher_Update :: ()
|
||||
|
||||
#import "Base.core"
|
||||
#import "Arena.core"
|
||||
#import "Windows.core"
|
||||
#import "OS$OS.core"
|
||||
#import "KERNEL32.core"
|
||||
#import "GDI32.core"
|
||||
#import "USER32.core"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
OS :: #import "Windows.core"
|
||||
OS :: #import "OS$OS.core"
|
||||
Base :: #import "Base.core"
|
||||
ArenaDI: U64
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#import "Arena.core"
|
||||
OS :: #import "Windows.core"
|
||||
OS :: #import "OS$OS.core"
|
||||
SizeU :: U64
|
||||
|
||||
ClampTopSizeU :: (val: SizeU, max: SizeU): SizeU
|
||||
|
||||
@@ -28,6 +28,8 @@ LONG :: S32 // @todo long
|
||||
UINT :: U32 // @todo uint
|
||||
ATOM :: WORD
|
||||
LARGE_INTEGER :: S64
|
||||
PLARGE_INTEGER :: *LARGE_INTEGER
|
||||
LPOVERLAPPED :: *OVERLAPPED
|
||||
|
||||
MEM_COMMIT :: 0x00001000
|
||||
MEM_RESERVE :: 0x00002000
|
||||
@@ -64,3 +66,29 @@ QueryPerformanceFrequency :: #foreign (lpFrequency: *LARGE_INTEGER): BOOL
|
||||
QueryPerformanceCounter :: #foreign (lpFrequency: *LARGE_INTEGER): BOOL
|
||||
Sleep :: #foreign (dwMilliseconds: DWORD)
|
||||
OutputDebugStringA :: #foreign (lpOutputString: LPCSTR)
|
||||
|
||||
CreateFileW :: #foreign (lpFileName: LPCWSTR, dwDesiredAccess: DWORD, dwShareMode: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, dwCreationDisposition: DWORD, dwFlagsAndAttributes: DWORD, hTemplateFile: HANDLE): HANDLE
|
||||
ReadFile :: #foreign (hFile: HANDLE, lpBuffer: LPVOID, nNumberOfBytesToRead: DWORD, lpNumberOfBytesRead: LPDWORD, lpOverlapped: LPOVERLAPPED): BOOL
|
||||
CloseHandle :: #foreign (hObject: HANDLE): BOOL
|
||||
GetFileSizeEx :: #foreign (hFile: HANDLE, lpFileSize: PLARGE_INTEGER)
|
||||
|
||||
OVERLAPPED :: struct
|
||||
Internal: ULONG_PTR
|
||||
InternalHigh: ULONG_PTR
|
||||
Pointer: PVOID
|
||||
hEvent: HANDLE
|
||||
|
||||
GENERIC_READ :: 0x80000000
|
||||
GENERIC_WRITE :: 0x40000000
|
||||
GENERIC_EXECUTE :: 0x20000000
|
||||
GENERIC_ALL :: 0x10000000
|
||||
|
||||
CREATE_NEW :: 1
|
||||
CREATE_ALWAYS :: 2
|
||||
OPEN_EXISTING :: 3
|
||||
OPEN_ALWAYS :: 4
|
||||
TRUNCATE_EXISTING :: 5
|
||||
|
||||
FILE_SHARE_READ :: 0x00000001
|
||||
FILE_SHARE_WRITE :: 0x00000002
|
||||
FILE_SHARE_DELETE :: 0x00000004
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
#import "KERNEL32.core"
|
||||
#import "Base.core"
|
||||
|
||||
PAGE_SIZE :: 4096
|
||||
Memory :: struct
|
||||
commit : SizeU
|
||||
reserve: SizeU
|
||||
data : *U8
|
||||
|
||||
ProcessHeap: HANDLE
|
||||
Allocate :: (size: U64): *void
|
||||
if ProcessHeap == 0
|
||||
ProcessHeap = GetProcessHeap()
|
||||
return HeapAlloc(ProcessHeap, 0, size)
|
||||
|
||||
Reserve :: (size: SizeU): Memory
|
||||
result := Memory{reserve=AlignUp(size, PAGE_SIZE)}
|
||||
result.data = VirtualAlloc(
|
||||
flProtect = PAGE_READWRITE,
|
||||
dwSize = result.reserve,
|
||||
flAllocationType = MEM_RESERVE,
|
||||
lpAddress = 0)->*U8
|
||||
return result
|
||||
|
||||
Commit :: (m: *Memory, size: SizeU): Bool
|
||||
commit_size := AlignUp(size, PAGE_SIZE)
|
||||
total_commit := m.commit + commit_size
|
||||
clamped_commit := ClampTopSizeU(total_commit, m.reserve)
|
||||
adjusted_commit := clamped_commit - m.commit
|
||||
if adjusted_commit != 0
|
||||
result := VirtualAlloc(
|
||||
lpAddress = (m.data + m.commit)->*void,
|
||||
dwSize = adjusted_commit,
|
||||
flAllocationType = MEM_COMMIT,
|
||||
flProtect = PAGE_READWRITE,
|
||||
)
|
||||
Assert(result != 0)
|
||||
m.commit += adjusted_commit
|
||||
return true
|
||||
return false
|
||||
|
||||
Release :: (m: *Memory)
|
||||
result := VirtualFree(m.data->*void, 0, MEM_RELEASE)
|
||||
if result != 0
|
||||
m.data = 0
|
||||
m.commit = 0
|
||||
m.reserve = 0
|
||||
|
||||
WriteConsole :: (string: String16)
|
||||
handle := GetStdHandle(STD_OUTPUT_HANDLE)
|
||||
WriteConsoleW(handle, string.str->*void, string.len->DWORD, 0, 0)
|
||||
|
||||
PerformanceFrequency: F64
|
||||
PerformanceFrequency_S64: S64
|
||||
Time :: (): F64
|
||||
query: LARGE_INTEGER
|
||||
if PerformanceFrequency_S64 == 0
|
||||
err := QueryPerformanceFrequency(&PerformanceFrequency_S64)
|
||||
Assert(err != 0)
|
||||
PerformanceFrequency = PerformanceFrequency_S64->F64
|
||||
|
||||
err := QueryPerformanceCounter(&query)
|
||||
Assert(err != 0)
|
||||
result := query->F64 / PerformanceFrequency
|
||||
return result
|
||||
@@ -2,7 +2,7 @@
|
||||
#import "GDI32.core"
|
||||
#import "USER32.core"
|
||||
#import "WINMM.core"
|
||||
#import "Windows.core"
|
||||
#import "OS$OS.core"
|
||||
|
||||
Platform :: struct
|
||||
bitmap: WIN32_Bitmap
|
||||
|
||||
Reference in New Issue
Block a user