mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 20:00:09 +00:00
map immutable fields: count, capacity, allocator
This commit is contained in:
+35
-1
@@ -1073,6 +1073,10 @@ gb_global Entity *entity__dynamic_array_count = NULL;
|
||||
gb_global Entity *entity__dynamic_array_capacity = NULL;
|
||||
gb_global Entity *entity__dynamic_array_allocator = NULL;
|
||||
|
||||
gb_global Entity *entity__dynamic_map_count = NULL;
|
||||
gb_global Entity *entity__dynamic_map_capacity = NULL;
|
||||
gb_global Entity *entity__dynamic_map_allocator = NULL;
|
||||
|
||||
Selection lookup_field_with_selection(gbAllocator a, Type *type_, String field_name, bool is_type, Selection sel);
|
||||
|
||||
Selection lookup_field(gbAllocator a, Type *type_, String field_name, bool is_type) {
|
||||
@@ -1240,7 +1244,7 @@ Selection lookup_field_with_selection(gbAllocator a, Type *type_, String field_n
|
||||
sel.entity = entity__slice_count;
|
||||
return sel;
|
||||
}
|
||||
} else if (type->kind == Type_DynamicArray) {
|
||||
} else if (type->kind == Type_DynamicArray) {
|
||||
String data_str = str_lit("data");
|
||||
String count_str = str_lit("count");
|
||||
String capacity_str = str_lit("capacity");
|
||||
@@ -1273,6 +1277,36 @@ Selection lookup_field_with_selection(gbAllocator a, Type *type_, String field_n
|
||||
sel.entity = entity__dynamic_array_allocator;
|
||||
return sel;
|
||||
}
|
||||
} else if (type->kind == Type_Map) {
|
||||
String count_str = str_lit("count");
|
||||
String capacity_str = str_lit("capacity");
|
||||
String allocator_str = str_lit("allocator");
|
||||
|
||||
if (str_eq(field_name, count_str)) {
|
||||
selection_add_index(&sel, 0);
|
||||
if (entity__dynamic_map_count == NULL) {
|
||||
entity__dynamic_map_count = make_entity_field(a, NULL, make_token_ident(count_str), t_int, false, 0);
|
||||
entity__dynamic_map_count->Variable.is_immutable = true;
|
||||
}
|
||||
sel.entity = entity__dynamic_map_count;
|
||||
return sel;
|
||||
} else if (str_eq(field_name, capacity_str)) {
|
||||
selection_add_index(&sel, 1);
|
||||
if (entity__dynamic_map_capacity == NULL) {
|
||||
entity__dynamic_map_capacity = make_entity_field(a, NULL, make_token_ident(capacity_str), t_int, false, 1);
|
||||
entity__dynamic_map_capacity->Variable.is_immutable = true;
|
||||
}
|
||||
sel.entity = entity__dynamic_map_capacity;
|
||||
return sel;
|
||||
} else if (str_eq(field_name, allocator_str)) {
|
||||
selection_add_index(&sel, 2);
|
||||
if (entity__dynamic_map_allocator == NULL) {
|
||||
entity__dynamic_map_allocator = make_entity_field(a, NULL, make_token_ident(allocator_str), t_allocator, false, 2);
|
||||
entity__dynamic_map_allocator->Variable.is_immutable = true;
|
||||
}
|
||||
sel.entity = entity__dynamic_map_allocator;
|
||||
return sel;
|
||||
}
|
||||
}
|
||||
|
||||
if (type->kind != Type_Record) {
|
||||
|
||||
Reference in New Issue
Block a user