Fix ordering of structs when array type appears, add more windows stuff
This commit is contained in:
@@ -344,7 +344,7 @@ gen_expr(Ast_Expr *ast, Ast_Type *type_of_var){
|
|||||||
|
|
||||||
For(node->exprs){
|
For(node->exprs){
|
||||||
if(is_struct(node->resolved_type))
|
if(is_struct(node->resolved_type))
|
||||||
gen("[%s] = ", it->resolved_name.str);
|
gen(".%s = ", it->resolved_name.str);
|
||||||
else if(is_array(node->resolved_type))
|
else if(is_array(node->resolved_type))
|
||||||
gen("[%d] = ", (int)it->resolved_index);
|
gen("[%d] = ", (int)it->resolved_index);
|
||||||
gen_expr(it->item);
|
gen_expr(it->item);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
DWORD :: U32
|
DWORD :: U32
|
||||||
LPCSTR :: *char
|
LPCSTR :: *char
|
||||||
|
LPCWSTR :: *U16
|
||||||
HWND :: *void
|
HWND :: *void
|
||||||
HMENU :: *void
|
HMENU :: *void
|
||||||
HINSTANCE :: *void
|
HINSTANCE :: *void
|
||||||
@@ -10,52 +11,18 @@ SIZE_T :: U64
|
|||||||
BOOL :: int
|
BOOL :: int
|
||||||
HANDLE :: *void
|
HANDLE :: *void
|
||||||
VOID :: void
|
VOID :: void
|
||||||
|
HICON :: HANDLE
|
||||||
|
HCURSOR :: HANDLE
|
||||||
|
HBRUSH :: HANDLE
|
||||||
LPDWORD :: *DWORD
|
LPDWORD :: *DWORD
|
||||||
|
LRESULT :: S64
|
||||||
|
WPARAM :: U64
|
||||||
|
LPARAM :: S64
|
||||||
BYTE :: U8 // @todo? unsigned char
|
BYTE :: U8 // @todo? unsigned char
|
||||||
WORD :: S16 // short
|
WORD :: S16 // short
|
||||||
LONG :: S32 // @todo long
|
LONG :: S32 // @todo long
|
||||||
UINT :: U32 // @todo uint
|
UINT :: U32 // @todo uint
|
||||||
|
|
||||||
RBGQUAD :: struct
|
|
||||||
rgbBlue: BYTE
|
|
||||||
rgbGreen: BYTE
|
|
||||||
rgbRed: BYTE
|
|
||||||
rgbReserved: BYTE
|
|
||||||
|
|
||||||
BITMAPINFOHEADER :: struct
|
|
||||||
biSize: DWORD
|
|
||||||
biWidth: LONG
|
|
||||||
biHeight: LONG
|
|
||||||
biPlanes: WORD
|
|
||||||
biBitCount: WORD
|
|
||||||
biCompression: DWORD
|
|
||||||
biSizeImage: DWORD
|
|
||||||
biXPelsPerMeter: LONG
|
|
||||||
biYPelsPerMeter: LONG
|
|
||||||
biClrUsed: DWORD
|
|
||||||
biClrImportant: DWORD
|
|
||||||
|
|
||||||
BI_RGB :: 0x0000
|
|
||||||
BI_RLE8 :: 0x0001
|
|
||||||
BI_RLE4 :: 0x0002
|
|
||||||
BI_BITFIELDS :: 0x0003
|
|
||||||
BI_JPEG :: 0x0004
|
|
||||||
BI_PNG :: 0x0005
|
|
||||||
BI_CMYK :: 0x000B
|
|
||||||
BI_CMYKRLE8 :: 0x000C
|
|
||||||
BI_CMYKRLE4 :: 0x000
|
|
||||||
DIB_RGB_COLORS :: 0x00
|
|
||||||
|
|
||||||
BITMAPINFO :: struct
|
|
||||||
bmiHeader :: BITMAPINFOHEADER
|
|
||||||
bmiColors :: [1]RBGQUAD
|
|
||||||
|
|
||||||
// #import #foreign "gdi32.lib" @todo
|
|
||||||
CreateWindowA :: #foreign (dwExStyle: DWORD, lpClassName: *char, lpWindowName: *char, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: *void): HWND
|
|
||||||
GetDC :: #foreign (hWnd: HWND): HDC
|
|
||||||
CreateDIBSection :: #foreign (hdc: HDC, pbmi: *BITMAPINFO, usage: UINT, ppvBits: **VOID, hSection: HANDLE, offset: DWORD): HBITMAP
|
|
||||||
CreateCompatibleDC :: #foreign (hdc: HDC): HDC
|
|
||||||
|
|
||||||
MEM_COMMIT :: 0x00001000
|
MEM_COMMIT :: 0x00001000
|
||||||
MEM_RESERVE :: 0x00002000
|
MEM_RESERVE :: 0x00002000
|
||||||
MEM_RESET :: 0x00080000
|
MEM_RESET :: 0x00080000
|
||||||
|
|||||||
20
programs/gdi32.kl
Normal file
20
programs/gdi32.kl
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#load "Windows.kl"
|
||||||
|
RBGQUAD :: struct;; rgbBlue: BYTE; rgbGreen: BYTE; rgbRed: BYTE; rgbReserved: BYTE
|
||||||
|
BITMAPINFOHEADER :: struct;; biSize: DWORD; biWidth: LONG; biHeight: LONG; biPlanes: WORD; biBitCount: WORD; biCompression: DWORD; biSizeImage: DWORD; biXPelsPerMeter: LONG; biYPelsPerMeter: LONG; biClrUsed: DWORD; biClrImportant: DWORD
|
||||||
|
BITMAPINFO :: struct;; bmiHeader: BITMAPINFOHEADER; bmiColors: [1]RBGQUAD
|
||||||
|
|
||||||
|
BI_RGB :: 0x0000
|
||||||
|
BI_RLE8 :: 0x0001
|
||||||
|
BI_RLE4 :: 0x0002
|
||||||
|
BI_BITFIELDS :: 0x0003
|
||||||
|
BI_JPEG :: 0x0004
|
||||||
|
BI_PNG :: 0x0005
|
||||||
|
BI_CMYK :: 0x000B
|
||||||
|
BI_CMYKRLE8 :: 0x000C
|
||||||
|
BI_CMYKRLE4 :: 0x000
|
||||||
|
DIB_RGB_COLORS :: 0x00
|
||||||
|
|
||||||
|
|
||||||
|
// #import #foreign "gdi32.lib" @todo
|
||||||
|
CreateDIBSection :: #foreign (hdc: HDC, pbmi: *BITMAPINFO, usage: UINT, ppvBits: **VOID, hSection: HANDLE, offset: DWORD): HBITMAP
|
||||||
|
CreateCompatibleDC :: #foreign (hdc: HDC): HDC
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
// #import "base.kl"
|
// #import "base.kl"
|
||||||
#load "Windows.kl"
|
#load "gdi32.kl"
|
||||||
|
#load "user32.kl"
|
||||||
|
|
||||||
Vec2I :: struct;; x: S32; y: S32
|
Vec2I :: struct;; x: S32; y: S32
|
||||||
Vec2 :: struct;; x: F32; y: F32
|
Vec2 :: struct;; x: F32; y: F32
|
||||||
@@ -34,8 +35,13 @@ create_bitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
window_procedure :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT
|
||||||
|
if msg == WM_DESTROY
|
||||||
|
pass
|
||||||
|
|
||||||
main :: (argc: int, argv: **char): int
|
main :: (argc: int, argv: **char): int
|
||||||
bitmap := create_bitmap({1280, 720})
|
bitmap := create_bitmap({1280, 720})
|
||||||
|
WNDCLASS
|
||||||
// memory := os.reserve(size = 10000)
|
// memory := os.reserve(size = 10000)
|
||||||
// os.commit(&memory, 1000)
|
// os.commit(&memory, 1000)
|
||||||
// os.release(&memory)
|
// os.release(&memory)
|
||||||
|
|||||||
13
programs/user32.kl
Normal file
13
programs/user32.kl
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#load "Windows.kl"
|
||||||
|
WNDPROC :: (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT
|
||||||
|
WNDCLASSW :: struct;; style: UINT; lpfnWndProc: WNDPROC; cbClsExtra: int; cbWndExtra: int; hInstance: HINSTANCE; hIcon: HICON; hCursor: HCURSOR; hbrBackground: HBRUSH; lpszMenuName: LPCWSTR; lpszClassName: LPCWSTR
|
||||||
|
|
||||||
|
PostQuitMessage :: #foreign(nExitCode: int)
|
||||||
|
DefWindowProc :: #foreign (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT
|
||||||
|
GetDC :: #foreign (hWnd: HWND): HDC
|
||||||
|
CreateWindowA :: #foreign (dwExStyle: DWORD, lpClassName: *char, lpWindowName: *char, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: *void): HWND
|
||||||
|
CreateWindowExW :: #foreign (dwExStyle: DWORD, lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpPara: LPVOID): HWND
|
||||||
|
|
||||||
|
WM_NULL :: 0x0000;; WM_CREATE :: 0x0001; WM_DESTROY :: 0x0002; WM_MOVE :: 0x0003; WM_SIZE :: 0x0005
|
||||||
|
WM_ACTIVATE :: 0x0006;; WA_INACTIVE :: 0; WA_ACTIVE :: 1; WA_CLICKACTIVE :: 2
|
||||||
|
WM_SETFOCUS :: 0x0007;; WM_KILLFOCUS :: 0x0008; WM_ENABLE :: 0x000A; WM_SETREDRAW :: 0x000B; WM_SETTEXT :: 0x000C; WM_GETTEXT :: 0x000D; WM_GETTEXTLENGTH :: 0x000E; WM_PAINT :: 0x000F; WM_CLOSE :: 0x0010
|
||||||
@@ -728,6 +728,8 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){
|
|||||||
Operand type = resolve_expr(node->base, AST_CANT_BE_NULL);
|
Operand type = resolve_expr(node->base, AST_CANT_BE_NULL);
|
||||||
Operand expr = require_const_int(node->expr, AST_CAN_BE_NULL);
|
Operand expr = require_const_int(node->expr, AST_CAN_BE_NULL);
|
||||||
if(type.type != type_type) compiler_error(node->pos, "Prefix array operator is only allowed on types");
|
if(type.type != type_type) compiler_error(node->pos, "Prefix array operator is only allowed on types");
|
||||||
|
|
||||||
|
type_complete(type.type_val);
|
||||||
if(node->expr){
|
if(node->expr){
|
||||||
node->resolved_type = type_array(type.type_val, bigint_as_unsigned(&expr.big_int_val));
|
node->resolved_type = type_array(type.type_val, bigint_as_unsigned(&expr.big_int_val));
|
||||||
} else{
|
} else{
|
||||||
|
|||||||
Reference in New Issue
Block a user