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 -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;