Fix error when using default argument
This commit is contained in:
@@ -44,18 +44,17 @@ 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 :: (hdc: HDC): HDC
|
||||
CreateCompatibleDC :: #foreign (hdc: HDC): HDC
|
||||
|
||||
MEM_COMMIT :: 0x00001000
|
||||
MEM_RESERVE :: 0x00002000
|
||||
|
||||
@@ -6,17 +6,17 @@ Vec2 :: struct;; x: F32; y: F32
|
||||
|
||||
Windows_Bitmap :: struct
|
||||
size: Vec2I
|
||||
data: *U32
|
||||
hdc: HDC
|
||||
dib: HBITMAP
|
||||
|
||||
create_bitmap :: (size: Vec2I, bottom_up: Bool)
|
||||
bitmap: Windows_Bitmap = {size = size}
|
||||
create_bitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap
|
||||
result: Windows_Bitmap = {size = size}
|
||||
if bottom_up == false
|
||||
bitmap.size.y = -bitmap.size.y
|
||||
result.size.y = -result.size.y
|
||||
|
||||
hdc := GetDC(0)
|
||||
bminfo := BITMAPINFO{
|
||||
bmiHeader = BITMAPINFOHEADER{
|
||||
BITMAPINFOHEADER{
|
||||
biSize = size_of(BITMAPINFOHEADER),
|
||||
biWidth = size.x->LONG,
|
||||
biHeight = size.y->LONG,
|
||||
@@ -28,10 +28,14 @@ create_bitmap :: (size: Vec2I, bottom_up: Bool)
|
||||
}
|
||||
}
|
||||
|
||||
hdc := GetDC(0)
|
||||
result.dib = CreateDIBSection(hdc, &bminfo, DIB_RGB_COLORS, &result.data->**void, 0, 0)
|
||||
result.hdc = CreateCompatibleDC(hdc)
|
||||
return result
|
||||
|
||||
|
||||
main :: (argc: int, argv: **char): int
|
||||
pass
|
||||
bitmap := create_bitmap({1280, 720})
|
||||
// memory := os.reserve(size = 10000)
|
||||
// os.commit(&memory, 1000)
|
||||
// os.release(&memory)
|
||||
|
||||
@@ -605,9 +605,12 @@ resolve_compound_struct(Ast_Call *node, Ast_Type *type){
|
||||
if(it->name){
|
||||
For_Named(type->agg.members, m){
|
||||
if(it->name->intern_val == m.name){
|
||||
|
||||
// @copy_paste
|
||||
if(m.type == type_type)
|
||||
item_type = m.type_val;
|
||||
else item_type = m.type;
|
||||
|
||||
if(m.visited){
|
||||
compiler_error(it->pos, "Field already initialized");
|
||||
} else m.visited = true;
|
||||
@@ -622,7 +625,13 @@ resolve_compound_struct(Ast_Call *node, Ast_Type *type){
|
||||
compiler_error(it->pos, "Cant mix named fields and normal fields");
|
||||
if(default_counter >= type->agg.members.len)
|
||||
compiler_error(it->pos, "Too many struct initializers");
|
||||
item_type = type->agg.members[default_counter++].type;
|
||||
|
||||
// @copy_paste
|
||||
item_type = type->agg.members[default_counter].type;
|
||||
if(item_type == type_type)
|
||||
item_type = type->agg.members[default_counter].type_val;
|
||||
|
||||
default_counter+=1;
|
||||
}
|
||||
|
||||
assert(item_type);
|
||||
@@ -919,13 +928,11 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){
|
||||
S64 default_iter = 0;
|
||||
|
||||
Ast_Lambda *lambda = (Ast_Lambda *)name.type->ast;
|
||||
for(S64 i = 0; i < lambda->args.len; i++){
|
||||
Ast_Decl *lambda_arg = lambda->args[i];
|
||||
For_Named(lambda->args, lambda_arg){
|
||||
assert(lambda_arg->type);
|
||||
|
||||
Ast_Call_Item *item = 0;
|
||||
For(node->exprs){
|
||||
|
||||
if(it->name){
|
||||
Ast_Atom *name = it->name;
|
||||
assert(name->kind == AST_IDENT);
|
||||
@@ -953,7 +960,9 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){
|
||||
else{
|
||||
// @note: default values are typechecked when they get resolved
|
||||
if(lambda_arg->expr){
|
||||
items.add(ast_call_item(lambda_arg->expr->pos, 0, 0, lambda_arg->expr));
|
||||
Ast_Call_Item *call_item = ast_call_item(lambda_arg->expr->pos, 0, 0, lambda_arg->expr);
|
||||
set_flag(call_item->flags, AST_ITEM_INCLUDED);
|
||||
items.add(call_item);
|
||||
}
|
||||
else compiler_error(lambda_arg->pos, "Required value in lambda call was not passed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user