Fixing generated names when namespaced Windows :: #import calls and field accesses
This commit is contained in:
10
base.kl
10
base.kl
@@ -1,4 +1,4 @@
|
||||
#import "Windows.kl"
|
||||
Windows :: #import "Windows.kl"
|
||||
|
||||
SizeU :: #strict U64
|
||||
OS_PAGE_SIZE :: 4096
|
||||
@@ -26,10 +26,10 @@ align_up :: (size: SizeU, align: SizeU): SizeU
|
||||
|
||||
reserve :: (size: SizeU): OS_Memory
|
||||
result := OS_Memory{reserve=align_up(size, OS_PAGE_SIZE)}
|
||||
result.data = VirtualAlloc(
|
||||
flProtect = PAGE_READWRITE,
|
||||
result.data = Windows.VirtualAlloc(
|
||||
flProtect = Windows.PAGE_READWRITE,
|
||||
dwSize = result.reserve,
|
||||
flAllocationType = MEM_RESERVE,
|
||||
flAllocationType = Windows.MEM_RESERVE,
|
||||
lpAddress = 0,
|
||||
)->*U8
|
||||
return result
|
||||
@@ -45,7 +45,7 @@ commit :: (m: *OS_Memory, size: SizeU): Bool
|
||||
clamped_commit := clamp_top_sizeu(total_commit, m.reserve)
|
||||
adjusted_commit := clamped_commit - m.commit
|
||||
if adjusted_commit != 0
|
||||
result := VirtualFree(m.data->*void, 0, MEM_RELEASE)
|
||||
result := Windows.VirtualFree(m.data->*void, 0, Windows.MEM_RELEASE)
|
||||
m.commit += adjusted_commit
|
||||
return true
|
||||
return false
|
||||
|
||||
19
ccodegen.cpp
19
ccodegen.cpp
@@ -5,7 +5,7 @@ global S32 global_indent;
|
||||
global S32 is_inside_struct;
|
||||
|
||||
function void gen_ast(Ast *ast);
|
||||
function void gen_expr(Ast_Expr *ast);
|
||||
function bool gen_expr(Ast_Expr *ast);
|
||||
|
||||
function void
|
||||
gen_indent(){
|
||||
@@ -170,10 +170,12 @@ gen_lambda(Intern_String name, Ast_Lambda *lambda){
|
||||
else gen(";");
|
||||
}
|
||||
|
||||
function void
|
||||
function bool
|
||||
gen_expr(Ast_Expr *ast){
|
||||
switch(ast->kind){
|
||||
CASE(IDENT, Atom){
|
||||
if(node->resolved_decl->kind == AST_MODULE_NAMESPACE || node->resolved_decl->kind == AST_FILE_NAMESPACE)
|
||||
return false;
|
||||
B32 print_scope = true;
|
||||
if(node->resolved_decl->lambda){
|
||||
if(is_flag_set(node->resolved_decl->lambda->flags, AST_FOREIGN))
|
||||
@@ -210,12 +212,12 @@ gen_expr(Ast_Expr *ast){
|
||||
|
||||
CASE(BINARY, Binary){
|
||||
if(node->op == TK_Dot){
|
||||
gen_expr(node->left);
|
||||
if(!node->type) gen("__");
|
||||
else if(node->type->kind == TYPE_POINTER) gen("->");
|
||||
else gen(".");
|
||||
if(gen_expr(node->left)){
|
||||
if(node->type && node->type->kind == TYPE_POINTER) gen("->");
|
||||
else gen(".");
|
||||
}
|
||||
gen_expr(node->right);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
else if(node->op == TK_Arrow){
|
||||
gen("(");
|
||||
@@ -224,7 +226,7 @@ gen_expr(Ast_Expr *ast){
|
||||
gen(")");
|
||||
gen_expr(node->left);
|
||||
gen(")");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!token_is_assign(node->op)) gen("(");
|
||||
@@ -276,6 +278,7 @@ gen_expr(Ast_Expr *ast){
|
||||
|
||||
invalid_default_case;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function void
|
||||
|
||||
Reference in New Issue
Block a user