Enumerated arrays [Enum_Type]Elem_Type

This commit is contained in:
gingerBill
2019-12-27 12:51:02 +00:00
parent eea403d0ab
commit 10f0961184
11 changed files with 864 additions and 146 deletions
+2
View File
@@ -20,6 +20,7 @@ Type_Kind :: enum {
Pointer,
Procedure,
Array,
Enumerated_Array,
Dynamic_Array,
Slice,
Tuple,
@@ -51,6 +52,7 @@ type_kind :: proc(T: typeid) -> Type_Kind {
case runtime.Type_Info_Pointer: return .Pointer;
case runtime.Type_Info_Procedure: return .Procedure;
case runtime.Type_Info_Array: return .Array;
case runtime.Type_Info_Enumerated_Array: return .Enumerated_Array;
case runtime.Type_Info_Dynamic_Array: return .Dynamic_Array;
case runtime.Type_Info_Slice: return .Slice;
case runtime.Type_Info_Tuple: return .Tuple;
+14
View File
@@ -82,6 +82,13 @@ are_types_identical :: proc(a, b: ^rt.Type_Info) -> bool {
if x.count != y.count do return false;
return are_types_identical(x.elem, y.elem);
case rt.Type_Info_Enumerated_Array:
y, ok := b.variant.(rt.Type_Info_Enumerated_Array);
if !ok do return false;
if x.count != y.count do return false;
return are_types_identical(x.index, y.index) &&
are_types_identical(x.elem, y.elem);
case rt.Type_Info_Dynamic_Array:
y, ok := b.variant.(rt.Type_Info_Dynamic_Array);
if !ok do return false;
@@ -397,6 +404,13 @@ write_type :: proc(buf: ^strings.Builder, ti: ^rt.Type_Info) {
write_i64(buf, i64(info.count), 10);
write_string(buf, "]");
write_type(buf, info.elem);
case rt.Type_Info_Enumerated_Array:
write_string(buf, "[");
write_type(buf, info.index);
write_string(buf, "]");
write_type(buf, info.elem);
case rt.Type_Info_Dynamic_Array:
write_string(buf, "[dynamic]");
write_type(buf, info.elem);