Use const & for Array<AstNode *> parameters

This commit is contained in:
gingerBill
2018-06-03 10:30:31 +01:00
parent 6202fb8373
commit 12b870ba66
13 changed files with 41 additions and 48 deletions
-2
View File
@@ -1,2 +0,0 @@
when ODIN_OS == "windows" do export "core:sync_windows.odin";
when ODIN_OS == "linux" do export "core:sync_linux.odin";
+4 -2
View File
@@ -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,
+4 -4
View File
@@ -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,
+2 -4
View File
@@ -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;
+6 -7
View File
@@ -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;
+1 -8
View File
@@ -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();
+2 -2
View File
@@ -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<AstNode *> inits, String context_name) {
void check_init_variables(CheckerContext *ctx, Entity **lhs, isize lhs_count, Array<AstNode *> 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<AstNode *> init_expr_list) {
void check_var_decl(CheckerContext *ctx, Entity *e, Entity **entities, isize entity_count, AstNode *type_expr, Array<AstNode *> const &init_expr_list) {
GB_ASSERT(e->type == nullptr);
GB_ASSERT(e->kind == Entity_Variable);
+4 -4
View File
@@ -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<AstNode *> stmts, u32 flags);
void check_stmt_list (CheckerContext *c, Array<AstNode *> 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<Operand> *operands = nullptr);
@@ -107,7 +107,7 @@ void error_operand_no_value(Operand *o) {
}
void check_scope_decls(CheckerContext *c, Array<AstNode *> nodes, isize reserve_size) {
void check_scope_decls(CheckerContext *c, Array<AstNode *> 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<Operand> *operands, Array<AstNode *> rhs, bool allow_ok, bool *optional_ok_ = nullptr) {
void check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, Array<Operand> *operands, Array<AstNode *> 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<AstNode *> params) {
gbString write_struct_fields_to_string(gbString str, Array<AstNode *> const &params) {
for_array(i, params) {
if (i > 0) {
str = gb_string_appendc(str, ", ");
+3 -3
View File
@@ -1,4 +1,4 @@
void check_stmt_list(CheckerContext *ctx, Array<AstNode *> stmts, u32 flags) {
void check_stmt_list(CheckerContext *ctx, Array<AstNode *> const &stmts, u32 flags) {
if (stmts.count == 0) {
return;
}
@@ -43,7 +43,7 @@ void check_stmt_list(CheckerContext *ctx, Array<AstNode *> stmts, u32 flags) {
}
}
bool check_is_terminating_list(Array<AstNode *> stmts) {
bool check_is_terminating_list(Array<AstNode *> 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<AstNode *> stmts) {
return false;
}
bool check_has_break_list(Array<AstNode *> stmts, bool implicit) {
bool check_has_break_list(Array<AstNode *> const &stmts, bool implicit) {
for_array(i, stmts) {
AstNode *stmt = stmts[i];
if (check_has_break(stmt, implicit)) {
+1 -1
View File
@@ -31,7 +31,7 @@ void populate_using_entity_scope(CheckerContext *ctx, AstNode *node, Type *t) {
}
void check_struct_fields(CheckerContext *ctx, AstNode *node, Array<Entity *> *fields, Array<AstNode *> params,
void check_struct_fields(CheckerContext *ctx, AstNode *node, Array<Entity *> *fields, Array<AstNode *> const &params,
isize init_field_capacity, Type *named_type, String context) {
*fields = array_make<Entity *>(heap_allocator(), 0, init_field_capacity);
+7 -8
View File
@@ -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;
}
+2 -2
View File
@@ -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;
+5 -1
View File
@@ -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;