Browse Source

Use templated `Array` with bounds checking

Ginger Bill 8 years ago
parent
commit
2a89d8021c
17 changed files with 670 additions and 667 deletions
  1. 92 92
      src/array.cpp
  2. 6 6
      src/build_settings.cpp
  3. 7 7
      src/check_decl.cpp
  4. 103 105
      src/check_expr.cpp
  5. 31 31
      src/check_stmt.cpp
  6. 64 66
      src/checker.cpp
  7. 0 4
      src/common.cpp
  8. 139 139
      src/ir.cpp
  9. 37 37
      src/ir_opt.cpp
  10. 18 18
      src/ir_print.cpp
  11. 2 2
      src/main.cpp
  12. 34 34
      src/map.cpp
  13. 56 54
      src/parser.cpp
  14. 57 48
      src/ssa.cpp
  15. 5 5
      src/timings.cpp
  16. 2 2
      src/tokenizer.cpp
  17. 17 17
      src/types.cpp

+ 92 - 92
src/array.cpp

@@ -1,98 +1,7 @@
 #define ARRAY_GROW_FORMULA(x) (2*(x) + 8)
 GB_STATIC_ASSERT(ARRAY_GROW_FORMULA(0) > 0);
 
-#define Array(Type_) struct { \
-	gbAllocator allocator; \
-	Type_ *     e; \
-	isize       count; \
-	isize       capacity; \
-}
-
-typedef Array(void) ArrayVoid;
-
-#define array_init_reserve(x_, allocator_, init_capacity_) do { \
-	void **e = cast(void **)&((x_)->e); \
-	GB_ASSERT((x_) != NULL); \
-	(x_)->allocator = (allocator_); \
-	(x_)->count = 0; \
-	(x_)->capacity = (init_capacity_); \
-	*e = gb_alloc((allocator_), gb_size_of(*(x_)->e)*(init_capacity_)); \
-} while (0)
-
-#define array_init_count(x_, allocator_, init_count_) do { \
-	void **e = cast(void **)&((x_)->e); \
-	GB_ASSERT((x_) != NULL); \
-	(x_)->allocator = (allocator_); \
-	(x_)->count = (init_count_); \
-	(x_)->capacity = (init_count_); \
-	*e = gb_alloc((allocator_), gb_size_of(*(x_)->e)*(init_count_)); \
-} while (0)
-
-#define array_init(x_, allocator_)        do { array_init_reserve(x_, allocator_, ARRAY_GROW_FORMULA(0)); } while (0)
-#define array_free(x_)                    do { gb_free((x_)->allocator, (x_)->e); } while (0)
-#define array_set_capacity(x_, capacity_) do { array__set_capacity((x_), (capacity_), gb_size_of(*(x_)->e)); } while (0)
-
-#define array_grow(x_, min_capacity_) do { \
-	isize new_capacity = ARRAY_GROW_FORMULA((x_)->capacity); \
-	if (new_capacity < (min_capacity_)) { \
-		new_capacity = (min_capacity_); \
-	} \
-	array_set_capacity(x_, new_capacity); \
-} while (0)
-
-#define array_add(x_, item_) do { \
-	if ((x_)->capacity < (x_)->count+1) { \
-		array_grow(x_, 0); \
-	} \
-	(x_)->e[(x_)->count++] = item_; \
-} while (0)
-
-#define array_pop(x_)   do { GB_ASSERT((x_)->count > 0); (x_)->count--; } while (0)
-#define array_clear(x_) do { (x_)->count = 0; } while (0)
-
-#define array_resize(x_, new_count_) do { \
-	if ((x_)->capacity < (new_count_)) { \
-		array_grow((x_), (new_count_)); \
-	} \
-	(x_)->count = (new_count_); \
-} while (0)
-
-#define array_reserve(x_, new_capacity_) do { \
-	if ((x_)->capacity < (new_capacity_)) { \
-		array_set_capacity((x_), (new_capacity_)); \
-	} \
-} while (0)
-
-
-
-
-void array__set_capacity(void *ptr, isize capacity, isize element_size) {
-	ArrayVoid *x = cast(ArrayVoid *)ptr;
-	GB_ASSERT(ptr != NULL);
-
-	GB_ASSERT(element_size > 0);
-
-	if (capacity == x->capacity) {
-		return;
-	}
-
-	if (capacity < x->count) {
-		if (x->capacity < capacity) {
-			isize new_capacity = ARRAY_GROW_FORMULA(x->capacity);
-			if (new_capacity < capacity) {
-				new_capacity = capacity;
-			}
-			array__set_capacity(ptr, new_capacity, element_size);
-		}
-		x->count = capacity;
-	}
-
-	x->e = gb_resize(x->allocator, x->e, element_size*x->capacity, element_size*capacity);
-	x->capacity = capacity;
-}
-
-
-#if 0
+#if 1
 template <typename T>
 struct Array {
 	gbAllocator allocator;
@@ -224,6 +133,97 @@ void array_set_capacity(Array<T> *array, isize capacity) {
 	array->capacity = capacity;
 }
 
+#endif
+
+#if 0
+#define Array(Type_) struct { \
+	gbAllocator allocator; \
+	Type_ *     e; \
+	isize       count; \
+	isize       capacity; \
+}
+
+typedef Array(void) ArrayVoid;
+
+#define array_init_reserve(x_, allocator_, init_capacity_) do { \
+	void **e = cast(void **)&((x_)->e); \
+	GB_ASSERT((x_) != NULL); \
+	(x_)->allocator = (allocator_); \
+	(x_)->count = 0; \
+	(x_)->capacity = (init_capacity_); \
+	*e = gb_alloc((allocator_), gb_size_of(*(x_)->e)*(init_capacity_)); \
+} while (0)
+
+#define array_init_count(x_, allocator_, init_count_) do { \
+	void **e = cast(void **)&((x_)->e); \
+	GB_ASSERT((x_) != NULL); \
+	(x_)->allocator = (allocator_); \
+	(x_)->count = (init_count_); \
+	(x_)->capacity = (init_count_); \
+	*e = gb_alloc((allocator_), gb_size_of(*(x_)->e)*(init_count_)); \
+} while (0)
 
+#define array_init(x_, allocator_)        do { array_init_reserve(x_, allocator_, ARRAY_GROW_FORMULA(0)); } while (0)
+#define array_free(x_)                    do { gb_free((x_)->allocator, (x_)->e); } while (0)
+#define array_set_capacity(x_, capacity_) do { array__set_capacity((x_), (capacity_), gb_size_of(*(x_)->e)); } while (0)
 
+#define array_grow(x_, min_capacity_) do { \
+	isize new_capacity = ARRAY_GROW_FORMULA((x_)->capacity); \
+	if (new_capacity < (min_capacity_)) { \
+		new_capacity = (min_capacity_); \
+	} \
+	array_set_capacity(x_, new_capacity); \
+} while (0)
+
+#define array_add(x_, item_) do { \
+	if ((x_)->capacity < (x_)->count+1) { \
+		array_grow(x_, 0); \
+	} \
+	(x_)->e[(x_)->count++] = item_; \
+} while (0)
+
+#define array_pop(x_)   do { GB_ASSERT((x_)->count > 0); (x_)->count--; } while (0)
+#define array_clear(x_) do { (x_)->count = 0; } while (0)
+
+#define array_resize(x_, new_count_) do { \
+	if ((x_)->capacity < (new_count_)) { \
+		array_grow((x_), (new_count_)); \
+	} \
+	(x_)->count = (new_count_); \
+} while (0)
+
+#define array_reserve(x_, new_capacity_) do { \
+	if ((x_)->capacity < (new_capacity_)) { \
+		array_set_capacity((x_), (new_capacity_)); \
+	} \
+} while (0)
+
+
+
+
+void array__set_capacity(void *ptr, isize capacity, isize element_size) {
+	ArrayVoid *x = cast(ArrayVoid *)ptr;
+	GB_ASSERT(ptr != NULL);
+
+	GB_ASSERT(element_size > 0);
+
+	if (capacity == x->capacity) {
+		return;
+	}
+
+	if (capacity < x->count) {
+		if (x->capacity < capacity) {
+			isize new_capacity = ARRAY_GROW_FORMULA(x->capacity);
+			if (new_capacity < capacity) {
+				new_capacity = capacity;
+			}
+			array__set_capacity(ptr, new_capacity, element_size);
+		}
+		x->count = capacity;
+	}
+
+	x->e = gb_resize(x->allocator, x->e, element_size*x->capacity, element_size*capacity);
+	x->capacity = capacity;
+}
 #endif
+

+ 6 - 6
src/build_settings.cpp

@@ -35,7 +35,7 @@ String const NIX_SEPARATOR_STRING   = {cast(u8 *)"/",  1};
 #if defined(GB_SYSTEM_WINDOWS)
 String odin_root_dir(void) {
 	String path = global_module_path;
-	Array(wchar_t) path_buf;
+	Array<wchar_t> path_buf;
 	isize len, i;
 	gbTempArenaMemory tmp;
 	wchar_t *text;
@@ -48,7 +48,7 @@ String odin_root_dir(void) {
 
 	len = 0;
 	for (;;) {
-		len = GetModuleFileNameW(NULL, &path_buf.e[0], path_buf.count);
+		len = GetModuleFileNameW(NULL, &path_buf[0], path_buf.count);
 		if (len == 0) {
 			return make_string(NULL, 0);
 		}
@@ -102,7 +102,7 @@ String odin_root_dir(void) {
 	len = 0;
 	for (;;) {
 		int sz = path_buf.count;
-		int res = _NSGetExecutablePath(&path_buf.e[0], &sz);
+		int res = _NSGetExecutablePath(&path_buf[0], &sz);
 		if(res == 0) {
 			len = sz;
 			break;
@@ -114,7 +114,7 @@ String odin_root_dir(void) {
 
 	tmp = gb_temp_arena_memory_begin(&string_buffer_arena);
 	text = gb_alloc_array(string_buffer_allocator, u8, len + 1);
-	gb_memmove(text, &path_buf.e[0], len);
+	gb_memmove(text, &path_buf[0], len);
 
 	path = make_string(text, len);
 	for (i = path.len-1; i >= 0; i--) {
@@ -158,7 +158,7 @@ String odin_root_dir(void) {
 		// of this compiler, it should be _good enough_.
 		// That said, there's no solid 100% method on Linux to get the program's
 		// path without checking this link. Sorry.
-		len = readlink("/proc/self/exe", &path_buf.e[0], path_buf.count);
+		len = readlink("/proc/self/exe", &path_buf[0], path_buf.count);
 		if(len == 0) {
 			return make_string(NULL, 0);
 		}
@@ -171,7 +171,7 @@ String odin_root_dir(void) {
 
 	tmp = gb_temp_arena_memory_begin(&string_buffer_arena);
 	text = gb_alloc_array(string_buffer_allocator, u8, len + 1);
-	gb_memmove(text, &path_buf.e[0], len);
+	gb_memmove(text, &path_buf[0], len);
 
 	path = make_string(text, len);
 	for (i = path.len-1; i >= 0; i--) {

+ 7 - 7
src/check_decl.cpp

@@ -67,20 +67,20 @@ void check_init_variables(Checker *c, Entity **lhs, isize lhs_count, AstNodeArra
 
 	// NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be
 	// an extra allocation
-	ArrayOperand operands = {};
-	array_init_reserve(&operands, c->tmp_allocator, 2*lhs_count);
+	Array<Operand> operands = {};
+	array_init(&operands, c->tmp_allocator, 2*lhs_count);
 	check_unpack_arguments(c, lhs_count, &operands, inits, true);
 
 	isize rhs_count = operands.count;
 	for_array(i, operands) {
-		if (operands.e[i].mode == Addressing_Invalid) {
+		if (operands[i].mode == Addressing_Invalid) {
 			rhs_count--;
 		}
 	}
 
 	isize max = gb_min(lhs_count, rhs_count);
 	for (isize i = 0; i < max; i++) {
-		check_init_variable(c, lhs[i], &operands.e[i], context_name);
+		check_init_variable(c, lhs[i], &operands[i], context_name);
 	}
 	if (rhs_count > 0 && lhs_count != rhs_count) {
 		error(lhs[0]->token, "Assignment count mismatch `%td` = `%td`", lhs_count, rhs_count);
@@ -432,7 +432,7 @@ void check_var_decl(Checker *c, Entity *e, Entity **entities, isize entity_count
 	}
 
 	AstNodeArray inits;
-	array_init_reserve(&inits, c->allocator, 1);
+	array_init(&inits, c->allocator, 1);
 	array_add(&inits, init_expr);
 	check_init_variables(c, entities, entity_count, inits, str_lit("variable declaration"));
 }
@@ -514,7 +514,7 @@ void check_proc_body(Checker *c, Token token, DeclInfo *decl, Type *type, AstNod
 				Scope **found = map_scope_get(&c->info.scopes, hash_pointer(t->Record.node));
 				GB_ASSERT(found != NULL);
 				for_array(i, (*found)->elements.entries) {
-					Entity *f = (*found)->elements.entries.e[i].value;
+					Entity *f = (*found)->elements.entries[i].value;
 					if (f->kind == Entity_Variable) {
 						Entity *uvar = make_entity_using_variable(c->allocator, e, f->token, f->type);
 						uvar->Variable.is_immutable = is_immutable;
@@ -555,7 +555,7 @@ void check_proc_body(Checker *c, Token token, DeclInfo *decl, Type *type, AstNod
 	if (decl->parent != NULL) {
 		// NOTE(bill): Add the dependencies from the procedure literal (lambda)
 		for_array(i, decl->deps.entries) {
-			HashKey key = decl->deps.entries.e[i].key;
+			HashKey key = decl->deps.entries[i].key;
 			Entity *e = cast(Entity *)key.ptr;
 			map_bool_set(&decl->parent->deps, key, true);
 		}

+ 103 - 105
src/check_expr.cpp

@@ -53,7 +53,7 @@ void check_scope_decls(Checker *c, AstNodeArray nodes, isize reserve_size) {
 	check_collect_entities(c, nodes, false);
 
 	for_array(i, s->elements.entries) {
-		Entity *e = s->elements.entries.e[i].value;
+		Entity *e = s->elements.entries[i].value;
 		switch (e->kind) {
 		case Entity_Constant:
 		case Entity_TypeName:
@@ -70,7 +70,7 @@ void check_scope_decls(Checker *c, AstNodeArray nodes, isize reserve_size) {
 	}
 
 	for_array(i, s->elements.entries) {
-		Entity *e = s->elements.entries.e[i].value;
+		Entity *e = s->elements.entries[i].value;
 		if (e->kind != Entity_Procedure) {
 			continue;
 		}
@@ -401,7 +401,7 @@ isize check_fields(Checker *c, AstNode *node, AstNodeArray decls,
 
 	isize field_index = 0;
 	for_array(decl_index, decls) {
-		AstNode *decl = decls.e[decl_index];
+		AstNode *decl = decls[decl_index];
 		if (decl->kind != AstNode_Field) {
 			continue;
 		}
@@ -412,13 +412,13 @@ isize check_fields(Checker *c, AstNode *node, AstNodeArray decls,
 
 		if (is_using) {
 			if (f->names.count > 1) {
-				error_node(f->names.e[0], "Cannot apply `using` to more than one of the same type");
+				error_node(f->names[0], "Cannot apply `using` to more than one of the same type");
 				is_using = false;
 			}
 		}
 
 		for_array(name_index, f->names) {
-			AstNode *name = f->names.e[name_index];
+			AstNode *name = f->names[name_index];
 			if (!ast_node_expect(name, AstNode_Ident)) {
 				continue;
 			}
@@ -454,15 +454,15 @@ isize check_fields(Checker *c, AstNode *node, AstNodeArray decls,
 			Type *t = base_type(type_deref(type));
 			if (!is_type_struct(t) && !is_type_raw_union(t) && !is_type_bit_field(t) &&
 			    f->names.count >= 1 &&
-			    f->names.e[0]->kind == AstNode_Ident) {
-				Token name_token = f->names.e[0]->Ident;
+			    f->names[0]->kind == AstNode_Ident) {
+				Token name_token = f->names[0]->Ident;
 				if (is_type_indexable(t)) {
 					bool ok = true;
 					for_array(emi, entity_map.entries) {
-						Entity *e = entity_map.entries.e[emi].value;
+						Entity *e = entity_map.entries[emi].value;
 						if (e->kind == Entity_Variable && e->flags & EntityFlag_Using) {
 							if (is_type_indexable(e->type)) {
-								if (e->identifier != f->names.e[0]) {
+								if (e->identifier != f->names[0]) {
 									ok = false;
 									using_index_expr = e;
 									break;
@@ -545,7 +545,7 @@ void check_struct_type(Checker *c, Type *struct_type, AstNode *node) {
 
 	isize field_count = 0;
 	for_array(field_index, st->fields) {
-	AstNode *field = st->fields.e[field_index];
+	AstNode *field = st->fields[field_index];
 		switch (field->kind) {
 		case_ast_node(f, Field, field);
 			field_count += f->names.count;
@@ -641,7 +641,7 @@ void check_union_type(Checker *c, Type *union_type, AstNode *node) {
 	isize variant_count = ut->variants.count+1;
 	isize field_count = 0;
 	for_array(i, ut->fields) {
-		AstNode *field = ut->fields.e[i];
+		AstNode *field = ut->fields[i];
 		if (field->kind == AstNode_Field) {
 			ast_node(f, Field, field);
 			field_count += f->names.count;
@@ -680,7 +680,7 @@ void check_union_type(Checker *c, Type *union_type, AstNode *node) {
 	}
 
 	for_array(i, ut->variants) {
-		AstNode *variant = ut->variants.e[i];
+		AstNode *variant = ut->variants[i];
 		if (variant->kind != AstNode_UnionField) {
 			continue;
 		}
@@ -694,12 +694,12 @@ void check_union_type(Checker *c, Type *union_type, AstNode *node) {
 			// NOTE(bill): Copy the contents for the common fields for now
 			AstNodeArray list = {};
 			array_init_count(&list, c->allocator, ut->fields.count+fl->list.count);
-			gb_memmove_array(list.e, ut->fields.e, ut->fields.count);
-			gb_memmove_array(list.e+ut->fields.count, fl->list.e, fl->list.count);
+			gb_memmove_array(list.data, ut->fields.data, ut->fields.count);
+			gb_memmove_array(list.data+ut->fields.count, fl->list.data, fl->list.count);
 
 			isize list_count = 0;
 			for_array(j, list) {
-				ast_node(f, Field, list.e[j]);
+				ast_node(f, Field, list[j]);
 				list_count += f->names.count;
 			}
 
@@ -760,7 +760,7 @@ void check_raw_union_type(Checker *c, Type *union_type, AstNode *node) {
 
 	isize field_count = 0;
 	for_array(field_index, ut->fields) {
-		AstNode *field = ut->fields.e[field_index];
+		AstNode *field = ut->fields[field_index];
 		switch (field->kind) {
 		case_ast_node(f, Field, field);
 			field_count += f->names.count;
@@ -817,7 +817,7 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod
 	ExactValue max_value = exact_value_i64(0);
 
 	for_array(i, et->fields) {
-		AstNode *field = et->fields.e[i];
+		AstNode *field = et->fields[i];
 		AstNode *ident = NULL;
 		AstNode *init = NULL;
 		if (field->kind == AstNode_FieldValue) {
@@ -932,7 +932,7 @@ void check_bit_field_type(Checker *c, Type *bit_field_type, Type *named_type, As
 
 	u32 curr_offset = 0;
 	for_array(i, bft->fields) {
-		AstNode *field = bft->fields.e[i];
+		AstNode *field = bft->fields[i];
 		GB_ASSERT(field->kind == AstNode_FieldValue);
 		AstNode *ident = field->FieldValue.field;
 		AstNode *value = field->FieldValue.value;
@@ -1041,7 +1041,7 @@ Type *check_get_params(Checker *c, Scope *scope, AstNode *_params, bool *is_vari
 
 	isize variable_count = 0;
 	for_array(i, params) {
-		AstNode *field = params.e[i];
+		AstNode *field = params[i];
 		if (ast_node_expect(field, AstNode_Field)) {
 			ast_node(f, Field, field);
 			variable_count += gb_max(f->names.count, 1);
@@ -1052,10 +1052,10 @@ Type *check_get_params(Checker *c, Scope *scope, AstNode *_params, bool *is_vari
 	Entity **variables = gb_alloc_array(c->allocator, Entity *, variable_count);
 	isize variable_index = 0;
 	for_array(i, params) {
-		if (params.e[i]->kind != AstNode_Field) {
+		if (params[i]->kind != AstNode_Field) {
 			continue;
 		}
-		ast_node(p, Field, params.e[i]);
+		ast_node(p, Field, params[i]);
 		AstNode *type_expr = p->type;
 		if (type_expr) {
 			if (type_expr->kind == AstNode_Ellipsis) {
@@ -1063,20 +1063,20 @@ Type *check_get_params(Checker *c, Scope *scope, AstNode *_params, bool *is_vari
 				if (i+1 == params.count) {
 					is_variadic = true;
 				} else {
-					error_node(params.e[i], "Invalid AST: Invalid variadic parameter");
+					error_node(params[i], "Invalid AST: Invalid variadic parameter");
 				}
 			}
 
 			Type *type = check_type(c, type_expr);
 			if (p->flags&FieldFlag_no_alias) {
 				if (!is_type_pointer(type)) {
-					error_node(params.e[i], "`no_alias` can only be applied to fields of pointer type");
+					error_node(params[i], "`no_alias` can only be applied to fields of pointer type");
 					p->flags &= ~FieldFlag_no_alias; // Remove the flag
 				}
 			}
 
 			for_array(j, p->names) {
-				AstNode *name = p->names.e[j];
+				AstNode *name = p->names[j];
 				if (ast_node_expect(name, AstNode_Ident)) {
 					Entity *param = make_entity_param(c->allocator, scope, name->Ident, type,
 					                                  (p->flags&FieldFlag_using) != 0, (p->flags&FieldFlag_immutable) != 0);
@@ -1127,7 +1127,7 @@ Type *check_get_results(Checker *c, Scope *scope, AstNode *_results) {
 
 	isize variable_count = 0;
 	for_array(i, results) {
-		AstNode *field = results.e[i];
+		AstNode *field = results[i];
 		if (ast_node_expect(field, AstNode_Field)) {
 			ast_node(f, Field, field);
 			variable_count += gb_max(f->names.count, 1);
@@ -1137,7 +1137,7 @@ Type *check_get_results(Checker *c, Scope *scope, AstNode *_results) {
 	Entity **variables = gb_alloc_array(c->allocator, Entity *, variable_count);
 	isize variable_index = 0;
 	for_array(i, results) {
-		ast_node(field, Field, results.e[i]);
+		ast_node(field, Field, results[i]);
 		Type *type = check_type(c, field->type);
 		if (field->names.count == 0) {
 			Token token = ast_node_token(field->type);
@@ -1149,7 +1149,7 @@ Type *check_get_results(Checker *c, Scope *scope, AstNode *_results) {
 				Token token = ast_node_token(field->type);
 				token.string = str_lit("");
 
-				AstNode *name = field->names.e[j];
+				AstNode *name = field->names[j];
 				if (name->kind != AstNode_Ident) {
 					error_node(name, "Expected an identifer for as the field name");
 				} else {
@@ -3551,7 +3551,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		// NOTE(bill): The first arg may be a Type, this will be checked case by case
 		break;
 	default:
-		check_multi_expr(c, operand, ce->args.e[0]);
+		check_multi_expr(c, operand, ce->args[0]);
 	}
 
 	switch (id) {
@@ -3609,10 +3609,10 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 	case BuiltinProc_new: {
 		// new :: proc(Type) -> ^Type
 		Operand op = {};
-		check_expr_or_type(c, &op, ce->args.e[0]);
+		check_expr_or_type(c, &op, ce->args[0]);
 		Type *type = op.type;
 		if ((op.mode != Addressing_Type && type == NULL) || type == t_invalid) {
-			error_node(ce->args.e[0], "Expected a type for `new`");
+			error_node(ce->args[0], "Expected a type for `new`");
 			return false;
 		}
 		operand->mode = Addressing_Value;
@@ -3623,16 +3623,16 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		// new_slice :: proc(Type, len: int) -> []Type
 		// new_slice :: proc(Type, len, cap: int) -> []Type
 		Operand op = {};
-		check_expr_or_type(c, &op, ce->args.e[0]);
+		check_expr_or_type(c, &op, ce->args[0]);
 		Type *type = op.type;
 		if ((op.mode != Addressing_Type && type == NULL) || type == t_invalid) {
-			error_node(ce->args.e[0], "Expected a type for `new_slice`");
+			error_node(ce->args[0], "Expected a type for `new_slice`");
 			return false;
 		}
 
 		isize arg_count = ce->args.count;
 		if (arg_count < 2 || 3 < arg_count) {
-			error_node(ce->args.e[0], "`new_slice` expects 2 or 3 arguments, found %td", arg_count);
+			error_node(ce->args[0], "`new_slice` expects 2 or 3 arguments, found %td", arg_count);
 			// NOTE(bill): Return the correct type to reduce errors
 		} else {
 			// If any are constant
@@ -3640,7 +3640,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			isize size_count = 0;
 			for (isize i = 1; i < arg_count; i++) {
 				i64 val = 0;
-				bool ok = check_index_value(c, ce->args.e[i], -1, &val);
+				bool ok = check_index_value(c, ce->args[i], -1, &val);
 				if (ok && val >= 0) {
 					GB_ASSERT(size_count < gb_count_of(sizes));
 					sizes[size_count++] = val;
@@ -3648,7 +3648,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			}
 
 			if (size_count == 2 && sizes[0] > sizes[1]) {
-				error_node(ce->args.e[1], "`new_slice` count and capacity are swapped");
+				error_node(ce->args[1], "`new_slice` count and capacity are swapped");
 				// No need quit
 			}
 		}
@@ -3661,10 +3661,10 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		// make :: proc(Type, len: int) -> Type
 		// make :: proc(Type, len, cap: int) -> Type
 		Operand op = {};
-		check_expr_or_type(c, &op, ce->args.e[0]);
+		check_expr_or_type(c, &op, ce->args[0]);
 		Type *type = op.type;
 		if ((op.mode != Addressing_Type && type == NULL) || type == t_invalid) {
-			error_node(ce->args.e[0], "Expected a type for `make`");
+			error_node(ce->args[0], "Expected a type for `make`");
 			return false;
 		}
 
@@ -3688,7 +3688,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 
 		isize arg_count = ce->args.count;
 		if (arg_count < min_args || max_args < arg_count) {
-			error_node(ce->args.e[0], "`make` expects %td or %d argument, found %td", min_args, max_args, arg_count);
+			error_node(ce->args[0], "`make` expects %td or %d argument, found %td", min_args, max_args, arg_count);
 			return false;
 		}
 
@@ -3697,7 +3697,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		isize size_count = 0;
 		for (isize i = 1; i < arg_count; i++) {
 			i64 val = 0;
-			bool ok = check_index_value(c, false, ce->args.e[i], -1, &val);
+			bool ok = check_index_value(c, false, ce->args[i], -1, &val);
 			if (ok && val >= 0) {
 				GB_ASSERT(size_count < gb_count_of(sizes));
 				sizes[size_count++] = val;
@@ -3705,7 +3705,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		}
 
 		if (size_count == 2 && sizes[0] > sizes[1]) {
-			error_node(ce->args.e[1], "`make` count and capacity are swapped");
+			error_node(ce->args[1], "`make` count and capacity are swapped");
 			// No need quit
 		}
 
@@ -3755,7 +3755,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			return false;
 		}
 
-		AstNode *capacity = ce->args.e[1];
+		AstNode *capacity = ce->args[1];
 		Operand op = {};
 		check_expr(c, &op, capacity);
 		if (op.mode == Addressing_Invalid) {
@@ -3846,7 +3846,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 
 		Type *key = base_type(type)->Map.key;
 		Operand x = {Addressing_Invalid};
-		AstNode *key_node = ce->args.e[1];
+		AstNode *key_node = ce->args[1];
 		Operand op = {};
 		check_expr(c, &op, key_node);
 		if (op.mode == Addressing_Invalid) {
@@ -3868,9 +3868,9 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 
 	case BuiltinProc_size_of: {
 		// size_of :: proc(Type) -> untyped int
-		Type *type = check_type(c, ce->args.e[0]);
+		Type *type = check_type(c, ce->args[0]);
 		if (type == NULL || type == t_invalid) {
-			error_node(ce->args.e[0], "Expected a type for `size_of`");
+			error_node(ce->args[0], "Expected a type for `size_of`");
 			return false;
 		}
 
@@ -3894,9 +3894,9 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 
 	case BuiltinProc_align_of: {
 		// align_of :: proc(Type) -> untyped int
-		Type *type = check_type(c, ce->args.e[0]);
+		Type *type = check_type(c, ce->args[0]);
 		if (type == NULL || type == t_invalid) {
-			error_node(ce->args.e[0], "Expected a type for `align_of`");
+			error_node(ce->args[0], "Expected a type for `align_of`");
 			return false;
 		}
 		operand->mode = Addressing_Constant;
@@ -3919,14 +3919,14 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 	case BuiltinProc_offset_of: {
 		// offset_of :: proc(Type, field) -> untyped int
 		Operand op = {};
-		Type *bt = check_type(c, ce->args.e[0]);
+		Type *bt = check_type(c, ce->args[0]);
 		Type *type = base_type(bt);
 		if (type == NULL || type == t_invalid) {
-			error_node(ce->args.e[0], "Expected a type for `offset_of`");
+			error_node(ce->args[0], "Expected a type for `offset_of`");
 			return false;
 		}
 
-		AstNode *field_arg = unparen_expr(ce->args.e[1]);
+		AstNode *field_arg = unparen_expr(ce->args[1]);
 		if (field_arg == NULL ||
 		    field_arg->kind != AstNode_Ident) {
 			error_node(field_arg, "Expected an identifier for field argument");
@@ -3942,14 +3942,14 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		Selection sel = lookup_field(c->allocator, type, arg->string, operand->mode == Addressing_Type);
 		if (sel.entity == NULL) {
 			gbString type_str = type_to_string(bt);
-			error_node(ce->args.e[0],
+			error_node(ce->args[0],
 			      "`%s` has no field named `%.*s`", type_str, LIT(arg->string));
 			gb_string_free(type_str);
 			return false;
 		}
 		if (sel.indirect) {
 			gbString type_str = type_to_string(bt);
-			error_node(ce->args.e[0],
+			error_node(ce->args[0],
 			      "Field `%.*s` is embedded via a pointer in `%s`", LIT(arg->string), type_str);
 			gb_string_free(type_str);
 			return false;
@@ -3962,7 +3962,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 
 	case BuiltinProc_offset_of_val: {
 		// offset_of_val :: proc(val: expression) -> untyped int
-		AstNode *arg = unparen_expr(ce->args.e[0]);
+		AstNode *arg = unparen_expr(ce->args[0]);
 		if (arg->kind != AstNode_SelectorExpr) {
 			gbString str = expr_to_string(arg);
 			error_node(arg, "`%s` is not a selector expression", str);
@@ -3997,7 +3997,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		}
 		if (sel.indirect) {
 			gbString type_str = type_to_string(type);
-			error_node(ce->args.e[0],
+			error_node(ce->args[0],
 			      "Field `%.*s` is embedded via a pointer in `%s`", LIT(i->string), type_str);
 			gb_string_free(type_str);
 			return false;
@@ -4031,7 +4031,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 
 		// NOTE(bill): The type information may not be setup yet
 		init_preload(c);
-		AstNode *expr = ce->args.e[0];
+		AstNode *expr = ce->args[0];
 		Type *type = check_type(c, expr);
 		if (type == NULL || type == t_invalid) {
 			error_node(expr, "Invalid argument to `type_info`");
@@ -4052,7 +4052,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 
 		// NOTE(bill): The type information may not be setup yet
 		init_preload(c);
-		AstNode *expr = ce->args.e[0];
+		AstNode *expr = ce->args[0];
 		check_assignment(c, operand, NULL, str_lit("argument of `type_info_of_val`"));
 		if (operand->mode == Addressing_Invalid || operand->mode == Addressing_Builtin)
 			return false;
@@ -4066,13 +4066,13 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		// compile_assert :: proc(cond: bool) -> bool
 
 		if (!is_type_boolean(operand->type) && operand->mode != Addressing_Constant) {
-			gbString str = expr_to_string(ce->args.e[0]);
+			gbString str = expr_to_string(ce->args[0]);
 			error_node(call, "`%s` is not a constant boolean", str);
 			gb_string_free(str);
 			return false;
 		}
 		if (!operand->value.value_bool) {
-			gbString str = expr_to_string(ce->args.e[0]);
+			gbString str = expr_to_string(ce->args[0]);
 			error_node(call, "Compile time assertion: `%s`", str);
 			gb_string_free(str);
 		}
@@ -4085,7 +4085,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		// assert :: proc(cond: bool) -> bool
 
 		if (!is_type_boolean(operand->type)) {
-			gbString str = expr_to_string(ce->args.e[0]);
+			gbString str = expr_to_string(ce->args[0]);
 			error_node(call, "`%s` is not a boolean", str);
 			gb_string_free(str);
 			return false;
@@ -4099,7 +4099,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		// panic :: proc(msg: string)
 
 		if (!is_type_string(operand->type)) {
-			gbString str = expr_to_string(ce->args.e[0]);
+			gbString str = expr_to_string(ce->args[0]);
 			error_node(call, "`%s` is not a string", str);
 			gb_string_free(str);
 			return false;
@@ -4117,7 +4117,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			dest_type = d->Slice.elem;
 		}
 		Operand op = {};
-		check_expr(c, &op, ce->args.e[1]);
+		check_expr(c, &op, ce->args[1]);
 		if (op.mode == Addressing_Invalid) {
 			return false;
 		}
@@ -4132,8 +4132,8 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		}
 
 		if (!are_types_identical(dest_type, src_type)) {
-			gbString d_arg = expr_to_string(ce->args.e[0]);
-			gbString s_arg = expr_to_string(ce->args.e[1]);
+			gbString d_arg = expr_to_string(ce->args[0]);
+			gbString s_arg = expr_to_string(ce->args[1]);
 			gbString d_str = type_to_string(dest_type);
 			gbString s_str = type_to_string(src_type);
 			error_node(call,
@@ -4169,7 +4169,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			if (i == 0) {
 				continue;
 			}
-			AstNode *arg = ce->args.e[i];
+			AstNode *arg = ce->args[i];
 			Operand op = {};
 			check_expr(c, &op, arg);
 			if (op.mode == Addressing_Invalid) {
@@ -4213,7 +4213,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 		operand->type = t_invalid;
 		operand->mode = Addressing_Invalid;
 
-		check_expr(c, &y, ce->args.e[1]);
+		check_expr(c, &y, ce->args[1]);
 		if (y.mode == Addressing_Invalid) {
 			return false;
 		}
@@ -4348,7 +4348,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 
 		isize arg_count = ce->args.count;
 		if (arg_count < 2 || 3 < arg_count) {
-			error_node(ce->args.e[0], "`slice_ptr` expects 2 or 3 arguments, found %td", arg_count);
+			error_node(ce->args[0], "`slice_ptr` expects 2 or 3 arguments, found %td", arg_count);
 			// NOTE(bill): Return the correct type to reduce errors
 		} else {
 			// If any are constant
@@ -4356,7 +4356,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			isize size_count = 0;
 			for (isize i = 1; i < arg_count; i++) {
 				i64 val = 0;
-				bool ok = check_index_value(c, false, ce->args.e[i], -1, &val);
+				bool ok = check_index_value(c, false, ce->args[i], -1, &val);
 				if (ok && val >= 0) {
 					GB_ASSERT(size_count < gb_count_of(sizes));
 					sizes[size_count++] = val;
@@ -4364,7 +4364,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			}
 
 			if (size_count == 2 && sizes[0] > sizes[1]) {
-				error_node(ce->args.e[1], "`slice_ptr` count and capacity are swapped");
+				error_node(ce->args[1], "`slice_ptr` count and capacity are swapped");
 				// No need quit
 			}
 		}
@@ -4396,7 +4396,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			return false;
 		}
 
-		AstNode *other_arg = ce->args.e[1];
+		AstNode *other_arg = ce->args[1];
 		Operand a = *operand;
 		Operand b = {};
 		check_expr(c, &b, other_arg);
@@ -4464,7 +4464,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			return false;
 		}
 
-		AstNode *other_arg = ce->args.e[1];
+		AstNode *other_arg = ce->args[1];
 		Operand a = *operand;
 		Operand b = {};
 		check_expr(c, &b, other_arg);
@@ -4566,8 +4566,8 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 			return false;
 		}
 
-		AstNode *min_arg = ce->args.e[1];
-		AstNode *max_arg = ce->args.e[2];
+		AstNode *min_arg = ce->args[1];
+		AstNode *max_arg = ce->args[2];
 		Operand x = *operand;
 		Operand y = {};
 		Operand z = {};
@@ -4646,13 +4646,13 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
 
 	case BuiltinProc_transmute: {
 		Operand op = {};
-		check_expr_or_type(c, &op, ce->args.e[0]);
+		check_expr_or_type(c, &op, ce->args[0]);
 		Type *t = op.type;
 		if ((op.mode != Addressing_Type && t == NULL) || t == t_invalid) {
-			error_node(ce->args.e[0], "Expected a type for `transmute`");
+			error_node(ce->args[0], "Expected a type for `transmute`");
 			return false;
 		}
-		AstNode *expr = ce->args.e[1];
+		AstNode *expr = ce->args[1];
 		Operand *o = operand;
 		check_expr(c, o, expr);
 		if (o->mode == Addressing_Invalid) {
@@ -4834,13 +4834,11 @@ int valid_proc_and_score_cmp(void const *a, void const *b) {
 	return sj < si ? -1 : sj > si;
 }
 
-typedef Array(Operand) ArrayOperand;
-
-bool check_unpack_arguments(Checker *c, isize lhs_count, ArrayOperand *operands, AstNodeArray rhs, bool allow_ok) {
+bool check_unpack_arguments(Checker *c, isize lhs_count, Array<Operand> *operands, AstNodeArray rhs, bool allow_ok) {
 	bool optional_ok = false;
 	for_array(i, rhs) {
 		Operand o = {};
-		check_multi_expr(c, &o, rhs.e[i]);
+		check_multi_expr(c, &o, rhs[i]);
 
 		if (o.type == NULL || o.type->kind != Type_Tuple) {
 			if (allow_ok && lhs_count == 2 && rhs.count == 1 &&
@@ -4877,8 +4875,8 @@ Type *check_call_arguments(Checker *c, Operand *operand, Type *proc_type, AstNod
 
 	ast_node(ce, CallExpr, call);
 
-	ArrayOperand operands;
-	array_init_reserve(&operands, heap_allocator(), 2*ce->args.count);
+	Array<Operand> operands;
+	array_init(&operands, heap_allocator(), 2*ce->args.count);
 	check_unpack_arguments(c, -1, &operands, ce->args, false);
 
 	if (operand->mode == Addressing_Overload) {
@@ -4905,7 +4903,7 @@ Type *check_call_arguments(Checker *c, Operand *operand, Type *proc_type, AstNod
 			Type *proc_type = base_type(p->type);
 			if (proc_type != NULL && is_type_proc(proc_type)) {
 				i64 score = 0;
-				CallArgumentError err = check_call_arguments_internal(c, call, proc_type, operands.e, operands.count, CallArgumentMode_NoErrors, &score);
+				CallArgumentError err = check_call_arguments_internal(c, call, proc_type, operands.data, operands.count, CallArgumentMode_NoErrors, &score);
 				if (err == CallArgumentError_None) {
 					valids[valid_count].index = i;
 					valids[valid_count].score = score;
@@ -4950,14 +4948,14 @@ Type *check_call_arguments(Checker *c, Operand *operand, Type *proc_type, AstNod
 			add_entity_use(c, expr, e);
 			proc_type = e->type;
 			i64 score = 0;
-			CallArgumentError err = check_call_arguments_internal(c, call, proc_type, operands.e, operands.count, CallArgumentMode_ShowErrors, &score);
+			CallArgumentError err = check_call_arguments_internal(c, call, proc_type, operands.data, operands.count, CallArgumentMode_ShowErrors, &score);
 		}
 
 		gb_free(heap_allocator(), valids);
 		gb_free(heap_allocator(), procs);
 	} else {
 		i64 score = 0;
-		CallArgumentError err = check_call_arguments_internal(c, call, proc_type, operands.e, operands.count, CallArgumentMode_ShowErrors, &score);
+		CallArgumentError err = check_call_arguments_internal(c, call, proc_type, operands.data, operands.count, CallArgumentMode_ShowErrors, &score);
 		array_free(&operands);
 	}
 	return proc_type;
@@ -4994,7 +4992,7 @@ ExprKind check_call_expr(Checker *c, Operand *operand, AstNode *call) {
 
 	if (operand->mode == Addressing_Invalid) {
 		for_array(i, ce->args) {
-			check_expr_base(c, operand, ce->args.e[i], NULL);
+			check_expr_base(c, operand, ce->args[i], NULL);
 		}
 		operand->mode = Addressing_Invalid;
 		operand->expr = call;
@@ -5010,7 +5008,7 @@ ExprKind check_call_expr(Checker *c, Operand *operand, AstNode *call) {
 		case 0:  error_node(call, "Missing argument in convertion to `%s`", str);   break;
 		default: error_node(call, "Too many arguments in convertion to `%s`", str); break;
 		case 1:
-			check_expr(c, operand, ce->args.e[0]);
+			check_expr(c, operand, ce->args[0]);
 			if (operand->mode != Addressing_Invalid) {
 				check_cast(c, operand, t);
 			}
@@ -5388,11 +5386,11 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 			}
 			{ // Checker values
 				isize field_count = t->Record.field_count;
-				if (cl->elems.e[0]->kind == AstNode_FieldValue) {
+				if (cl->elems[0]->kind == AstNode_FieldValue) {
 					bool *fields_visited = gb_alloc_array(c->allocator, bool, field_count);
 
 					for_array(i, cl->elems) {
-						AstNode *elem = cl->elems.e[i];
+						AstNode *elem = cl->elems[i];
 						if (elem->kind != AstNode_FieldValue) {
 							error_node(elem, "Mixture of `field = value` and value elements in a structure literal is not allowed");
 							continue;
@@ -5423,15 +5421,15 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 							continue;
 						}
 
-						Entity *field = t->Record.fields[sel.index.e[0]];
+						Entity *field = t->Record.fields[sel.index[0]];
 						add_entity_use(c, fv->field, field);
 
-						if (fields_visited[sel.index.e[0]]) {
+						if (fields_visited[sel.index[0]]) {
 							error_node(elem, "Duplicate field `%.*s` in structure literal", LIT(name));
 							continue;
 						}
 
-						fields_visited[sel.index.e[0]] = true;
+						fields_visited[sel.index[0]] = true;
 						check_expr(c, o, fv->value);
 
 						if (is_type_any(field->type) || is_type_union(field->type) || is_type_raw_union(field->type)) {
@@ -5455,7 +5453,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 					}
 
 					for_array(index, cl->elems) {
-						AstNode *elem = cl->elems.e[index];
+						AstNode *elem = cl->elems[index];
 						if (elem->kind == AstNode_FieldValue) {
 							error_node(elem, "Mixture of `field = value` and value elements in a structure literal is not allowed");
 							continue;
@@ -5533,8 +5531,8 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 			}
 
 			for (; index < elem_count; index++) {
-				GB_ASSERT(cl->elems.e != NULL);
-				AstNode *e = cl->elems.e[index];
+				GB_ASSERT(cl->elems.data != NULL);
+				AstNode *e = cl->elems[index];
 				if (e == NULL) {
 					error_node(node, "Invalid literal element");
 					continue;
@@ -5563,7 +5561,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 
 			if (t->kind == Type_Vector) {
 				if (t->Vector.count > 1 && gb_is_between(index, 2, t->Vector.count-1)) {
-					error_node(cl->elems.e[0], "Expected either 1 (broadcast) or %td elements in vector literal, got %td", t->Vector.count, index);
+					error_node(cl->elems[0], "Expected either 1 (broadcast) or %td elements in vector literal, got %td", t->Vector.count, index);
 				}
 			}
 
@@ -5585,11 +5583,11 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 			{ // Checker values
 				Type *field_types[2] = {t_rawptr, t_type_info_ptr};
 				isize field_count = 2;
-				if (cl->elems.e[0]->kind == AstNode_FieldValue) {
+				if (cl->elems[0]->kind == AstNode_FieldValue) {
 					bool fields_visited[2] = {};
 
 					for_array(i, cl->elems) {
-						AstNode *elem = cl->elems.e[i];
+						AstNode *elem = cl->elems[i];
 						if (elem->kind != AstNode_FieldValue) {
 							error_node(elem, "Mixture of `field = value` and value elements in a `any` literal is not allowed");
 							continue;
@@ -5609,7 +5607,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 							continue;
 						}
 
-						isize index = sel.index.e[0];
+						isize index = sel.index[0];
 
 						if (fields_visited[index]) {
 							error_node(elem, "Duplicate field `%.*s` in `any` literal", LIT(name));
@@ -5626,7 +5624,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 					}
 				} else {
 					for_array(index, cl->elems) {
-						AstNode *elem = cl->elems.e[index];
+						AstNode *elem = cl->elems[index];
 						if (elem->kind == AstNode_FieldValue) {
 							error_node(elem, "Mixture of `field = value` and value elements in a `any` literal is not allowed");
 							continue;
@@ -5658,7 +5656,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 			is_constant = false;
 			{ // Checker values
 				for_array(i, cl->elems) {
-					AstNode *elem = cl->elems.e[i];
+					AstNode *elem = cl->elems[i];
 					if (elem->kind != AstNode_FieldValue) {
 						error_node(elem, "Only `field = value` elements are allowed in a map literal");
 						continue;
@@ -6146,7 +6144,7 @@ gbString write_record_fields_to_string(gbString str, AstNodeArray params) {
 		if (i > 0) {
 			str = gb_string_appendc(str, ", ");
 		}
-		str = write_expr_to_string(str, params.e[i]);
+		str = write_expr_to_string(str, params[i]);
 	}
 	return str;
 }
@@ -6200,7 +6198,7 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
 			if (i > 0) {
 				str = gb_string_appendc(str, ", ");
 			}
-			str = write_expr_to_string(str, cl->elems.e[i]);
+			str = write_expr_to_string(str, cl->elems[i]);
 		}
 		str = gb_string_appendc(str, "}");
 	case_end;
@@ -6321,7 +6319,7 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
 		}
 
 		for_array(i, f->names) {
-			AstNode *name = f->names.e[i];
+			AstNode *name = f->names[i];
 			if (i > 0) {
 				str = gb_string_appendc(str, ", ");
 			}
@@ -6341,7 +6339,7 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
 			if (i > 0) {
 				str = gb_string_appendc(str, ", ");
 			}
-			str = write_expr_to_string(str, f->list.e[i]);
+			str = write_expr_to_string(str, f->list[i]);
 		}
 	case_end;
 
@@ -6357,7 +6355,7 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
 		str = gb_string_appendc(str, "(");
 
 		for_array(i, ce->args) {
-			AstNode *arg = ce->args.e[i];
+			AstNode *arg = ce->args[i];
 			if (i > 0) {
 				str = gb_string_appendc(str, ", ");
 			}
@@ -6406,7 +6404,7 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
 			if (i > 0) {
 				str = gb_string_appendc(str, ", ");
 			}
-			str = write_expr_to_string(str, et->fields.e[i]);
+			str = write_expr_to_string(str, et->fields[i]);
 		}
 		str = gb_string_appendc(str, "}");
 	case_end;

+ 31 - 31
src/check_stmt.cpp

@@ -12,13 +12,13 @@ void check_stmt_list(Checker *c, AstNodeArray stmts, u32 flags) {
 
 	isize max = stmts.count;
 	for (isize i = stmts.count-1; i >= 0; i--) {
-		if (stmts.e[i]->kind != AstNode_EmptyStmt) {
+		if (stmts[i]->kind != AstNode_EmptyStmt) {
 			break;
 		}
 		max--;
 	}
 	for (isize i = 0; i < max; i++) {
-		AstNode *n = stmts.e[i];
+		AstNode *n = stmts[i];
 		if (n->kind == AstNode_EmptyStmt) {
 			continue;
 		}
@@ -43,7 +43,7 @@ void check_stmt_list(Checker *c, AstNodeArray stmts, u32 flags) {
 bool check_is_terminating_list(AstNodeArray stmts) {
 	// Iterate backwards
 	for (isize n = stmts.count-1; n >= 0; n--) {
-		AstNode *stmt = stmts.e[n];
+		AstNode *stmt = stmts[n];
 		if (stmt->kind != AstNode_EmptyStmt) {
 			return check_is_terminating(stmt);
 		}
@@ -54,7 +54,7 @@ bool check_is_terminating_list(AstNodeArray stmts) {
 
 bool check_has_break_list(AstNodeArray stmts, bool implicit) {
 	for_array(i, stmts) {
-		AstNode *stmt = stmts.e[i];
+		AstNode *stmt = stmts[i];
 		if (check_has_break(stmt, implicit)) {
 			return true;
 		}
@@ -137,7 +137,7 @@ bool check_is_terminating(AstNode *node) {
 	case_ast_node(ms, MatchStmt, node);
 		bool has_default = false;
 		for_array(i, ms->body->BlockStmt.stmts) {
-			AstNode *clause = ms->body->BlockStmt.stmts.e[i];
+			AstNode *clause = ms->body->BlockStmt.stmts[i];
 			ast_node(cc, CaseClause, clause);
 			if (cc->list.count == 0) {
 				has_default = true;
@@ -153,7 +153,7 @@ bool check_is_terminating(AstNode *node) {
 	case_ast_node(ms, TypeMatchStmt, node);
 		bool has_default = false;
 		for_array(i, ms->body->BlockStmt.stmts) {
-			AstNode *clause = ms->body->BlockStmt.stmts.e[i];
+			AstNode *clause = ms->body->BlockStmt.stmts[i];
 			ast_node(cc, CaseClause, clause);
 			if (cc->list.count == 0) {
 				has_default = true;
@@ -448,7 +448,7 @@ void check_label(Checker *c, AstNode *label) {
 
 	bool ok = true;
 	for_array(i, c->context.decl->labels) {
-		BlockLabel bl = c->context.decl->labels.e[i];
+		BlockLabel bl = c->context.decl->labels[i];
 		if (bl.name == name) {
 			error_node(label, "Duplicate label with the name `%.*s`", LIT(name));
 			ok = false;
@@ -513,7 +513,7 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
 	case Entity_ImportName: {
 		Scope *scope = e->ImportName.scope;
 		for_array(i, scope->elements.entries) {
-			Entity *decl = scope->elements.entries.e[i].value;
+			Entity *decl = scope->elements.entries[i].value;
 			Entity *found = scope_insert_entity(c->context.scope, decl);
 			if (found != NULL) {
 				gbString expr_str = expr_to_string(expr);
@@ -539,7 +539,7 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
 			GB_ASSERT(found_ != NULL);
 			Scope *found = *found_;
 			for_array(i, found->elements.entries) {
-				Entity *f = found->elements.entries.e[i].value;
+				Entity *f = found->elements.entries[i].value;
 				if (f->kind == Entity_Variable) {
 					Entity *uvar = make_entity_using_variable(c->allocator, e, f->token, f->type);
 					// if (is_selector) {
@@ -693,23 +693,23 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 
 			// NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be
 			// an extra allocation
-			ArrayOperand operands = {};
-			array_init_reserve(&operands, c->tmp_allocator, 2 * lhs_count);
+			Array<Operand> operands = {};
+			array_init(&operands, c->tmp_allocator, 2 * lhs_count);
 			check_unpack_arguments(c, lhs_count, &operands, as->rhs, true);
 
 			isize rhs_count = operands.count;
 			for_array(i, operands) {
-				if (operands.e[i].mode == Addressing_Invalid) {
+				if (operands[i].mode == Addressing_Invalid) {
 					rhs_count--;
 				}
 			}
 
 			isize max = gb_min(lhs_count, rhs_count);
 			for (isize i = 0; i < max; i++) {
-				check_assignment_variable(c, &operands.e[i], as->lhs.e[i]);
+				check_assignment_variable(c, &operands[i], as->lhs[i]);
 			}
 			if (lhs_count != rhs_count) {
-				error_node(as->lhs.e[0], "Assignment count mismatch `%td` = `%td`", lhs_count, rhs_count);
+				error_node(as->lhs[0], "Assignment count mismatch `%td` = `%td`", lhs_count, rhs_count);
 			}
 
 			gb_temp_arena_memory_end(tmp);
@@ -732,15 +732,15 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 			be->op = op;
 			be->op.kind = cast(TokenKind)(cast(i32)be->op.kind - (Token_AddEq - Token_Add));
 			 // NOTE(bill): Only use the first one will be used
-			be->left  = as->lhs.e[0];
-			be->right = as->rhs.e[0];
+			be->left  = as->lhs[0];
+			be->right = as->rhs[0];
 
 			check_binary_expr(c, &operand, &binary_expr);
 			if (operand.mode == Addressing_Invalid) {
 				return;
 			}
 			// NOTE(bill): Only use the first one will be used
-			check_assignment_variable(c, &operand, as->lhs.e[0]);
+			check_assignment_variable(c, &operand, as->lhs[0]);
 		} break;
 		}
 	case_end;
@@ -794,7 +794,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 		}
 
 
-		Type *proc_type = c->proc_stack.e[c->proc_stack.count-1];
+		Type *proc_type = c->proc_stack[c->proc_stack.count-1];
 		isize result_count = 0;
 		if (proc_type->Proc.results) {
 			result_count = proc_type->Proc.results->Tuple.variable_count;
@@ -816,13 +816,13 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 				check_init_variables(c, variables, result_count,
 				                     rs->results, str_lit("return statement"));
 				// if (pos.line == 10) {
-				// 	AstNode *x = rs->results.e[0];
+				// 	AstNode *x = rs->results[0];
 				// 	gb_printf_err("%s\n", expr_to_string(x));
 				// 	gb_printf_err("%s\n", type_to_string(type_of_expr(&c->info, x)));
 				// }
 			}
 		} else if (rs->results.count > 0) {
-			error_node(rs->results.e[0], "No return values expected");
+			error_node(rs->results[0], "No return values expected");
 		}
 	case_end;
 
@@ -1106,7 +1106,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 		AstNode *first_default = NULL;
 		ast_node(bs, BlockStmt, ms->body);
 		for_array(i, bs->stmts) {
-			AstNode *stmt = bs->stmts.e[i];
+			AstNode *stmt = bs->stmts[i];
 			AstNode *default_stmt = NULL;
 			if (stmt->kind == AstNode_CaseClause) {
 				ast_node(cc, CaseClause, stmt);
@@ -1134,7 +1134,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 		map_type_and_token_init(&seen, heap_allocator());
 
 		for_array(i, bs->stmts) {
-			AstNode *stmt = bs->stmts.e[i];
+			AstNode *stmt = bs->stmts[i];
 			if (stmt->kind != AstNode_CaseClause) {
 				// NOTE(bill): error handled by above multiple default checker
 				continue;
@@ -1142,7 +1142,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 			ast_node(cc, CaseClause, stmt);
 
 			for_array(j, cc->list) {
-				AstNode *expr = unparen_expr(cc->list.e[j]);
+				AstNode *expr = unparen_expr(cc->list[j]);
 
 				if (is_ast_node_a_range(expr)) {
 					ast_node(ie, BinaryExpr, expr);
@@ -1297,8 +1297,8 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 			syntax_error(as_token, "Expected 1 expression after `in`");
 			break;
 		}
-		AstNode *lhs = as->lhs.e[0];
-		AstNode *rhs = as->rhs.e[0];
+		AstNode *lhs = as->lhs[0];
+		AstNode *rhs = as->rhs[0];
 
 		check_expr(c, &x, rhs);
 		check_assignment(c, &x, NULL, str_lit("type match expression"));
@@ -1316,7 +1316,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 		AstNode *first_default = NULL;
 		ast_node(bs, BlockStmt, ms->body);
 		for_array(i, bs->stmts) {
-			AstNode *stmt = bs->stmts.e[i];
+			AstNode *stmt = bs->stmts[i];
 			AstNode *default_stmt = NULL;
 			if (stmt->kind == AstNode_CaseClause) {
 				ast_node(cc, CaseClause, stmt);
@@ -1350,7 +1350,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 		map_bool_init(&seen, heap_allocator());
 
 		for_array(i, bs->stmts) {
-			AstNode *stmt = bs->stmts.e[i];
+			AstNode *stmt = bs->stmts[i];
 			if (stmt->kind != AstNode_CaseClause) {
 				// NOTE(bill): error handled by above multiple default checker
 				continue;
@@ -1362,7 +1362,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 
 			Type *case_type = NULL;
 			for_array(type_index, cc->list) {
-				AstNode *type_expr = cc->list.e[type_index];
+				AstNode *type_expr = cc->list[type_index];
 				if (type_expr != NULL) { // Otherwise it's a default expression
 					Operand y = {};
 					check_expr_or_type(c, &y, type_expr);
@@ -1502,7 +1502,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 			return;
 		}
 		for_array(i, us->list) {
-			AstNode *expr = unparen_expr(us->list.e[0]);
+			AstNode *expr = unparen_expr(us->list[0]);
 			Entity *e = NULL;
 
 			bool is_selector = false;
@@ -1555,7 +1555,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 			}
 
 			for_array(i, vd->names) {
-				AstNode *name = vd->names.e[i];
+				AstNode *name = vd->names[i];
 				Entity *entity = NULL;
 				if (name->kind != AstNode_Ident) {
 					error_node(name, "A variable declaration must be an identifier");
@@ -1638,7 +1638,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
 						Scope **found = map_scope_get(&c->info.scopes, hash_pointer(t->Record.node));
 						GB_ASSERT(found != NULL);
 						for_array(i, (*found)->elements.entries) {
-							Entity *f = (*found)->elements.entries.e[i].value;
+							Entity *f = (*found)->elements.entries[i].value;
 							if (f->kind == Entity_Variable) {
 								Entity *uvar = make_entity_using_variable(c->allocator, e, f->token, f->type);
 								uvar->Variable.is_immutable = is_immutable;

+ 64 - 66
src/checker.cpp

@@ -197,7 +197,7 @@ struct DeclInfo {
 	AstNode *         proc_lit; // AstNode_ProcLit
 
 	MapBool           deps; // Key: Entity *
-	Array(BlockLabel) labels;
+	Array<BlockLabel> labels;
 };
 
 // ProcedureInfo stores the information needed for checking a procedure
@@ -240,8 +240,8 @@ typedef struct Scope {
 	MapEntity        elements; // Key: String
 	MapBool          implicit; // Key: Entity *
 
-	Array(Scope *)   shared;
-	Array(Scope *)   imported;
+	Array<Scope *>   shared;
+	Array<Scope *>   imported;
 	bool             is_proc;
 	bool             is_global;
 	bool             is_file;
@@ -286,10 +286,10 @@ typedef struct DelayedDecl {
 } DelayedDecl;
 
 typedef struct CheckerFileNode {
-	i32       id;
-	Array_i32 wheres;
-	Array_i32 whats;
-	i32       score; // Higher the score, the better
+	i32        id;
+	Array<i32> wheres;
+	Array<i32> whats;
+	i32        score; // Higher the score, the better
 } CheckerFileNode;
 
 typedef struct CheckerContext {
@@ -324,10 +324,10 @@ typedef struct Checker {
 
 	AstFile *              curr_ast_file;
 	Scope *                global_scope;
-	Array(ProcedureInfo)   procs; // NOTE(bill): Procedures to check
-	Array(DelayedDecl)     delayed_imports;
-	Array(DelayedDecl)     delayed_foreign_libraries;
-	Array(CheckerFileNode) file_nodes;
+	Array<ProcedureInfo>   procs; // NOTE(bill): Procedures to check
+	Array<DelayedDecl>     delayed_imports;
+	Array<DelayedDecl>     delayed_foreign_libraries;
+	Array<CheckerFileNode> file_nodes;
 
 	gbArena                arena;
 	gbArena                tmp_arena;
@@ -336,7 +336,7 @@ typedef struct Checker {
 
 	CheckerContext         context;
 
-	Array(Type *)          proc_stack;
+	Array<Type *>          proc_stack;
 	bool                   done_preload;
 } Checker;
 
@@ -347,8 +347,6 @@ typedef struct DelayedEntity {
 	DeclInfo *  decl;
 } DelayedEntity;
 
-typedef Array(DelayedEntity) DelayedEntities;
-
 
 
 
@@ -406,7 +404,7 @@ Scope *make_scope(Scope *parent, gbAllocator allocator) {
 
 void destroy_scope(Scope *scope) {
 	for_array(i, scope->elements.entries) {
-		Entity *e =scope->elements.entries.e[i].value;
+		Entity *e =scope->elements.entries[i].value;
 		if (e->kind == Entity_Variable) {
 			if (!(e->flags & EntityFlag_Used)) {
 #if 0
@@ -462,7 +460,7 @@ Entity *current_scope_lookup_entity(Scope *s, String name) {
 		return *found;
 	}
 	for_array(i, s->shared) {
-		Scope *shared = s->shared.e[i];
+		Scope *shared = s->shared[i];
 		Entity **found = map_entity_get(&shared->elements, key);
 		if (found) {
 			Entity *e = *found;
@@ -512,7 +510,7 @@ void scope_lookup_parent_entity(Scope *scope, String name, Scope **scope_, Entit
 		} else {
 			// Check shared scopes - i.e. other files @ global scope
 			for_array(i, s->shared) {
-				Scope *shared = s->shared.e[i];
+				Scope *shared = s->shared[i];
 				Entity **found = map_entity_get(&shared->elements, key);
 				if (found) {
 					Entity *e = *found;
@@ -753,7 +751,7 @@ void init_checker(Checker *c, Parser *parser, BuildContext *bc) {
 	array_init(&c->file_nodes, a);
 
 	for_array(i, parser->files) {
-		AstFile *file = &parser->files.e[i];
+		AstFile *file = &parser->files[i];
 		CheckerFileNode node = {};
 		node.id = file->id;
 		array_init(&node.whats,  a);
@@ -765,7 +763,7 @@ void init_checker(Checker *c, Parser *parser, BuildContext *bc) {
 	isize item_size = gb_max3(gb_size_of(Entity), gb_size_of(Type), gb_size_of(Scope));
 	isize total_token_count = 0;
 	for_array(i, c->parser->files) {
-		AstFile *f = &c->parser->files.e[i];
+		AstFile *f = &c->parser->files[i];
 		total_token_count += f->tokens.count;
 	}
 	isize arena_size = 2 * item_size * total_token_count;
@@ -961,7 +959,7 @@ void add_type_info_type(Checker *c, Type *t) {
 
 	isize ti_index = -1;
 	for_array(i, c->info.type_info_map.entries) {
-		MapIsizeEntry *e = &c->info.type_info_map.entries.e[i];
+		MapIsizeEntry *e = &c->info.type_info_map.entries[i];
 		Type *prev_type = cast(Type *)e->key.ptr;
 		if (are_types_identical(t, prev_type)) {
 			// Duplicate entry
@@ -1107,7 +1105,7 @@ void pop_procedure(Checker *c) {
 Type *const curr_procedure_type(Checker *c) {
 	isize count = c->proc_stack.count;
 	if (count > 0) {
-		return c->proc_stack.e[count-1];
+		return c->proc_stack[count-1];
 	}
 	return NULL;
 }
@@ -1143,7 +1141,7 @@ void add_dependency_to_map(MapEntity *map, CheckerInfo *info, Entity *node) {
 
 	DeclInfo *decl = *found;
 	for_array(i, decl->deps.entries) {
-		Entity *e = cast(Entity *)decl->deps.entries.e[i].key.ptr;
+		Entity *e = cast(Entity *)decl->deps.entries[i].key.ptr;
 		add_dependency_to_map(map, info, e);
 	}
 }
@@ -1153,7 +1151,7 @@ MapEntity generate_minimum_dependency_map(CheckerInfo *info, Entity *start) {
 	map_entity_init(&map, heap_allocator());
 
 	for_array(i, info->definitions.entries) {
-		Entity *e = info->definitions.entries.e[i].value;
+		Entity *e = info->definitions.entries[i].value;
 		if (e->scope->is_global) {
 			// NOTE(bill): Require runtime stuff
 			add_dependency_to_map(&map, info, e);
@@ -1401,21 +1399,21 @@ bool check_arity_match(Checker *c, AstNodeValueDecl *d) {
 
 	if (rhs == 0) {
 		if (d->type == NULL) {
-			error_node(d->names.e[0], "Missing type or initial expression");
+			error_node(d->names[0], "Missing type or initial expression");
 			return false;
 		}
 	} else if (lhs < rhs) {
 		if (lhs < d->values.count) {
-			AstNode *n = d->values.e[lhs];
+			AstNode *n = d->values[lhs];
 			gbString str = expr_to_string(n);
 			error_node(n, "Extra initial expression `%s`", str);
 			gb_string_free(str);
 		} else {
-			error_node(d->names.e[0], "Extra initial expression");
+			error_node(d->names[0], "Extra initial expression");
 		}
 		return false;
 	} else if (lhs > rhs && rhs != 1) {
-		AstNode *n = d->names.e[rhs];
+		AstNode *n = d->names[rhs];
 		gbString str = expr_to_string(n);
 		error_node(n, "Missing expression for `%s`", str);
 		gb_string_free(str);
@@ -1466,7 +1464,7 @@ void check_collect_entities(Checker *c, AstNodeArray nodes, bool is_file_scope)
 	}
 
 	for_array(decl_index, nodes) {
-		AstNode *decl = nodes.e[decl_index];
+		AstNode *decl = nodes[decl_index];
 		if (!is_ast_node_decl(decl) && !is_ast_node_when_stmt(decl)) {
 			continue;
 		}
@@ -1498,7 +1496,7 @@ void check_collect_entities(Checker *c, AstNodeArray nodes, bool is_file_scope)
 					di = make_declaration_info(heap_allocator(), c->context.scope, c->context.decl);
 					di->entities = entities;
 					di->type_expr = vd->type;
-					di->init_expr = vd->values.e[0];
+					di->init_expr = vd->values[0];
 
 
 					if (vd->flags & VarDeclFlag_thread_local) {
@@ -1508,10 +1506,10 @@ void check_collect_entities(Checker *c, AstNodeArray nodes, bool is_file_scope)
 
 
 				for_array(i, vd->names) {
-					AstNode *name = vd->names.e[i];
+					AstNode *name = vd->names[i];
 					AstNode *value = NULL;
 					if (i < vd->values.count) {
-						value = vd->values.e[i];
+						value = vd->values[i];
 					}
 					if (name->kind != AstNode_Ident) {
 						error_node(name, "A declaration's name must be an identifier, got %.*s", LIT(ast_node_strings[name->kind]));
@@ -1545,7 +1543,7 @@ void check_collect_entities(Checker *c, AstNodeArray nodes, bool is_file_scope)
 				check_arity_match(c, vd);
 			} else {
 				for_array(i, vd->names) {
-					AstNode *name = vd->names.e[i];
+					AstNode *name = vd->names[i];
 					if (name->kind != AstNode_Ident) {
 						error_node(name, "A declaration's name must be an identifier, got %.*s", LIT(ast_node_strings[name->kind]));
 						continue;
@@ -1553,7 +1551,7 @@ void check_collect_entities(Checker *c, AstNodeArray nodes, bool is_file_scope)
 
 					AstNode *init = NULL;
 					if (i < vd->values.count) {
-						init = vd->values.e[i];
+						init = vd->values[i];
 					}
 
 					DeclInfo *d = make_declaration_info(c->allocator, c->context.scope, c->context.decl);
@@ -1648,7 +1646,7 @@ void check_collect_entities(Checker *c, AstNodeArray nodes, bool is_file_scope)
 		// NOTE(bill): `when` stmts need to be handled after the other as the condition may refer to something
 		// declared after this stmt in source
 		for_array(i, nodes) {
-			AstNode *node = nodes.e[i];
+			AstNode *node = nodes[i];
 			switch (node->kind) {
 			case_ast_node(ws, WhenStmt, node);
 				check_collect_entities_from_when_stmt(c, ws, is_file_scope);
@@ -1663,7 +1661,7 @@ void check_all_global_entities(Checker *c) {
 	Scope *prev_file = {};
 
 	for_array(i, c->info.entities.entries) {
-		MapDeclInfoEntry *entry = &c->info.entities.entries.e[i];
+		MapDeclInfoEntry *entry = &c->info.entities.entries[i];
 		Entity *e = cast(Entity *)cast(uintptr)entry->key.key;
 		DeclInfo *d = entry->value;
 
@@ -1701,7 +1699,7 @@ void check_all_global_entities(Checker *c) {
 	}
 
 	for_array(i, c->info.entities.entries) {
-		MapDeclInfoEntry *entry = &c->info.entities.entries.e[i];
+		MapDeclInfoEntry *entry = &c->info.entities.entries[i];
 		Entity *e = cast(Entity *)cast(uintptr)entry->key.key;
 		if (e->kind != Entity_Procedure) {
 			continue;
@@ -1779,8 +1777,8 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 		Array_i32 shared_global_file_ids = {};
 		array_init_reserve(&shared_global_file_ids, heap_allocator(), c->file_nodes.count);
 		for_array(i, c->file_nodes) {
-			CheckerFileNode *node = &c->file_nodes.e[i];
-			AstFile *f = &c->parser->files.e[node->id];
+			CheckerFileNode *node = &c->file_nodes[i];
+			AstFile *f = &c->parser->files[node->id];
 			GB_ASSERT(f->id == node->id);
 			if (f->scope->is_global) {
 				array_add(&shared_global_file_ids, f->id);
@@ -1788,11 +1786,11 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 		}
 
 		for_array(i, c->file_nodes) {
-			CheckerFileNode *node = &c->file_nodes.e[i];
-			AstFile *f = &c->parser->files.e[node->id];
+			CheckerFileNode *node = &c->file_nodes[i];
+			AstFile *f = &c->parser->files[node->id];
 			if (!f->scope->is_global) {
 				for_array(j, shared_global_file_ids) {
-					array_add(&node->whats, shared_global_file_ids.e[j]);
+					array_add(&node->whats, shared_global_file_ids[j]);
 				}
 			}
 		}
@@ -1801,8 +1799,8 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 	}
 
 	for_array(i, c->delayed_imports) {
-		Scope *parent_scope = c->delayed_imports.e[i].parent;
-		AstNode *decl = c->delayed_imports.e[i].decl;
+		Scope *parent_scope = c->delayed_imports[i].parent;
+		AstNode *decl = c->delayed_imports[i].decl;
 		ast_node(id, ImportDecl, decl);
 		Token token = id->relpath;
 
@@ -1816,7 +1814,7 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 		Scope **found = map_scope_get(file_scopes, key);
 		if (found == NULL) {
 			for_array(scope_index, file_scopes->entries) {
-				Scope *scope = file_scopes->entries.e[scope_index].value;
+				Scope *scope = file_scopes->entries[scope_index].value;
 				gb_printf_err("%.*s\n", LIT(scope->file->tokenizer.fullpath));
 			}
 			gb_printf_err("%.*s(%td:%td)\n", LIT(token.pos.file), token.pos.line, token.pos.column);
@@ -1832,10 +1830,10 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 		i32 child_id  = scope->file->id;
 
 		// TODO(bill): Very slow
-		CheckerFileNode *parent_node = &c->file_nodes.e[parent_id];
+		CheckerFileNode *parent_node = &c->file_nodes[parent_id];
 		bool add_child = true;
 		for_array(j, parent_node->whats) {
-			if (parent_node->whats.e[j] == child_id) {
+			if (parent_node->whats[j] == child_id) {
 				add_child = false;
 				break;
 			}
@@ -1844,10 +1842,10 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 			array_add(&parent_node->whats, child_id);
 		}
 
-		CheckerFileNode *child_node  = &c->file_nodes.e[child_id];
+		CheckerFileNode *child_node  = &c->file_nodes[child_id];
 		bool add_parent = true;
 		for_array(j, parent_node->wheres) {
-			if (parent_node->wheres.e[j] == parent_id) {
+			if (parent_node->wheres[j] == parent_id) {
 				add_parent = false;
 				break;
 			}
@@ -1858,24 +1856,24 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 	}
 
 	for_array(i, c->file_nodes) {
-		CheckerFileNode *node = &c->file_nodes.e[i];
-		AstFile *f = &c->parser->files.e[node->id];
+		CheckerFileNode *node = &c->file_nodes[i];
+		AstFile *f = &c->parser->files[node->id];
 		gb_printf_err("File %d %.*s", node->id, LIT(f->tokenizer.fullpath));
 		gb_printf_err("\n  wheres:");
 		for_array(j, node->wheres) {
-			gb_printf_err(" %d", node->wheres.e[j]);
+			gb_printf_err(" %d", node->wheres[j]);
 		}
 		gb_printf_err("\n  whats:");
 		for_array(j, node->whats) {
-			gb_printf_err(" %d", node->whats.e[j]);
+			gb_printf_err(" %d", node->whats[j]);
 		}
 		gb_printf_err("\n");
 	}
 #endif
 
 	for_array(i, c->delayed_imports) {
-		Scope *parent_scope = c->delayed_imports.e[i].parent;
-		AstNode *decl = c->delayed_imports.e[i].decl;
+		Scope *parent_scope = c->delayed_imports[i].parent;
+		AstNode *decl = c->delayed_imports[i].decl;
 		ast_node(id, ImportDecl, decl);
 		Token token = id->relpath;
 
@@ -1889,7 +1887,7 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 		Scope **found = map_scope_get(file_scopes, key);
 		if (found == NULL) {
 			for_array(scope_index, file_scopes->entries) {
-				Scope *scope = file_scopes->entries.e[scope_index].value;
+				Scope *scope = file_scopes->entries[scope_index].value;
 				gb_printf_err("%.*s\n", LIT(scope->file->tokenizer.fullpath));
 			}
 			gb_printf_err("%.*s(%td:%td)\n", LIT(token.pos.file), token.pos.line, token.pos.column);
@@ -1917,7 +1915,7 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 
 		bool previously_added = false;
 		for_array(import_index, parent_scope->imported) {
-			Scope *prev = parent_scope->imported.e[import_index];
+			Scope *prev = parent_scope->imported[import_index];
 			if (prev == scope) {
 				previously_added = true;
 				break;
@@ -1935,7 +1933,7 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 		if (id->import_name.string == ".") {
 			// NOTE(bill): Add imported entities to this file's scope
 			for_array(elem_index, scope->elements.entries) {
-				Entity *e = scope->elements.entries.e[elem_index].value;
+				Entity *e = scope->elements.entries[elem_index].value;
 				if (e->scope == parent_scope) {
 					continue;
 				}
@@ -1974,8 +1972,8 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
 	}
 
 	for_array(i, c->delayed_foreign_libraries) {
-		Scope *parent_scope = c->delayed_foreign_libraries.e[i].parent;
-		AstNode *decl = c->delayed_foreign_libraries.e[i].decl;
+		Scope *parent_scope = c->delayed_foreign_libraries[i].parent;
+		AstNode *decl = c->delayed_foreign_libraries[i].decl;
 		ast_node(fl, ForeignLibrary, decl);
 
 		String file_str = fl->filepath.string;
@@ -2029,7 +2027,7 @@ void check_parsed_files(Checker *c) {
 
 	// Map full filepaths to Scopes
 	for_array(i, c->parser->files) {
-		AstFile *f = &c->parser->files.e[i];
+		AstFile *f = &c->parser->files[i];
 		Scope *scope = NULL;
 		scope = make_scope(c->global_scope, c->allocator);
 		scope->is_global = f->is_global_scope;
@@ -2056,7 +2054,7 @@ void check_parsed_files(Checker *c) {
 
 	// Collect Entities
 	for_array(i, c->parser->files) {
-		AstFile *f = &c->parser->files.e[i];
+		AstFile *f = &c->parser->files[i];
 		CheckerContext prev_context = c->context;
 		add_curr_ast_file(c, f);
 		check_collect_entities(c, f->decls, true);
@@ -2071,7 +2069,7 @@ void check_parsed_files(Checker *c) {
 	// Check procedure bodies
 	// NOTE(bill): Nested procedures bodies will be added to this "queue"
 	for_array(i, c->procs) {
-		ProcedureInfo *pi = &c->procs.e[i];
+		ProcedureInfo *pi = &c->procs[i];
 		CheckerContext prev_context = c->context;
 		add_curr_ast_file(c, pi->file);
 
@@ -2094,7 +2092,7 @@ void check_parsed_files(Checker *c) {
 
 	// Add untyped expression values
 	for_array(i, c->info.untyped.entries) {
-		MapExprInfoEntry *entry = &c->info.untyped.entries.e[i];
+		MapExprInfoEntry *entry = &c->info.untyped.entries[i];
 		HashKey key = entry->key;
 		AstNode *expr = cast(AstNode *)cast(uintptr)key.key;
 		ExprInfo *info = &entry->value;
@@ -2132,7 +2130,7 @@ void check_parsed_files(Checker *c) {
 
 	// NOTE(bill): Check for illegal cyclic type declarations
 	for_array(i, c->info.definitions.entries) {
-		Entity *e = c->info.definitions.entries.e[i].value;
+		Entity *e = c->info.definitions.entries[i].value;
 		if (e->kind == Entity_TypeName) {
 			if (e->type != NULL) {
 				// i64 size  = type_size_of(c->sizes, c->allocator, e->type);
@@ -2148,13 +2146,13 @@ void check_parsed_files(Checker *c) {
 
 	if (!build_context.is_dll) {
 		for_array(i, file_scopes.entries) {
-			Scope *s = file_scopes.entries.e[i].value;
+			Scope *s = file_scopes.entries[i].value;
 			if (s->is_init) {
 				Entity *e = current_scope_lookup_entity(s, str_lit("main"));
 				if (e == NULL) {
 					Token token = {};
 					if (s->file->tokens.count > 0) {
-						token = s->file->tokens.e[0];
+						token = s->file->tokens[0];
 					} else {
 						token.pos.file = s->file->tokenizer.fullpath;
 						token.pos.line = 1;

+ 0 - 4
src/common.cpp

@@ -242,10 +242,6 @@ f64 gb_sqrt(f64 x) {
 //
 ////////////////////////////////////////////////////////////////
 
-typedef Array(i32)   Array_i32;
-typedef Array(isize) Array_isize;
-
-
 #define MAP_TYPE String
 #define MAP_PROC map_string_
 #define MAP_NAME MapString

File diff suppressed because it is too large
+ 139 - 139
src/ir.cpp


+ 37 - 37
src/ir_opt.cpp

@@ -48,7 +48,7 @@ void ir_opt_add_operands(irValueArray *ops, irInstr *i) {
 		break;
 	case irInstr_Phi:
 		for_array(j, i->Phi.edges) {
-			array_add(ops, i->Phi.edges.e[j]);
+			array_add(ops, i->Phi.edges[j]);
 		}
 		break;
 	case irInstr_Unreachable:
@@ -97,24 +97,24 @@ void ir_opt_add_operands(irValueArray *ops, irInstr *i) {
 
 void ir_opt_block_replace_pred(irBlock *b, irBlock *from, irBlock *to) {
 	for_array(i, b->preds) {
-		irBlock *pred = b->preds.e[i];
+		irBlock *pred = b->preds[i];
 		if (pred == from) {
-			b->preds.e[i] = to;
+			b->preds[i] = to;
 		}
 	}
 }
 
 void ir_opt_block_replace_succ(irBlock *b, irBlock *from, irBlock *to) {
 	for_array(i, b->succs) {
-		irBlock *succ = b->succs.e[i];
+		irBlock *succ = b->succs[i];
 		if (succ == from) {
-			b->succs.e[i] = to;
+			b->succs[i] = to;
 		}
 	}
 }
 
 bool ir_opt_block_has_phi(irBlock *b) {
-	return b->instrs.e[0]->Instr.kind == irInstr_Phi;
+	return b->instrs[0]->Instr.kind == irInstr_Phi;
 }
 
 
@@ -129,7 +129,7 @@ bool ir_opt_block_has_phi(irBlock *b) {
 irValueArray ir_get_block_phi_nodes(irBlock *b) {
 	irValueArray phis = {0};
 	for_array(i, b->instrs) {
-		irInstr *instr = &b->instrs.e[i]->Instr;
+		irInstr *instr = &b->instrs[i]->Instr;
 		if (instr->kind != irInstr_Phi) {
 			phis = b->instrs;
 			phis.count = i;
@@ -143,19 +143,19 @@ void ir_remove_pred(irBlock *b, irBlock *p) {
 	irValueArray phis = ir_get_block_phi_nodes(b);
 	isize i = 0;
 	for_array(j, b->preds) {
-		irBlock *pred = b->preds.e[j];
+		irBlock *pred = b->preds[j];
 		if (pred != p) {
-			b->preds.e[i] = b->preds.e[j];
+			b->preds[i] = b->preds[j];
 			for_array(k, phis) {
-				irInstrPhi *phi = &phis.e[k]->Instr.Phi;
-				phi->edges.e[i] = phi->edges.e[j];
+				irInstrPhi *phi = &phis[k]->Instr.Phi;
+				phi->edges[i] = phi->edges[j];
 			}
 			i++;
 		}
 	}
 	b->preds.count = i;
 	for_array(k, phis) {
-		irInstrPhi *phi = &phis.e[k]->Instr.Phi;
+		irInstrPhi *phi = &phis[k]->Instr.Phi;
 		phi->edges.count = i;
 	}
 
@@ -164,13 +164,13 @@ void ir_remove_pred(irBlock *b, irBlock *p) {
 void ir_remove_dead_blocks(irProcedure *proc) {
 	isize j = 0;
 	for_array(i, proc->blocks) {
-		irBlock *b = proc->blocks.e[i];
+		irBlock *b = proc->blocks[i];
 		if (b == NULL) {
 			continue;
 		}
 		// NOTE(bill): Swap order
 		b->index = j;
-		proc->blocks.e[j++] = b;
+		proc->blocks[j++] = b;
 	}
 	proc->blocks.count = j;
 }
@@ -180,7 +180,7 @@ void ir_mark_reachable(irBlock *b) {
 	isize const BLACK = -1;
 	b->index = BLACK;
 	for_array(i, b->succs) {
-		irBlock *succ = b->succs.e[i];
+		irBlock *succ = b->succs[i];
 		if (succ->index == WHITE) {
 			ir_mark_reachable(succ);
 		}
@@ -191,23 +191,23 @@ void ir_remove_unreachable_blocks(irProcedure *proc) {
 	isize const WHITE =  0;
 	isize const BLACK = -1;
 	for_array(i, proc->blocks) {
-		proc->blocks.e[i]->index = WHITE;
+		proc->blocks[i]->index = WHITE;
 	}
 
-	ir_mark_reachable(proc->blocks.e[0]);
+	ir_mark_reachable(proc->blocks[0]);
 
 	for_array(i, proc->blocks) {
-		irBlock *b = proc->blocks.e[i];
+		irBlock *b = proc->blocks[i];
 		if (b->index == WHITE) {
 			for_array(j, b->succs) {
-				irBlock *c = b->succs.e[j];
+				irBlock *c = b->succs[j];
 				if (c->index == BLACK) {
 					ir_remove_pred(c, b);
 				}
 			}
 			// NOTE(bill): Mark as empty but don't actually free it
 			// As it's been allocated with an arena
-			proc->blocks.e[i] = NULL;
+			proc->blocks[i] = NULL;
 		}
 	}
 	ir_remove_dead_blocks(proc);
@@ -217,7 +217,7 @@ bool ir_opt_block_fusion(irProcedure *proc, irBlock *a) {
 	if (a->succs.count != 1) {
 		return false;
 	}
-	irBlock *b = a->succs.e[0];
+	irBlock *b = a->succs[0];
 	if (b->preds.count != 1) {
 		return false;
 	}
@@ -228,21 +228,21 @@ bool ir_opt_block_fusion(irProcedure *proc, irBlock *a) {
 
 	array_pop(&a->instrs); // Remove branch at end
 	for_array(i, b->instrs) {
-		array_add(&a->instrs, b->instrs.e[i]);
-		ir_set_instr_parent(b->instrs.e[i], a);
+		array_add(&a->instrs, b->instrs[i]);
+		ir_set_instr_parent(b->instrs[i], a);
 	}
 
 	array_clear(&a->succs);
 	for_array(i, b->succs) {
-		array_add(&a->succs, b->succs.e[i]);
+		array_add(&a->succs, b->succs[i]);
 	}
 
 	// Fix preds links
 	for_array(i, b->succs) {
-		ir_opt_block_replace_pred(b->succs.e[i], b, a);
+		ir_opt_block_replace_pred(b->succs[i], b, a);
 	}
 
-	proc->blocks.e[b->index] = NULL;
+	proc->blocks[b->index] = NULL;
 	return true;
 }
 
@@ -254,7 +254,7 @@ void ir_opt_blocks(irProcedure *proc) {
 	while (changed) {
 		changed = false;
 		for_array(i, proc->blocks) {
-			irBlock *b = proc->blocks.e[i];
+			irBlock *b = proc->blocks[i];
 			if (b == NULL) {
 				continue;
 			}
@@ -274,15 +274,15 @@ void ir_opt_build_referrers(irProcedure *proc) {
 	gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&proc->module->tmp_arena);
 
 	irValueArray ops = {0}; // NOTE(bill): Act as a buffer
-	array_init_reserve(&ops, proc->module->tmp_allocator, 64); // HACK(bill): This _could_ overflow the temp arena
+	array_init(&ops, proc->module->tmp_allocator, 64); // HACK(bill): This _could_ overflow the temp arena
 	for_array(i, proc->blocks) {
-		irBlock *b = proc->blocks.e[i];
+		irBlock *b = proc->blocks[i];
 		for_array(j, b->instrs) {
-			irValue *instr = b->instrs.e[j];
+			irValue *instr = b->instrs[j];
 			array_clear(&ops);
 			ir_opt_add_operands(&ops, &instr->Instr);
 			for_array(k, ops) {
-				irValue *op = ops.e[k];
+				irValue *op = ops[k];
 				if (op == NULL) {
 					continue;
 				}
@@ -324,7 +324,7 @@ i32 ir_lt_depth_first_search(irLTState *lt, irBlock *p, i32 i, irBlock **preorde
 	lt->sdom[p->index] = p;
 	ir_lt_link(lt, NULL, p);
 	for_array(index, p->succs) {
-		irBlock *q = p->succs.e[index];
+		irBlock *q = p->succs[index];
 		if (lt->sdom[q->index] == NULL) {
 			lt->parent[q->index] = p;
 			i = ir_lt_depth_first_search(lt, q, i, preorder);
@@ -354,7 +354,7 @@ irDomPrePost ir_opt_number_dom_tree(irBlock *v, i32 pre, i32 post) {
 
 	v->dom.pre = pre++;
 	for_array(i, v->dom.children) {
-		result = ir_opt_number_dom_tree(v->dom.children.e[i], result.pre, result.post);
+		result = ir_opt_number_dom_tree(v->dom.children[i], result.pre, result.post);
 	}
 	v->dom.post = post++;
 
@@ -381,7 +381,7 @@ void ir_opt_build_dom_tree(irProcedure *proc) {
 
 	irBlock **preorder = &buf[3*n];
 	irBlock **buckets  = &buf[4*n];
-	irBlock *root = proc->blocks.e[0];
+	irBlock *root = proc->blocks[0];
 
 	// Step 1 - number vertices
 	i32 pre_num = ir_lt_depth_first_search(&lt, root, 0, preorder);
@@ -403,7 +403,7 @@ void ir_opt_build_dom_tree(irProcedure *proc) {
 		// Step 2 - Compute all sdoms
 		lt.sdom[w->index] = lt.parent[w->index];
 		for_array(pred_index, w->preds) {
-			irBlock *v = w->preds.e[pred_index];
+			irBlock *v = w->preds[pred_index];
 			irBlock *u = ir_lt_eval(&lt, v);
 			if (lt.sdom[u->index]->dom.pre < lt.sdom[w->index]->dom.pre) {
 				lt.sdom[w->index] = lt.sdom[u->index];
@@ -438,7 +438,7 @@ void ir_opt_build_dom_tree(irProcedure *proc) {
 			}
 
 			// Calculate children relation as inverse of idom
-			if (w->dom.idom->dom.children.e == NULL) {
+			if (w->dom.idom->dom.children.data == NULL) {
 				// TODO(bill): Is this good enough for memory allocations?
 				array_init(&w->dom.idom->dom.children, heap_allocator());
 			}
@@ -461,7 +461,7 @@ void ir_opt_tree(irGen *s) {
 	s->opt_called = true;
 
 	for_array(member_index, s->module.procs) {
-		irProcedure *proc = s->module.procs.e[member_index];
+		irProcedure *proc = s->module.procs[member_index];
 		if (proc->blocks.count == 0) { // Prototype/external procedure
 			continue;
 		}

+ 18 - 18
src/ir_print.cpp

@@ -497,7 +497,7 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
 				if (i > 0) {
 					ir_fprintf(f, ", ");
 				}
-				TypeAndValue tav = type_and_value_of_expr(m->info, cl->elems.e[i]);
+				TypeAndValue tav = type_and_value_of_expr(m->info, cl->elems[i]);
 				GB_ASSERT(tav.mode != Addressing_Invalid);
 				ir_print_compound_element(f, m, tav.value, elem_type);
 			}
@@ -527,7 +527,7 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
 			ir_fprintf(f, "][");
 
 			if (elem_count == 1 && type->Vector.count > 1) {
-				TypeAndValue tav = type_and_value_of_expr(m->info, cl->elems.e[0]);
+				TypeAndValue tav = type_and_value_of_expr(m->info, cl->elems[0]);
 				GB_ASSERT(tav.mode != Addressing_Invalid);
 
 				for (isize i = 0; i < type->Vector.count; i++) {
@@ -541,7 +541,7 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
 					if (i > 0) {
 						ir_fprintf(f, ", ");
 					}
-					TypeAndValue tav = type_and_value_of_expr(m->info, cl->elems.e[i]);
+					TypeAndValue tav = type_and_value_of_expr(m->info, cl->elems[i]);
 					GB_ASSERT(tav.mode != Addressing_Invalid);
 					ir_print_compound_element(f, m, tav.value, elem_type);
 				}
@@ -563,24 +563,24 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
 			ExactValue *values = gb_alloc_array(m->tmp_allocator, ExactValue, value_count);
 
 
-			if (cl->elems.e[0]->kind == AstNode_FieldValue) {
+			if (cl->elems[0]->kind == AstNode_FieldValue) {
 				isize elem_count = cl->elems.count;
 				for (isize i = 0; i < elem_count; i++) {
-					ast_node(fv, FieldValue, cl->elems.e[i]);
+					ast_node(fv, FieldValue, cl->elems[i]);
 					String name = fv->field->Ident.string;
 
 					TypeAndValue tav = type_and_value_of_expr(m->info, fv->value);
 					GB_ASSERT(tav.mode != Addressing_Invalid);
 
 					Selection sel = lookup_field(m->allocator, type, name, false);
-					Entity *f = type->Record.fields[sel.index.e[0]];
+					Entity *f = type->Record.fields[sel.index[0]];
 
 					values[f->Variable.field_index] = tav.value;
 				}
 			} else {
 				for (isize i = 0; i < value_count; i++) {
 					Entity *f = type->Record.fields_in_src_order[i];
-					TypeAndValue tav = type_and_value_of_expr(m->info, cl->elems.e[i]);
+					TypeAndValue tav = type_and_value_of_expr(m->info, cl->elems[i]);
 					ExactValue val = {};
 					if (tav.mode != Addressing_Invalid) {
 						val = tav.value;
@@ -891,11 +891,11 @@ void ir_print_instr(irFileBuffer *f, irModule *m, irValue *value) {
 				ir_fprintf(f, ", ");
 			}
 
-			irValue *edge = instr->Phi.edges.e[i];
+			irValue *edge = instr->Phi.edges[i];
 			irBlock *block = NULL;
 			if (instr->parent != NULL &&
 			    i < instr->parent->preds.count) {
-				block = instr->parent->preds.e[i];
+				block = instr->parent->preds[i];
 			}
 
 			ir_fprintf(f, "[ ");
@@ -1538,14 +1538,14 @@ void ir_print_proc(irFileBuffer *f, irModule *m, irProcedure *proc) {
 
 		ir_fprintf(f, "{\n");
 		for_array(i, proc->blocks) {
-			irBlock *block = proc->blocks.e[i];
+			irBlock *block = proc->blocks[i];
 
 			if (i > 0) ir_fprintf(f, "\n");
 			ir_print_block_name(f, block);
 			ir_fprintf(f, ":\n");
 
 			for_array(j, block->instrs) {
-				irValue *value = block->instrs.e[j];
+				irValue *value = block->instrs[j];
 				ir_print_instr(f, m, value);
 			}
 		}
@@ -1555,7 +1555,7 @@ void ir_print_proc(irFileBuffer *f, irModule *m, irProcedure *proc) {
 	}
 
 	for_array(i, proc->children) {
-		ir_print_proc(f, m, proc->children.e[i]);
+		ir_print_proc(f, m, proc->children[i]);
 	}
 }
 
@@ -1606,7 +1606,7 @@ void print_llvm_ir(irGen *ir) {
 
 
 	for_array(member_index, m->members.entries) {
-		MapIrValueEntry *entry = &m->members.entries.e[member_index];
+		MapIrValueEntry *entry = &m->members.entries[member_index];
 		irValue *v = entry->value;
 		if (v->kind != irValue_TypeName) {
 			continue;
@@ -1619,7 +1619,7 @@ void print_llvm_ir(irGen *ir) {
 	bool dll_main_found = false;
 
 	for_array(member_index, m->members.entries) {
-		MapIrValueEntry *entry = &m->members.entries.e[member_index];
+		MapIrValueEntry *entry = &m->members.entries[member_index];
 		irValue *v = entry->value;
 		if (v->kind != irValue_Proc) {
 			continue;
@@ -1631,7 +1631,7 @@ void print_llvm_ir(irGen *ir) {
 	}
 
 	for_array(member_index, m->members.entries) {
-		MapIrValueEntry *entry = &m->members.entries.e[member_index];
+		MapIrValueEntry *entry = &m->members.entries[member_index];
 		irValue *v = entry->value;
 		if (v->kind != irValue_Proc) {
 			continue;
@@ -1643,7 +1643,7 @@ void print_llvm_ir(irGen *ir) {
 	}
 
 	for_array(member_index, m->members.entries) {
-		MapIrValueEntry *entry = &m->members.entries.e[member_index];
+		MapIrValueEntry *entry = &m->members.entries[member_index];
 		irValue *v = entry->value;
 		if (v->kind != irValue_Global) {
 			continue;
@@ -1707,7 +1707,7 @@ void print_llvm_ir(irGen *ir) {
 		ir_fprintf(f, "!%d = !{!\"clang version 3.9.0 (branches/release_39)\"}\n", diec+3);
 
 		for_array(di_index, m->debug_info.entries) {
-			MapIrDebugInfoEntry *entry = &m->debug_info.entries.e[di_index];
+			MapIrDebugInfoEntry *entry = &m->debug_info.entries[di_index];
 			irDebugInfo *di = entry->value;
 			ir_fprintf(f, "!%d = ", di->id);
 
@@ -1752,7 +1752,7 @@ void print_llvm_ir(irGen *ir) {
 			case irDebugInfo_AllProcs:
 				ir_fprintf(f, "!{");
 				for_array(proc_index, di->AllProcs.procs) {
-					irDebugInfo *p = di->AllProcs.procs.e[proc_index];
+					irDebugInfo *p = di->AllProcs.procs[proc_index];
 					if (proc_index > 0) {ir_fprintf(f, ",");}
 					ir_fprintf(f, "!%d", p->id);
 				}

+ 2 - 2
src/main.cpp

@@ -309,7 +309,7 @@ int main(int argc, char **argv) {
 	// defer (gb_string_free(lib_str));
 	char lib_str_buf[1024] = {0};
 	for_array(i, ir_gen.module.foreign_library_paths) {
-		String lib = ir_gen.module.foreign_library_paths.e[i];
+		String lib = ir_gen.module.foreign_library_paths[i];
 		// gb_printf_err("Linking lib: %.*s\n", LIT(lib));
 		isize len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf),
 		                        " \"%.*s\"", LIT(lib));
@@ -371,7 +371,7 @@ int main(int argc, char **argv) {
 	// defer (gb_string_free(lib_str));
 	char lib_str_buf[1024] = {0};
 	for_array(i, ir_gen.module.foreign_library_paths) {
-		String lib = ir_gen.module.foreign_library_paths.e[i];
+		String lib = ir_gen.module.foreign_library_paths[i];
 
 		// NOTE(zangent): Sometimes, you have to use -framework on MacOS.
 		//   This allows you to specify '-f' in a #foreign_system_library,

+ 34 - 34
src/map.cpp

@@ -92,8 +92,8 @@ typedef struct MAP_ENTRY {
 } MAP_ENTRY;
 
 typedef struct MAP_NAME {
-	Array(isize)     hashes;
-	Array(MAP_ENTRY) entries;
+	Array<isize>     hashes;
+	Array<MAP_ENTRY> entries;
 } MAP_NAME;
 
 void      _J2(MAP_PROC,init)             (MAP_NAME *h, gbAllocator a);
@@ -124,8 +124,8 @@ gb_inline void _J2(MAP_PROC,init)(MAP_NAME *h, gbAllocator a) {
 }
 
 gb_inline void _J2(MAP_PROC,init_with_reserve)(MAP_NAME *h, gbAllocator a, isize capacity) {
-	array_init_reserve(&h->hashes,  a, capacity);
-	array_init_reserve(&h->entries, a, capacity);
+	array_init(&h->hashes,  a, capacity);
+	array_init(&h->entries, a, capacity);
 }
 
 gb_inline void _J2(MAP_PROC,destroy)(MAP_NAME *h) {
@@ -145,13 +145,13 @@ gb_internal MapFindResult _J2(MAP_PROC,_find)(MAP_NAME *h, HashKey key) {
 	MapFindResult fr = {-1, -1, -1};
 	if (h->hashes.count > 0) {
 		fr.hash_index  = key.key % h->hashes.count;
-		fr.entry_index = h->hashes.e[fr.hash_index];
+		fr.entry_index = h->hashes[fr.hash_index];
 		while (fr.entry_index >= 0) {
-			if (hash_key_equal(h->entries.e[fr.entry_index].key, key)) {
+			if (hash_key_equal(h->entries[fr.entry_index].key, key)) {
 				return fr;
 			}
 			fr.entry_prev = fr.entry_index;
-			fr.entry_index = h->entries.e[fr.entry_index].next;
+			fr.entry_index = h->entries[fr.entry_index].next;
 		}
 	}
 	return fr;
@@ -161,13 +161,13 @@ gb_internal MapFindResult _J2(MAP_PROC,_find_from_entry)(MAP_NAME *h, MAP_ENTRY
 	MapFindResult fr = {-1, -1, -1};
 	if (h->hashes.count > 0) {
 		fr.hash_index  = e->key.key % h->hashes.count;
-		fr.entry_index = h->hashes.e[fr.hash_index];
+		fr.entry_index = h->hashes[fr.hash_index];
 		while (fr.entry_index >= 0) {
-			if (&h->entries.e[fr.entry_index] == e) {
+			if (&h->entries[fr.entry_index] == e) {
 				return fr;
 			}
 			fr.entry_prev = fr.entry_index;
-			fr.entry_index = h->entries.e[fr.entry_index].next;
+			fr.entry_index = h->entries[fr.entry_index].next;
 		}
 	}
 	return fr;
@@ -190,10 +190,10 @@ void _J2(MAP_PROC,rehash)(MAP_NAME *h, isize new_count) {
 	array_resize(&nh.hashes, new_count);
 	array_reserve(&nh.entries, h->entries.count);
 	for (i = 0; i < new_count; i++) {
-		nh.hashes.e[i] = -1;
+		nh.hashes[i] = -1;
 	}
 	for (i = 0; i < h->entries.count; i++) {
-		MAP_ENTRY *e = &h->entries.e[i];
+		MAP_ENTRY *e = &h->entries[i];
 		MapFindResult fr;
 		if (nh.hashes.count == 0) {
 			_J2(MAP_PROC,grow)(&nh);
@@ -201,12 +201,12 @@ void _J2(MAP_PROC,rehash)(MAP_NAME *h, isize new_count) {
 		fr = _J2(MAP_PROC,_find)(&nh, e->key);
 		j = _J2(MAP_PROC,_add_entry)(&nh, e->key);
 		if (fr.entry_prev < 0) {
-			nh.hashes.e[fr.hash_index] = j;
+			nh.hashes[fr.hash_index] = j;
 		} else {
-			nh.entries.e[fr.entry_prev].next = j;
+			nh.entries[fr.entry_prev].next = j;
 		}
-		nh.entries.e[j].next = fr.entry_index;
-		nh.entries.e[j].value = e->value;
+		nh.entries[j].next = fr.entry_index;
+		nh.entries[j].value = e->value;
 		if (_J2(MAP_PROC,_full)(&nh)) {
 			_J2(MAP_PROC,grow)(&nh);
 		}
@@ -218,7 +218,7 @@ void _J2(MAP_PROC,rehash)(MAP_NAME *h, isize new_count) {
 gb_inline MAP_TYPE *_J2(MAP_PROC,get)(MAP_NAME *h, HashKey key) {
 	isize index = _J2(MAP_PROC,_find)(h, key).entry_index;
 	if (index >= 0) {
-		return &h->entries.e[index].value;
+		return &h->entries[index].value;
 	}
 	return NULL;
 }
@@ -234,12 +234,12 @@ void _J2(MAP_PROC,set)(MAP_NAME *h, HashKey key, MAP_TYPE value) {
 	} else {
 		index = _J2(MAP_PROC,_add_entry)(h, key);
 		if (fr.entry_prev >= 0) {
-			h->entries.e[fr.entry_prev].next = index;
+			h->entries[fr.entry_prev].next = index;
 		} else {
-			h->hashes.e[fr.hash_index] = index;
+			h->hashes[fr.hash_index] = index;
 		}
 	}
-	h->entries.e[index].value = value;
+	h->entries[index].value = value;
 
 	if (_J2(MAP_PROC,_full)(h)) {
 		_J2(MAP_PROC,grow)(h);
@@ -251,20 +251,20 @@ void _J2(MAP_PROC,set)(MAP_NAME *h, HashKey key, MAP_TYPE value) {
 void _J2(MAP_PROC,_erase)(MAP_NAME *h, MapFindResult fr) {
 	MapFindResult last;
 	if (fr.entry_prev < 0) {
-		h->hashes.e[fr.hash_index] = h->entries.e[fr.entry_index].next;
+		h->hashes[fr.hash_index] = h->entries[fr.entry_index].next;
 	} else {
-		h->entries.e[fr.entry_prev].next = h->entries.e[fr.entry_index].next;
+		h->entries[fr.entry_prev].next = h->entries[fr.entry_index].next;
 	}
 	if (fr.entry_index == h->entries.count-1) {
 		array_pop(&h->entries);
 		return;
 	}
-	h->entries.e[fr.entry_index] = h->entries.e[h->entries.count-1];
-	last = _J2(MAP_PROC,_find)(h, h->entries.e[fr.entry_index].key);
+	h->entries[fr.entry_index] = h->entries[h->entries.count-1];
+	last = _J2(MAP_PROC,_find)(h, h->entries[fr.entry_index].key);
 	if (last.entry_prev >= 0) {
-		h->entries.e[last.entry_prev].next = fr.entry_index;
+		h->entries[last.entry_prev].next = fr.entry_index;
 	} else {
-		h->hashes.e[last.hash_index] = fr.entry_index;
+		h->hashes[last.hash_index] = fr.entry_index;
 	}
 }
 
@@ -287,16 +287,16 @@ MAP_ENTRY *_J2(MAP_PROC,multi_find_first)(MAP_NAME *h, HashKey key) {
 	if (i < 0) {
 		return NULL;
 	}
-	return &h->entries.e[i];
+	return &h->entries[i];
 }
 
 MAP_ENTRY *_J2(MAP_PROC,multi_find_next)(MAP_NAME *h, MAP_ENTRY *e) {
 	isize i = e->next;
 	while (i >= 0) {
-		if (hash_key_equal(h->entries.e[i].key, e->key)) {
-			return &h->entries.e[i];
+		if (hash_key_equal(h->entries[i].key, e->key)) {
+			return &h->entries[i];
 		}
-		i = h->entries.e[i].next;
+		i = h->entries[i].next;
 	}
 	return NULL;
 }
@@ -330,12 +330,12 @@ void _J2(MAP_PROC,multi_insert)(MAP_NAME *h, HashKey key, MAP_TYPE value) {
 	fr = _J2(MAP_PROC,_find)(h, key);
 	i = _J2(MAP_PROC,_add_entry)(h, key);
 	if (fr.entry_prev < 0) {
-		h->hashes.e[fr.hash_index] = i;
+		h->hashes[fr.hash_index] = i;
 	} else {
-		h->entries.e[fr.entry_prev].next = i;
+		h->entries[fr.entry_prev].next = i;
 	}
-	h->entries.e[i].next = fr.entry_index;
-	h->entries.e[i].value = value;
+	h->entries[i].next = fr.entry_index;
+	h->entries[i].value = value;
 	// Grow if needed
 	if (_J2(MAP_PROC,_full)(h)) {
 		_J2(MAP_PROC,grow)(h);

+ 56 - 54
src/parser.cpp

@@ -15,13 +15,13 @@ typedef enum ParseFileError {
 	ParseFile_Count,
 } ParseFileError;
 
-typedef Array(AstNode *) AstNodeArray;
+typedef Array<AstNode *> AstNodeArray;
 
 typedef struct AstFile {
 	i32            id;
 	gbArena        arena;
 	Tokenizer      tokenizer;
-	Array(Token)   tokens;
+	Array<Token>   tokens;
 	isize          curr_token_index;
 	Token          curr_token;
 	Token          prev_token; // previous non-comment
@@ -54,8 +54,8 @@ typedef struct ImportedFile {
 
 typedef struct Parser {
 	String              init_fullpath;
-	Array(AstFile)      files;
-	Array(ImportedFile) imports;
+	Array<AstFile>      files;
+	Array<ImportedFile> imports;
 	gbAtomic32          import_index;
 	isize               total_token_count;
 	isize               total_line_count;
@@ -525,7 +525,7 @@ Token ast_node_token(AstNode *node) {
 	case AstNode_PushContext:   return node->PushContext.token;
 
 	case AstNode_BadDecl:        return node->BadDecl.begin;
-	case AstNode_ValueDecl:      return ast_node_token(node->ValueDecl.names.e[0]);
+	case AstNode_ValueDecl:      return ast_node_token(node->ValueDecl.names[0]);
 	case AstNode_ImportDecl:     return node->ImportDecl.token;
 	case AstNode_ForeignLibrary: return node->ForeignLibrary.token;
 	case AstNode_Label:      return node->Label.token;
@@ -533,7 +533,7 @@ Token ast_node_token(AstNode *node) {
 
 	case AstNode_Field:
 		if (node->Field.names.count > 0) {
-			return ast_node_token(node->Field.names.e[0]);
+			return ast_node_token(node->Field.names[0]);
 		}
 		return ast_node_token(node->Field.type);
 	case AstNode_FieldList:
@@ -565,7 +565,7 @@ AstNodeArray clone_ast_node_array(gbAllocator a, AstNodeArray array) {
 	if (array.count > 0) {
 		array_init_count(&result, a, array.count);
 		for_array(i, array) {
-			result.e[i] = clone_ast_node(a, array.e[i]);
+			result[i] = clone_ast_node(a, array[i]);
 		}
 	}
 	return result;
@@ -1457,7 +1457,7 @@ bool next_token(AstFile *f) {
 		}
 
 		f->curr_token_index++;
-		f->curr_token = f->tokens.e[f->curr_token_index];
+		f->curr_token = f->tokens[f->curr_token_index];
 		if (f->curr_token.kind == Token_Comment) {
 			return next_token(f);
 		}
@@ -1474,7 +1474,7 @@ TokenKind look_ahead_token_kind(AstFile *f, isize amount) {
 	isize index = f->curr_token_index;
 	while (amount > 0) {
 		index++;
-		kind = f->tokens.e[index].kind;
+		kind = f->tokens[index].kind;
 		if (kind != Token_Comment) {
 			amount--;
 		}
@@ -1647,7 +1647,7 @@ bool is_semicolon_optional_for_node(AstFile *f, AstNode *s) {
 	case AstNode_ValueDecl:
 		if (!s->ValueDecl.is_var) {
 			if (s->ValueDecl.values.count > 0) {
-				AstNode *last = s->ValueDecl.values.e[s->ValueDecl.values.count-1];
+				AstNode *last = s->ValueDecl.values[s->ValueDecl.values.count-1];
 				return is_semicolon_optional_for_node(f, last);
 			}
 		}
@@ -1961,7 +1961,7 @@ AstNode *convert_stmt_to_expr(AstFile *f, AstNode *statement, String kind) {
 	}
 
 	syntax_error(f->curr_token, "Expected `%.*s`, found a simple statement.", LIT(kind));
-	return ast_bad_expr(f, f->curr_token, f->tokens.e[f->curr_token_index+1]);
+	return ast_bad_expr(f, f->curr_token, f->tokens[f->curr_token_index+1]);
 }
 
 
@@ -1990,20 +1990,20 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
 			// NOTE(bill): Allow neighbouring string literals to be merge together to
 			// become one big string
 			String s = f->curr_token.string;
-			Array(u8) data;
-			array_init_reserve(&data, heap_allocator(), token.string.len+s.len);
-			gb_memmove(data.e, token.string.text, token.string.len);
+			Array<u8> data;
+			array_init(&data, heap_allocator(), token.string.len+s.len);
+			gb_memmove(data.data, token.string.text, token.string.len);
 			data.count += token.string.len;
 
 			while (f->curr_token.kind == Token_String) {
 				String s = f->curr_token.string;
 				isize old_count = data.count;
 				array_resize(&data, data.count + s.len);
-				gb_memmove(data.e+old_count, s.text, s.len);
+				gb_memmove(data.data+old_count, s.text, s.len);
 				next_token(f);
 			}
 
-			token.string = make_string(data.e, data.count);
+			token.string = make_string(data.data, data.count);
 			array_add(&f->tokenizer.allocated_strings, token.string);
 		}
 
@@ -2512,12 +2512,12 @@ AstNode *parse_value_decl(AstFile *f, AstNodeArray lhs) {
 		}
 	}
 
-	if (values.e == NULL) {
+	if (values.data == NULL) {
 		values = make_ast_node_array(f);
 	}
 
 	AstNodeArray specs = {};
-	array_init_reserve(&specs, heap_allocator(), 1);
+	array_init(&specs, heap_allocator(), 1);
 	return ast_value_decl(f, is_mutable, lhs, type, values);
 }
 
@@ -2566,7 +2566,7 @@ AstNode *parse_simple_stmt(AstFile *f, StmtAllowFlag flags) {
 
 			AstNodeArray rhs = {};
 			array_init_count(&rhs, heap_allocator(), 1);
-			rhs.e[0] = expr;
+			rhs[0] = expr;
 
 			return ast_assign_stmt(f, token, lhs, rhs);
 		}
@@ -2579,7 +2579,7 @@ AstNode *parse_simple_stmt(AstFile *f, StmtAllowFlag flags) {
 			case Token_for:
 			case Token_match: {
 				next_token(f);
-				AstNode *name = lhs.e[0];
+				AstNode *name = lhs[0];
 				AstNode *label = ast_label_decl(f, ast_node_token(name), name);
 				AstNode *stmt = parse_stmt(f);
 			#define _SET_LABEL(Kind_, label_) case GB_JOIN2(AstNode_, Kind_): (stmt->Kind_).label = label_; break
@@ -2612,10 +2612,10 @@ AstNode *parse_simple_stmt(AstFile *f, StmtAllowFlag flags) {
 	case Token_Inc:
 	case Token_Dec:
 		next_token(f);
-		return ast_inc_dec_stmt(f, token, lhs.e[0]);
+		return ast_inc_dec_stmt(f, token, lhs[0]);
 	}
 
-	return ast_expr_stmt(f, lhs.e[0]);
+	return ast_expr_stmt(f, lhs[0]);
 }
 
 
@@ -2786,14 +2786,12 @@ typedef struct AstNodeAndFlags {
 	u32      flags;
 } AstNodeAndFlags;
 
-typedef Array(AstNodeAndFlags) AstNodeAndFlagsArray;
-
-AstNodeArray convert_to_ident_list(AstFile *f, AstNodeAndFlagsArray list, bool ignore_flags) {
+AstNodeArray convert_to_ident_list(AstFile *f, Array<AstNodeAndFlags> list, bool ignore_flags) {
 	AstNodeArray idents = {};
-	array_init_reserve(&idents, heap_allocator(), list.count);
+	array_init(&idents, heap_allocator(), list.count);
 	// Convert to ident list
 	for_array(i, list) {
-		AstNode *ident = list.e[i].node;
+		AstNode *ident = list[i].node;
 
 		if (!ignore_flags) {
 			if (i != 0) {
@@ -2834,7 +2832,7 @@ AstNode *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, Tok
 	Token start_token = f->curr_token;
 
 	AstNodeArray params = make_ast_node_array(f);
-	AstNodeAndFlagsArray list = {}; array_init(&list, heap_allocator()); // LEAK(bill):
+	Array<AstNodeAndFlags> list = {}; array_init(&list, heap_allocator()); // LEAK(bill):
 	isize total_name_count = 0;
 	bool allow_ellipsis = allowed_flags&FieldFlag_ellipsis;
 
@@ -2858,7 +2856,7 @@ AstNode *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, Tok
 		}
 		u32 set_flags = 0;
 		if (list.count > 0) {
-			set_flags = list.e[0].flags;
+			set_flags = list[0].flags;
 		}
 		set_flags = check_field_prefixes(f, names.count, allowed_flags, set_flags);
 		total_name_count += names.count;
@@ -2897,15 +2895,15 @@ AstNode *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, Tok
 
 	for_array(i, list) {
 		AstNodeArray names = {};
-		AstNode *type = list.e[i].node;
+		AstNode *type = list[i].node;
 		Token token = blank_token;
 
 		array_init_count(&names, heap_allocator(), 1);
 		token.pos = ast_node_token(type).pos;
-		names.e[0] = ast_ident(f, token);
-		u32 flags = check_field_prefixes(f, list.count, allowed_flags, list.e[i].flags);
+		names[0] = ast_ident(f, token);
+		u32 flags = check_field_prefixes(f, list.count, allowed_flags, list[i].flags);
 
-		AstNode *param = ast_field(f, names, list.e[i].node, flags);
+		AstNode *param = ast_field(f, names, list[i].node, flags);
 		array_add(&params, param);
 	}
 
@@ -3095,7 +3093,7 @@ AstNode *parse_type_or_ident(AstFile *f) {
 					AstNode *type = parse_var_type(f, false);
 					array_add(&decls, ast_field(f, names, type, set_flags));
 				} else {
-					AstNode *name  = names.e[0];
+					AstNode *name  = names[0];
 					Token    open  = expect_token(f, Token_OpenBrace);
 					isize decl_count = 0;
 					AstNode *list  = parse_record_fields(f, &decl_count, FieldFlag_using, str_lit("union"));
@@ -3273,7 +3271,7 @@ AstNode *parse_if_stmt(AstFile *f) {
 			break;
 		default:
 			syntax_error(f->curr_token, "Expected if statement block statement");
-			else_stmt = ast_bad_stmt(f, f->curr_token, f->tokens.e[f->curr_token_index+1]);
+			else_stmt = ast_bad_stmt(f, f->curr_token, f->tokens[f->curr_token_index+1]);
 			break;
 		}
 	}
@@ -3310,7 +3308,7 @@ AstNode *parse_when_stmt(AstFile *f) {
 			break;
 		default:
 			syntax_error(f->curr_token, "Expected when statement block statement");
-			else_stmt = ast_bad_stmt(f, f->curr_token, f->tokens.e[f->curr_token_index+1]);
+			else_stmt = ast_bad_stmt(f, f->curr_token, f->tokens[f->curr_token_index+1]);
 			break;
 		}
 	}
@@ -3337,7 +3335,11 @@ AstNode *parse_return_stmt(AstFile *f) {
 		results = make_ast_node_array(f);
 	}
 
-	expect_semicolon(f, results.e[0]);
+	AstNode *end = NULL;
+	if (results.count > 0) {
+		end = results[results.count-1];
+	}
+	expect_semicolon(f, end);
 	return ast_return_stmt(f, token, results);
 }
 
@@ -3413,11 +3415,11 @@ AstNode *parse_for_stmt(AstFile *f) {
 		AstNode *index = NULL;
 		switch (cond->AssignStmt.lhs.count) {
 		case 1:
-			value = cond->AssignStmt.lhs.e[0];
+			value = cond->AssignStmt.lhs[0];
 			break;
 		case 2:
-			value = cond->AssignStmt.lhs.e[0];
-			index = cond->AssignStmt.lhs.e[1];
+			value = cond->AssignStmt.lhs[0];
+			index = cond->AssignStmt.lhs[1];
 			break;
 		default:
 			error_node(cond, "Expected at 1 or 2 identifiers");
@@ -3426,7 +3428,7 @@ AstNode *parse_for_stmt(AstFile *f) {
 
 		AstNode *rhs = NULL;
 		if (cond->AssignStmt.rhs.count > 0) {
-			rhs = cond->AssignStmt.rhs.e[0];
+			rhs = cond->AssignStmt.rhs[0];
 		}
 		return ast_range_stmt(f, token, value, index, in_token, rhs, body);
 	}
@@ -3613,7 +3615,7 @@ AstNode *parse_stmt(AstFile *f) {
 		}
 
 		if (f->curr_token.kind != Token_Colon) {
-			expect_semicolon(f, list.e[list.count-1]);
+			expect_semicolon(f, list[list.count-1]);
 			return ast_using_stmt(f, token, list);
 		}
 
@@ -3920,8 +3922,8 @@ ParseFileError init_ast_file(AstFile *f, String fullpath) {
 		}
 
 		f->curr_token_index = 0;
-		f->prev_token = f->tokens.e[f->curr_token_index];
-		f->curr_token = f->tokens.e[f->curr_token_index];
+		f->prev_token = f->tokens[f->curr_token_index];
+		f->curr_token = f->tokens[f->curr_token_index];
 
 		// NOTE(bill): Is this big enough or too small?
 		isize arena_size = gb_size_of(AstNode);
@@ -3962,7 +3964,7 @@ bool init_parser(Parser *p) {
 void destroy_parser(Parser *p) {
 	// TODO(bill): Fix memory leak
 	for_array(i, p->files) {
-		destroy_ast_file(&p->files.e[i]);
+		destroy_ast_file(&p->files[i]);
 	}
 #if 0
 	for_array(i, p->imports) {
@@ -3982,7 +3984,7 @@ bool try_add_import_path(Parser *p, String path, String rel_path, TokenPos pos)
 	rel_path = string_trim_whitespace(rel_path);
 
 	for_array(i, p->imports) {
-		String import = p->imports.e[i].path;
+		String import = p->imports[i].path;
 		if (import == path) {
 			return false;
 		}
@@ -4042,7 +4044,7 @@ bool is_import_path_valid(String path) {
 
 void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, AstNodeArray decls) {
 	for_array(i, decls) {
-		AstNode *node = decls.e[i];
+		AstNode *node = decls[i];
 		if (!is_ast_node_decl(node) &&
 		    node->kind != AstNode_BadStmt &&
 		    node->kind != AstNode_EmptyStmt) {
@@ -4072,7 +4074,7 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, AstNodeArray
 
 			if (collection_name.len == 0) {
 				syntax_error_node(node, "Missing import collection for path: `%.*s`", LIT(oirignal_string));
-				decls.e[i] = ast_bad_decl(f, id->relpath, id->relpath);
+				decls[i] = ast_bad_decl(f, id->relpath, id->relpath);
 				continue;
 			}
 
@@ -4089,7 +4091,7 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, AstNodeArray
 				}
 			} else {
 				syntax_error_node(node, "Unknown import collection: `%.*s`", LIT(collection_name));
-				decls.e[i] = ast_bad_decl(f, id->relpath, id->relpath);
+				decls[i] = ast_bad_decl(f, id->relpath, id->relpath);
 				continue;
 			}
 
@@ -4100,7 +4102,7 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, AstNodeArray
 					syntax_error_node(node, "Invalid include path: `%.*s`", LIT(file_str));
 				}
 				// NOTE(bill): It's a naughty name
-				decls.e[i] = ast_bad_decl(f, id->relpath, id->relpath);
+				decls[i] = ast_bad_decl(f, id->relpath, id->relpath);
 				continue;
 			}
 
@@ -4112,7 +4114,7 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, AstNodeArray
 					syntax_error_node(node, "Invalid include path: `%.*s`", LIT(file_str));
 				}
 				// NOTE(bill): It's a naughty name
-				decls.e[i] = ast_bad_decl(f, id->relpath, id->relpath);
+				decls[i] = ast_bad_decl(f, id->relpath, id->relpath);
 				continue;
 			}
 
@@ -4140,7 +4142,7 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, AstNodeArray
 					syntax_error_node(node, "Invalid `foreign_library` path");
 				}
 				// NOTE(bill): It's a naughty name
-				f->decls.e[i] = ast_bad_decl(f, fl->token, fl->token);
+				f->decls[i] = ast_bad_decl(f, fl->token, fl->token);
 				continue;
 			}
 
@@ -4192,7 +4194,7 @@ ParseFileError parse_files(Parser *p, char *init_filename) {
 	p->init_fullpath = init_fullpath;
 
 	for_array(i, p->imports) {
-		ImportedFile imported_file = p->imports.e[i];
+		ImportedFile imported_file = p->imports[i];
 		String import_path = imported_file.path;
 		String import_rel_path = imported_file.rel_path;
 		TokenPos pos = imported_file.pos;
@@ -4245,7 +4247,7 @@ ParseFileError parse_files(Parser *p, char *init_filename) {
 	}
 
 	for_array(i, p->files) {
-		p->total_token_count += p->files.e[i].tokens.count;
+		p->total_token_count += p->files[i].tokens.count;
 	}
 
 

+ 57 - 48
src/ssa.cpp

@@ -19,7 +19,7 @@ String ssa_mangle_name(ssaModule *m, String path, Entity *e);
 #define MAP_NAME MapSsaValue
 #include "map.cpp"
 
-typedef Array(ssaValue *) ssaValueArray;
+typedef Array<ssaValue *> ssaValueArray;
 
 #include "ssa_op.cpp"
 
@@ -30,6 +30,15 @@ struct ssaValueArgs {
 	isize       capacity;
 	ssaValue *  backing[SSA_DEFAULT_VALUE_ARG_CAPACITY];
 	gbAllocator allocator;
+
+	ssaValue *&operator[](isize i) {
+		GB_ASSERT(0 <= i && i <= count);
+		return e[i];
+	}
+	ssaValue * const &operator[](isize i) const {
+		GB_ASSERT(0 <= i && i <= count);
+		return e[i];
+	}
 };
 
 struct ssaValue {
@@ -97,7 +106,7 @@ struct ssaEdge {
 	isize     index;
 };
 
-typedef Array(ssaEdge) ssaEdgeArray;
+typedef Array<ssaEdge> ssaEdgeArray;
 
 struct ssaBlock {
 	i32                  id;   // Unique identifier but the pointer could be used too
@@ -134,7 +143,7 @@ struct ssaProc {
 	Entity *          entity;
 	DeclInfo *        decl_info;
 
-	Array(ssaBlock *) blocks;
+	Array<ssaBlock *> blocks;
 	ssaBlock *        entry;      // Entry block
 	ssaBlock *        exit;       // Exit block
 	ssaBlock *        curr_block;
@@ -145,7 +154,7 @@ struct ssaProc {
 	i32               value_id;
 	MapSsaValue       values;   // Key: Entity *
 
-	Array(ssaDefer)   defer_stmts;
+	Array<ssaDefer>   defer_stmts;
 	i32               scope_level;
 };
 
@@ -164,7 +173,7 @@ struct ssaModule {
 	MapEntity          min_dep_map; // Key: Entity *
 	MapSsaValue        values;      // Key: Entity *
 	// List of registers for the specific architecture
-	Array(ssaRegister) registers;
+	Array<ssaRegister> registers;
 
 	ssaProc *proc; // current procedure
 
@@ -172,7 +181,7 @@ struct ssaModule {
 
 	u32 stmt_state_flags;
 
-	Array(ssaProc *)  procs;
+	Array<ssaProc *>  procs;
 	ssaValueArray     procs_to_generate;
 };
 
@@ -406,7 +415,7 @@ ssaValue *ssa_emit_deep_field_ptr_index(ssaProc *p, ssaValue *e, Selection sel);
 
 void ssa_reset_value_args(ssaValue *v) {
 	for_array(i, v->args) {
-		v->args.e[i]->uses--;
+		v->args[i]->uses--;
 	}
 	v->args.count = 0;
 }
@@ -425,7 +434,7 @@ ssaValue *ssa_get_last_value(ssaBlock *b) {
 	if (len <= 0) {
 		return 0;
 	}
-	ssaValue *v = b->values.e[len-1];
+	ssaValue *v = b->values[len-1];
 	return v;
 }
 
@@ -451,7 +460,7 @@ void ssa_build_defer_stmt(ssaProc *p, ssaDefer d) {
 void ssa_emit_defer_stmts(ssaProc *p, ssaDeferExitKind kind, ssaBlock *b) {
 	isize count = p->defer_stmts.count;
 	for (isize i = count-1; i >= 0; i--) {
-		ssaDefer d = p->defer_stmts.e[i];
+		ssaDefer d = p->defer_stmts[i];
 		if (kind == ssaDeferExit_Default) {
 			gb_printf_err("scope_level %d %d\n", p->scope_level, d.scope_level);
 			if (p->scope_level == d.scope_level &&
@@ -782,7 +791,7 @@ ssaValue *ssa_emit_conv(ssaProc *p, ssaValue *v, Type *t) {
 // NOTE(bill): Returns NULL if not possible
 ssaValue *ssa_address_from_load_or_generate_local(ssaProc *p, ssaValue *v) {
 	if (v->op == ssaOp_Load) {
-		return v->args.e[0];
+		return v->args[0];
 	}
 	ssaAddr addr = ssa_add_local_generated(p, v->type);
 	ssa_new_value2(p, ssaOp_Store, addr.addr->type, addr.addr, v);
@@ -863,7 +872,7 @@ ssaValue *ssa_emit_ptr_index(ssaProc *p, ssaValue *s, i64 index) {
 ssaValue *ssa_emit_value_index(ssaProc *p, ssaValue *s, i64 index) {
 	if (s->op == ssaOp_Load) {
 		if (!can_ssa_type(s->type)) {
-			ssaValue *e = ssa_emit_ptr_index(p, s->args.e[0], index);
+			ssaValue *e = ssa_emit_ptr_index(p, s->args[0], index);
 			return ssa_emit_load(p, e);
 		}
 	}
@@ -930,7 +939,7 @@ ssaValue *ssa_emit_deep_field_ptr_index(ssaProc *p, ssaValue *e, Selection sel)
 	Type *type = type_deref(e->type);
 
 	for_array(i, sel.index) {
-		i32 index = cast(i32)sel.index.e[i];
+		i32 index = cast(i32)sel.index[i];
 		if (is_type_pointer(type)) {
 			type = type_deref(type);
 			e = ssa_emit_load(p, e);
@@ -994,14 +1003,14 @@ ssaValue *ssa_emit_deep_field_value_index(ssaProc *p, ssaValue *e, Selection sel
 	Type *type = e->type;
 	if (e->op == ssaOp_Load) {
 		if (!can_ssa_type(e->type)) {
-			ssaValue *ptr = ssa_emit_deep_field_ptr_index(p, e->args.e[0], sel);
+			ssaValue *ptr = ssa_emit_deep_field_ptr_index(p, e->args[0], sel);
 			return ssa_emit_load(p, ptr);
 		}
 	}
 	GB_ASSERT(can_ssa_type(e->type));
 
 	for_array(i, sel.index) {
-		i32 index = cast(i32)sel.index.e[i];
+		i32 index = cast(i32)sel.index[i];
 		if (is_type_pointer(type)) {
 			e = ssa_emit_load(p, e);
 		}
@@ -1837,7 +1846,7 @@ ssaValue *ssa_build_expr(ssaProc *p, AstNode *expr) {
 	case_ast_node(ce, CallExpr, expr);
 		if (map_tav_get(&p->module->info->types, hash_pointer(ce->proc))->mode == Addressing_Type) {
 			GB_ASSERT(ce->args.count == 1);
-			ssaValue *x = ssa_build_expr(p, ce->args.e[0]);
+			ssaValue *x = ssa_build_expr(p, ce->args[0]);
 			return ssa_emit_conv(p, x, tv.type);
 		}
 
@@ -1863,7 +1872,7 @@ ssaValue *ssa_build_expr(ssaProc *p, AstNode *expr) {
 
 void ssa_build_stmt_list(ssaProc *p, AstNodeArray nodes) {
 	for_array(i, nodes) {
-		ssa_build_stmt(p, nodes.e[i]);
+		ssa_build_stmt(p, nodes[i]);
 	}
 }
 
@@ -1946,7 +1955,7 @@ void ssa_build_stmt_internal(ssaProc *p, AstNode *node) {
 
 	case_ast_node(us, UsingStmt, node);
 		for_array(i, us->list) {
-			AstNode *decl = unparen_expr(us->list.e[i]);
+			AstNode *decl = unparen_expr(us->list[i]);
 			if (decl->kind == AstNode_ValueDecl) {
 				ssa_build_stmt(p, decl);
 			}
@@ -1973,19 +1982,19 @@ void ssa_build_stmt_internal(ssaProc *p, AstNode *node) {
 			gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&m->tmp_arena);
 			if (vd->values.count == 0) {
 				for_array(i, vd->names) {
-					AstNode *name = vd->names.e[i];
+					AstNode *name = vd->names[i];
 					if (!ssa_is_blank_ident(name)) {
 						ssa_add_local_for_ident(p, name);
 					}
 				}
 			} else {
-				Array(ssaAddr) lvals = {0};
+				Array<ssaAddr> lvals = {0};
 				ssaValueArray  inits = {0};
-				array_init_reserve(&lvals, m->tmp_allocator, vd->names.count);
-				array_init_reserve(&inits, m->tmp_allocator, vd->names.count);
+				array_init(&lvals, m->tmp_allocator, vd->names.count);
+				array_init(&inits, m->tmp_allocator, vd->names.count);
 
 				for_array(i, vd->names) {
-					AstNode *name = vd->names.e[i];
+					AstNode *name = vd->names[i];
 					ssaAddr lval = ssa_addr(NULL);
 					if (!ssa_is_blank_ident(name)) {
 						lval = ssa_add_local_for_ident(p, name);
@@ -1995,7 +2004,7 @@ void ssa_build_stmt_internal(ssaProc *p, AstNode *node) {
 				}
 
 				for_array(i, vd->values) {
-					ssaValue *init = ssa_build_expr(p, vd->values.e[i]);
+					ssaValue *init = ssa_build_expr(p, vd->values[i]);
 					if (init == NULL) { // TODO(bill): remove this
 						continue;
 					}
@@ -2012,7 +2021,7 @@ void ssa_build_stmt_internal(ssaProc *p, AstNode *node) {
 				}
 
 				for_array(i, inits) {
-					ssa_addr_store(p, lvals.e[i], inits.e[i]);
+					ssa_addr_store(p, lvals[i], inits[i]);
 				}
 			}
 
@@ -2030,11 +2039,11 @@ void ssa_build_stmt_internal(ssaProc *p, AstNode *node) {
 
 		switch (as->op.kind) {
 		case Token_Eq: {
-			Array(ssaAddr) lvals = {0};
+			Array<ssaAddr> lvals = {0};
 			array_init(&lvals, m->tmp_allocator);
 
 			for_array(i, as->lhs) {
-				AstNode *lhs = as->lhs.e[i];
+				AstNode *lhs = as->lhs[i];
 				ssaAddr lval = {0};
 				if (!ssa_is_blank_ident(lhs)) {
 					lval = ssa_build_addr(p, lhs);
@@ -2044,28 +2053,28 @@ void ssa_build_stmt_internal(ssaProc *p, AstNode *node) {
 
 			if (as->lhs.count == as->rhs.count) {
 				if (as->lhs.count == 1) {
-					AstNode *rhs = as->rhs.e[0];
+					AstNode *rhs = as->rhs[0];
 					ssaValue *init = ssa_build_expr(p, rhs);
-					ssa_addr_store(p, lvals.e[0], init);
+					ssa_addr_store(p, lvals[0], init);
 				} else {
 					ssaValueArray inits;
-					array_init_reserve(&inits, m->tmp_allocator, lvals.count);
+					array_init(&inits, m->tmp_allocator, lvals.count);
 
 					for_array(i, as->rhs) {
-						ssaValue *init = ssa_build_expr(p, as->rhs.e[i]);
+						ssaValue *init = ssa_build_expr(p, as->rhs[i]);
 						array_add(&inits, init);
 					}
 
 					for_array(i, inits) {
-						ssa_addr_store(p, lvals.e[i], inits.e[i]);
+						ssa_addr_store(p, lvals[i], inits[i]);
 					}
 				}
 			} else {
 				ssaValueArray inits;
-				array_init_reserve(&inits, m->tmp_allocator, lvals.count);
+				array_init(&inits, m->tmp_allocator, lvals.count);
 
 				for_array(i, as->rhs) {
-					ssaValue *init = ssa_build_expr(p, as->rhs.e[i]);
+					ssaValue *init = ssa_build_expr(p, as->rhs[i]);
 					Type *t = base_type(init->type);
 					// TODO(bill): refactor for code reuse as this is repeated a bit
 					if (t->kind == Type_Tuple) {
@@ -2080,7 +2089,7 @@ void ssa_build_stmt_internal(ssaProc *p, AstNode *node) {
 				}
 
 				for_array(i, inits) {
-					ssa_addr_store(p, lvals.e[i], inits.e[i]);
+					ssa_addr_store(p, lvals[i], inits[i]);
 				}
 			}
 		} break;
@@ -2091,8 +2100,8 @@ void ssa_build_stmt_internal(ssaProc *p, AstNode *node) {
 			// +=, -=, etc
 			i32 op = cast(i32)as->op.kind;
 			op += Token_Add - Token_AddEq; // Convert += to +
-			ssaAddr lhs = ssa_build_addr(p, as->lhs.e[0]);
-			ssaValue *value = ssa_build_expr(p, as->rhs.e[0]);
+			ssaAddr lhs = ssa_build_addr(p, as->lhs[0]);
+			ssaValue *value = ssa_build_expr(p, as->rhs[0]);
 			ssa_build_assign_op(p, lhs, value, cast(TokenKind)op);
 		} break;
 		}
@@ -2316,7 +2325,7 @@ void ssa_print_reg_value(gbFile *f, ssaValue *v) {
 
 	for_array(i, v->args) {
 		gb_fprintf(f, " ");
-		ssa_print_value(f, v->args.e[i]);
+		ssa_print_value(f, v->args[i]);
 	}
 
 	if (v->comment_string.len > 0) {
@@ -2335,12 +2344,12 @@ void ssa_print_proc(gbFile *f, ssaProc *p) {
 	bool *printed = gb_alloc_array(heap_allocator(), bool, p->value_id+1);
 
 	for_array(i, p->blocks) {
-		ssaBlock *b = p->blocks.e[i];
+		ssaBlock *b = p->blocks[i];
 		gb_fprintf(f, "  b%d:", b->id);
 		if (b->preds.count > 0) {
 			gb_fprintf(f, " <-");
 			for_array(j, b->preds) {
-				ssaBlock *pred = b->preds.e[j].block;
+				ssaBlock *pred = b->preds[j].block;
 				gb_fprintf(f, " b%d", pred->id);
 			}
 		}
@@ -2351,7 +2360,7 @@ void ssa_print_proc(gbFile *f, ssaProc *p) {
 
 		isize n = 0;
 		for_array(j, b->values) {
-			ssaValue *v = b->values.e[j];
+			ssaValue *v = b->values[j];
 			if (v->op != ssaOp_Phi) {
 				continue;
 			}
@@ -2363,13 +2372,13 @@ void ssa_print_proc(gbFile *f, ssaProc *p) {
 		while (n < b->values.count) {
 			isize m = 0;
 			for_array(j, b->values) {
-				ssaValue *v = b->values.e[j];
+				ssaValue *v = b->values[j];
 				if (printed[v->id]) {
 					continue;
 				}
 				bool skip = false;
 				for_array(k, v->args) {
-					ssaValue *w = v->args.e[k];
+					ssaValue *w = v->args[k];
 					if (w != NULL && w->block == b && !printed[w->id]) {
 						skip = true;
 						break;
@@ -2387,7 +2396,7 @@ void ssa_print_proc(gbFile *f, ssaProc *p) {
 			if (m == n) {
 				gb_fprintf(f, "!!!!DepCycle!!!!\n");
 				for_array(k, b->values) {
-					ssaValue *v = b->values.e[k];
+					ssaValue *v = b->values[k];
 					if (printed[v->id]) {
 						continue;
 					}
@@ -2401,14 +2410,14 @@ void ssa_print_proc(gbFile *f, ssaProc *p) {
 
 		if (b->kind == ssaBlock_Plain) {
 			GB_ASSERT(b->succs.count == 1);
-			ssaBlock *next = b->succs.e[0].block;
+			ssaBlock *next = b->succs[0].block;
 			gb_fprintf(f, "    ");
 			gb_fprintf(f, "jump b%d", next->id);
 			gb_fprintf(f, "\n");
 		} else if (b->kind == ssaBlock_If) {
 			GB_ASSERT(b->succs.count == 2);
-			ssaBlock *yes = b->succs.e[0].block;
-			ssaBlock *no = b->succs.e[1].block;
+			ssaBlock *yes = b->succs[0].block;
+			ssaBlock *no = b->succs[1].block;
 			gb_fprintf(f, "    ");
 			gb_fprintf(f, "branch v%d, b%d, b%d", b->control->id, yes->id, no->id);
 			gb_fprintf(f, "\n");
@@ -2491,7 +2500,7 @@ bool ssa_generate(Parser *parser, CheckerInfo *info) {
 	bool has_win_main = false;
 
 	for_array(i, info->entities.entries) {
-		MapDeclInfoEntry *entry = &info->entities.entries.e[i];
+		MapDeclInfoEntry *entry = &info->entities.entries[i];
 		Entity *e = cast(Entity *)cast(uintptr)entry->key.key;
 		String name = e->token.string;
 		if (e->kind == Entity_Variable) {
@@ -2517,7 +2526,7 @@ bool ssa_generate(Parser *parser, CheckerInfo *info) {
 	m.min_dep_map = generate_minimum_dependency_map(info, entry_point);
 
 	for_array(i, info->entities.entries) {
-		MapDeclInfoEntry *entry = &info->entities.entries.e[i];
+		MapDeclInfoEntry *entry = &info->entities.entries[i];
 		Entity *e = cast(Entity *)entry->key.ptr;
 		String name = e->token.string;
 		DeclInfo *decl = entry->value;

+ 5 - 5
src/timings.cpp

@@ -6,7 +6,7 @@ typedef struct TimeStamp {
 
 typedef struct Timings {
 	TimeStamp        total;
-	Array(TimeStamp) sections;
+	Array<TimeStamp> sections;
 	u64              freq;
 } Timings;
 
@@ -83,7 +83,7 @@ TimeStamp make_time_stamp(String label) {
 }
 
 void timings_init(Timings *t, String label, isize buffer_size) {
-	array_init_reserve(&t->sections, heap_allocator(), buffer_size);
+	array_init(&t->sections, heap_allocator(), buffer_size);
 	t->total = make_time_stamp(label);
 	t->freq  = time_stamp__freq();
 }
@@ -94,7 +94,7 @@ void timings_destroy(Timings *t) {
 
 void timings__stop_current_section(Timings *t) {
 	if (t->sections.count > 0) {
-		t->sections.e[t->sections.count-1].finish = time_stamp_time_now();
+		t->sections[t->sections.count-1].finish = time_stamp_time_now();
 	}
 }
 
@@ -117,7 +117,7 @@ void timings_print_all(Timings *t) {
 
 	max_len = t->total.label.len;
 	for_array(i, t->sections) {
-		TimeStamp ts = t->sections.e[i];
+		TimeStamp ts = t->sections[i];
 		max_len = gb_max(max_len, ts.label.len);
 	}
 
@@ -129,7 +129,7 @@ void timings_print_all(Timings *t) {
 	          time_stamp_as_ms(t->total, t->freq));
 
 	for_array(i, t->sections) {
-		TimeStamp ts = t->sections.e[i];
+		TimeStamp ts = t->sections[i];
 		gb_printf("%.*s%.*s - %.3f ms\n",
 		          LIT(ts.label),
 	              cast(int)(max_len-ts.label.len), SPACES,

+ 2 - 2
src/tokenizer.cpp

@@ -338,7 +338,7 @@ typedef struct Tokenizer {
 	isize line_count;
 
 	isize error_count;
-	Array(String) allocated_strings;
+	Array<String> allocated_strings;
 } Tokenizer;
 
 
@@ -460,7 +460,7 @@ gb_inline void destroy_tokenizer(Tokenizer *t) {
 		gb_free(heap_allocator(), t->start);
 	}
 	for_array(i, t->allocated_strings) {
-		gb_free(heap_allocator(), t->allocated_strings.e[i].text);
+		gb_free(heap_allocator(), t->allocated_strings[i].text);
 	}
 	array_free(&t->allocated_strings);
 }

+ 17 - 17
src/types.cpp

@@ -197,13 +197,13 @@ typedef struct Type {
 // TODO(bill): Should I add extra information here specifying the kind of selection?
 // e.g. field, constant, vector field, type field, etc.
 typedef struct Selection {
-	Entity *  entity;
-	Array_i32 index;
-	bool      indirect; // Set if there was a pointer deref anywhere down the line
+	Entity *   entity;
+	Array<i32> index;
+	bool       indirect; // Set if there was a pointer deref anywhere down the line
 } Selection;
 Selection empty_selection = {0};
 
-Selection make_selection(Entity *entity, Array_i32 index, bool indirect) {
+Selection make_selection(Entity *entity, Array<i32> index, bool indirect) {
 	Selection s = {entity, index, indirect};
 	return s;
 }
@@ -212,10 +212,10 @@ void selection_add_index(Selection *s, isize index) {
 	// IMPORTANT NOTE(bill): this requires a stretchy buffer/dynamic array so it requires some form
 	// of heap allocation
 	// TODO(bill): Find a way to use a backing buffer for initial use as the general case is probably .count<3
-	if (s->index.e == NULL) {
+	if (s->index.data == NULL) {
 		array_init(&s->index, heap_allocator());
 	}
-	array_add(&s->index, index);
+	array_add(&s->index, cast(i32)index);
 }
 
 
@@ -1297,9 +1297,9 @@ Selection lookup_field_from_index(gbAllocator a, Type *type, i64 index) {
 			Entity *f = type->Record.fields[i];
 			if (f->kind == Entity_Variable) {
 				if (f->Variable.field_src_index == index) {
-					Array_i32 sel_array = {0};
+					Array<i32> sel_array = {0};
 					array_init_count(&sel_array, a, 1);
-					sel_array.e[0] = i;
+					sel_array[0] = i;
 					return make_selection(f, sel_array, false);
 				}
 			}
@@ -1309,18 +1309,18 @@ Selection lookup_field_from_index(gbAllocator a, Type *type, i64 index) {
 		for (isize i = 0; i < max_count; i++) {
 			Entity *f = type->Tuple.variables[i];
 			if (i == index) {
-				Array_i32 sel_array = {0};
+				Array<i32> sel_array = {0};
 				array_init_count(&sel_array, a, 1);
-				sel_array.e[0] = i;
+				sel_array[0] = i;
 				return make_selection(f, sel_array, false);
 			}
 		}
 		break;
 
 	case Type_BitField: {
-		Array_i32 sel_array = {0};
+		Array<i32> sel_array = {0};
 		array_init_count(&sel_array, a, 1);
-		sel_array.e[0] = cast(i32)index;
+		sel_array[0] = cast(i32)index;
 		return make_selection(type->BitField.fields[index], sel_array, false);
 	} break;
 
@@ -1509,7 +1509,7 @@ Selection lookup_field_with_selection(gbAllocator a, Type *type_, String field_n
 
 
 typedef struct TypePath {
-	Array(Type *) path; // Entity_TypeName;
+	Array<Type *> path; // Entity_TypeName;
 	bool failure;
 } TypePath;
 
@@ -1526,7 +1526,7 @@ void type_path_print_illegal_cycle(TypePath *tp, isize start_index) {
 	GB_ASSERT(tp != NULL);
 
 	GB_ASSERT(start_index < tp->path.count);
-	Type *t = tp->path.e[start_index];
+	Type *t = tp->path[start_index];
 	GB_ASSERT(t != NULL);
 
 	GB_ASSERT_MSG(is_type_named(t), "%s", type_to_string(t));
@@ -1534,7 +1534,7 @@ void type_path_print_illegal_cycle(TypePath *tp, isize start_index) {
 	error(e->token, "Illegal declaration cycle of `%.*s`", LIT(t->Named.name));
 	// NOTE(bill): Print cycle, if it's deep enough
 	for (isize j = start_index; j < tp->path.count; j++) {
-		Type *t = tp->path.e[j];
+		Type *t = tp->path[j];
 		GB_ASSERT_MSG(is_type_named(t), "%s", type_to_string(t));
 		Entity *e = t->Named.type_name;
 		error(e->token, "\t%.*s refers to", LIT(t->Named.name));
@@ -1549,7 +1549,7 @@ TypePath *type_path_push(TypePath *tp, Type *t) {
 	GB_ASSERT(tp != NULL);
 
 	for (isize i = 0; i < tp->path.count; i++) {
-		if (tp->path.e[i] == t) {
+		if (tp->path[i] == t) {
 			type_path_print_illegal_cycle(tp, i);
 		}
 	}
@@ -2082,7 +2082,7 @@ i64 type_offset_of_from_selection(gbAllocator allocator, Type *type, Selection s
 	Type *t = type;
 	i64 offset = 0;
 	for_array(i, sel.index) {
-		isize index = sel.index.e[i];
+		isize index = sel.index[i];
 		t = base_type(t);
 		offset += type_offset_of(allocator, t, index);
 		if (t->kind == Type_Record && t->Record.kind == TypeRecord_Struct) {

Some files were not shown because too many files changed in this diff