Begin work on matrix type

This commit is contained in:
gingerBill
2021-10-18 16:52:19 +01:00
parent 7aac8df2f2
commit 4c655865e5
14 changed files with 367 additions and 9 deletions
+2
View File
@@ -1953,6 +1953,8 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
}
}
case runtime.Type_Info_Matrix:
io.write_string(fi.writer, "[]")
}
}
+5 -1
View File
@@ -33,6 +33,7 @@ Type_Info_Bit_Set :: runtime.Type_Info_Bit_Set
Type_Info_Simd_Vector :: runtime.Type_Info_Simd_Vector
Type_Info_Relative_Pointer :: runtime.Type_Info_Relative_Pointer
Type_Info_Relative_Slice :: runtime.Type_Info_Relative_Slice
Type_Info_Matrix :: runtime.Type_Info_Matrix
Type_Info_Enum_Value :: runtime.Type_Info_Enum_Value
@@ -66,6 +67,7 @@ Type_Kind :: enum {
Simd_Vector,
Relative_Pointer,
Relative_Slice,
Matrix,
}
@@ -99,6 +101,7 @@ type_kind :: proc(T: typeid) -> Type_Kind {
case Type_Info_Simd_Vector: return .Simd_Vector
case Type_Info_Relative_Pointer: return .Relative_Pointer
case Type_Info_Relative_Slice: return .Relative_Slice
case Type_Info_Matrix: return .Matrix
}
}
@@ -1401,7 +1404,8 @@ equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_
Type_Info_Bit_Set,
Type_Info_Enum,
Type_Info_Simd_Vector,
Type_Info_Relative_Pointer:
Type_Info_Relative_Pointer,
Type_Info_Matrix:
return mem.compare_byte_ptrs((^byte)(a.data), (^byte)(b.data), t.size) == 0
case Type_Info_String:
+14
View File
@@ -164,6 +164,12 @@ are_types_identical :: proc(a, b: ^Type_Info) -> bool {
case Type_Info_Relative_Slice:
y := b.variant.(Type_Info_Relative_Slice) or_return
return x.base_integer == y.base_integer && x.slice == y.slice
case Type_Info_Matrix:
y := b.variant.(Type_Info_Matrix) or_return
if x.row_count != y.row_count { return false }
if x.column_count != y.column_count { return false }
return are_types_identical(x.elem, y.elem)
}
return false
@@ -584,6 +590,14 @@ write_type_writer :: proc(w: io.Writer, ti: ^Type_Info, n_written: ^int = nil) -
write_type(w, info.base_integer, &n) or_return
io.write_string(w, ") ", &n) or_return
write_type(w, info.slice, &n) or_return
case Type_Info_Matrix:
io.write_string(w, "[", &n) or_return
io.write_i64(w, i64(info.row_count), 10, &n) or_return
io.write_string(w, "; ", &n) or_return
io.write_i64(w, i64(info.column_count), 10, &n) or_return
io.write_string(w, "]", &n) or_return
write_type(w, info.elem, &n) or_return
}
return
+9
View File
@@ -162,6 +162,13 @@ Type_Info_Relative_Slice :: struct {
slice: ^Type_Info,
base_integer: ^Type_Info,
}
Type_Info_Matrix :: struct {
elem: ^Type_Info,
elem_size: int,
stride: int, // bytes
row_count: int,
column_count: int,
}
Type_Info_Flag :: enum u8 {
Comparable = 0,
@@ -202,6 +209,7 @@ Type_Info :: struct {
Type_Info_Simd_Vector,
Type_Info_Relative_Pointer,
Type_Info_Relative_Slice,
Type_Info_Matrix,
},
}
@@ -233,6 +241,7 @@ Typeid_Kind :: enum u8 {
Simd_Vector,
Relative_Pointer,
Relative_Slice,
Matrix,
}
#assert(len(Typeid_Kind) < 32)
+8
View File
@@ -370,5 +370,13 @@ print_type :: proc "contextless" (ti: ^Type_Info) {
print_type(info.base_integer)
print_string(") ")
print_type(info.slice)
case Type_Info_Matrix:
print_string("[")
print_u64(u64(info.row_count))
print_string("; ")
print_u64(u64(info.column_count))
print_string("]")
print_type(info.elem)
}
}