diff --git a/core/sync/sync.odin b/core/sync/sync.odin deleted file mode 100644 index de45d8f6e..000000000 --- a/core/sync/sync.odin +++ /dev/null @@ -1,2 +0,0 @@ -when ODIN_OS == "windows" do export "core:sync_windows.odin"; -when ODIN_OS == "linux" do export "core:sync_linux.odin"; diff --git a/core/sync/sync_linux.odin b/core/sync/sync_linux.odin index b77d51e0a..561f3be6a 100644 --- a/core/sync/sync_linux.odin +++ b/core/sync/sync_linux.odin @@ -1,5 +1,7 @@ -import "core:atomics.odin" -import "core:os.odin" +package sync + +import "core:atomics" +import "core:os" Semaphore :: struct { // _handle: win32.Handle, diff --git a/core/sync/sync_windows.odin b/core/sync/sync_windows.odin index 0a76bbfb1..a8b292456 100644 --- a/core/sync/sync_windows.odin +++ b/core/sync/sync_windows.odin @@ -1,7 +1,7 @@ -when ODIN_OS == "windows" { - import win32 "core:sys/windows.odin"; -} -import "core:atomics.odin" +package sync + +import "core:sys/win32" +import "core:atomics" Semaphore :: struct { _handle: win32.Handle, diff --git a/core/sys/win32/wgl.odin b/core/sys/win32/wgl.odin index 1cc1e20fa..0d54f4cb8 100644 --- a/core/sys/win32/wgl.odin +++ b/core/sys/win32/wgl.odin @@ -1,9 +1,7 @@ +// +build windows package win32 -// when ODIN_OS == "windows" { - foreign import "system:opengl32.lib" -// } - +foreign import "system:opengl32.lib" CONTEXT_MAJOR_VERSION_ARB :: 0x2091; CONTEXT_MINOR_VERSION_ARB :: 0x2092; diff --git a/core/sys/win32/windows.odin b/core/sys/win32/windows.odin index 76b57979e..e52ff3f41 100644 --- a/core/sys/win32/windows.odin +++ b/core/sys/win32/windows.odin @@ -1,12 +1,11 @@ +// +build windows package win32 -// when ODIN_OS == "windows" { - foreign import "system:kernel32.lib" - foreign import "system:user32.lib" - foreign import "system:gdi32.lib" - foreign import "system:winmm.lib" - foreign import "system:shell32.lib" -// } +foreign import "system:kernel32.lib" +foreign import "system:user32.lib" +foreign import "system:gdi32.lib" +foreign import "system:winmm.lib" +foreign import "system:shell32.lib" Handle :: distinct rawptr; Hwnd :: distinct Handle; diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin index 90663d7b3..14265696c 100644 --- a/examples/demo/demo.odin +++ b/examples/demo/demo.odin @@ -18,6 +18,7 @@ import "core:c" when os.OS == "windows" { import "core:atomics" + import "core:sync" import "core:thread" import "core:sys/win32" } @@ -737,14 +738,6 @@ deprecated_attribute :: proc() { // foo_v1(1); } -A :: struct {x, y, z: int}; -B :: struct {x, y, z: int}; -C :: struct { - using a: A, - b: B, -} - - main :: proc() { when true { general_stuff(); diff --git a/src/check_decl.cpp b/src/check_decl.cpp index bdedc773e..4e4355968 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -89,7 +89,7 @@ Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *operand, Stri return e->type; } -void check_init_variables(CheckerContext *ctx, Entity **lhs, isize lhs_count, Array inits, String context_name) { +void check_init_variables(CheckerContext *ctx, Entity **lhs, isize lhs_count, Array const &inits, String context_name) { if ((lhs == nullptr || lhs_count == 0) && inits.count == 0) { return; } @@ -661,7 +661,7 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { } } -void check_var_decl(CheckerContext *ctx, Entity *e, Entity **entities, isize entity_count, AstNode *type_expr, Array init_expr_list) { +void check_var_decl(CheckerContext *ctx, Entity *e, Entity **entities, isize entity_count, AstNode *type_expr, Array const &init_expr_list) { GB_ASSERT(e->type == nullptr); GB_ASSERT(e->kind == Entity_Variable); diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 1576989cc..9e3486675 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -72,7 +72,7 @@ void update_expr_type (CheckerContext *c, AstNode *e, Type *ty bool check_is_terminating (AstNode *node); bool check_has_break (AstNode *stmt, bool implicit); void check_stmt (CheckerContext *c, AstNode *node, u32 flags); -void check_stmt_list (CheckerContext *c, Array stmts, u32 flags); +void check_stmt_list (CheckerContext *c, Array const &stmts, u32 flags); void check_init_constant (CheckerContext *c, Entity *e, Operand *operand); bool check_representable_as_constant(CheckerContext *c, ExactValue in_value, Type *type, ExactValue *out_value); bool check_procedure_type (CheckerContext *c, Type *type, AstNode *proc_type_node, Array *operands = nullptr); @@ -107,7 +107,7 @@ void error_operand_no_value(Operand *o) { } -void check_scope_decls(CheckerContext *c, Array nodes, isize reserve_size) { +void check_scope_decls(CheckerContext *c, Array const &nodes, isize reserve_size) { Scope *s = c->scope; GB_ASSERT(s->package == nullptr); @@ -4100,7 +4100,7 @@ isize add_dependencies_from_unpacking(CheckerContext *c, Entity **lhs, isize lhs } -void check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, Array *operands, Array rhs, bool allow_ok, bool *optional_ok_ = nullptr) { +void check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, Array *operands, Array const &rhs, bool allow_ok, bool *optional_ok_ = nullptr) { bool optional_ok = false; isize tuple_index = 0; for_array(i, rhs) { @@ -6279,7 +6279,7 @@ void check_expr_or_type(CheckerContext *c, Operand *o, AstNode *e, Type *type_hi gbString write_expr_to_string(gbString str, AstNode *node); -gbString write_struct_fields_to_string(gbString str, Array params) { +gbString write_struct_fields_to_string(gbString str, Array const ¶ms) { for_array(i, params) { if (i > 0) { str = gb_string_appendc(str, ", "); diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 5cf8804e9..ec7be19ad 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1,4 +1,4 @@ -void check_stmt_list(CheckerContext *ctx, Array stmts, u32 flags) { +void check_stmt_list(CheckerContext *ctx, Array const &stmts, u32 flags) { if (stmts.count == 0) { return; } @@ -43,7 +43,7 @@ void check_stmt_list(CheckerContext *ctx, Array stmts, u32 flags) { } } -bool check_is_terminating_list(Array stmts) { +bool check_is_terminating_list(Array const &stmts) { // Iterate backwards for (isize n = stmts.count-1; n >= 0; n--) { AstNode *stmt = stmts[n]; @@ -55,7 +55,7 @@ bool check_is_terminating_list(Array stmts) { return false; } -bool check_has_break_list(Array stmts, bool implicit) { +bool check_has_break_list(Array const &stmts, bool implicit) { for_array(i, stmts) { AstNode *stmt = stmts[i]; if (check_has_break(stmt, implicit)) { diff --git a/src/check_type.cpp b/src/check_type.cpp index c75832446..387369f7d 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -31,7 +31,7 @@ void populate_using_entity_scope(CheckerContext *ctx, AstNode *node, Type *t) { } -void check_struct_fields(CheckerContext *ctx, AstNode *node, Array *fields, Array params, +void check_struct_fields(CheckerContext *ctx, AstNode *node, Array *fields, Array const ¶ms, isize init_field_capacity, Type *named_type, String context) { *fields = array_make(heap_allocator(), 0, init_field_capacity); diff --git a/src/checker.cpp b/src/checker.cpp index ddcf976e2..2471bcf54 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -2233,13 +2233,13 @@ void check_all_global_entities(Checker *c) { GB_ASSERT(ctx.pkg != nullptr); GB_ASSERT(e->pkg != nullptr); - if (e->token.string == "main") { - if (e->kind != Entity_Procedure) { - if (pkg->kind == Package_Init) { - error(e->token, "'main' is reserved as the entry point procedure in the initial scope"); - continue; - } - } else if (pkg->kind == Package_Runtime) { + if (pkg->kind == Package_Init) { + if (e->kind != Entity_Procedure && e->token.string == "main") { + error(e->token, "'main' is reserved as the entry point procedure in the initial scope"); + continue; + } + } else if (pkg->kind == Package_Runtime) { + if (e->token.string == "main") { error(e->token, "'main' is reserved as the entry point procedure in the initial scope"); continue; } @@ -2249,7 +2249,6 @@ void check_all_global_entities(Checker *c) { ctx.scope = d->scope; check_entity_decl(&ctx, e, d, nullptr); - if (pkg->kind != Package_Runtime) { processing_preload = false; } diff --git a/src/ir.cpp b/src/ir.cpp index 154e7b2ad..65fa38932 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -2161,7 +2161,7 @@ irValue *ir_map_entries(irProcedure *proc, irValue *value) { GB_ASSERT_MSG(t->kind == Type_Map, "%s", type_to_string(t)); init_map_internal_types(t); Type *gst = t->Map.generated_struct_type; - isize index = 1; + i32 index = 1; irValue *entries = ir_emit(proc, ir_instr_struct_extract_value(proc, value, index, gst->Struct.fields[index]->type)); return entries; } @@ -2172,7 +2172,7 @@ irValue *ir_map_entries_ptr(irProcedure *proc, irValue *value) { GB_ASSERT_MSG(t->kind == Type_Map, "%s", type_to_string(t)); init_map_internal_types(t); Type *gst = t->Map.generated_struct_type; - isize index = 1; + i32 index = 1; Type *ptr_t = alloc_type_pointer(gst->Struct.fields[index]->type); irValue *entries = ir_emit(proc, ir_instr_struct_element_ptr(proc, value, index, ptr_t)); return entries; diff --git a/src/ir_print.cpp b/src/ir_print.cpp index fdbc8a950..ce5fcec9e 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -1652,6 +1652,10 @@ void ir_print_type_name(irFileBuffer *f, irModule *m, irValue *v) { ir_write_byte(f, '\n'); } +void foo_bar(void) { + +} + void print_llvm_ir(irGen *ir) { irModule *m = &ir->module; @@ -1805,7 +1809,7 @@ void print_llvm_ir(irGen *ir) { if (m->generate_debug_info) { ir_write_byte(f, '\n'); - i32 diec = m->debug_info.entries.count; + i32 diec = cast(i32)m->debug_info.entries.count; i32 di_version = diec+1; i32 di_debug_info = diec+2;