switch on typeid with type cases

This commit is contained in:
gingerBill
2018-10-13 11:07:56 +01:00
parent 0971a59493
commit 73e9dbbf8c
4 changed files with 44 additions and 27 deletions
+2 -4
View File
@@ -239,8 +239,7 @@ write_type :: proc(buf: ^String_Buffer, ti: ^runtime.Type_Info) {
case runtime.Type_Info_Named:
write_string(buf, info.name);
case runtime.Type_Info_Integer:
a := any{id = ti.id};
switch in a {
switch ti.id {
case int: write_string(buf, "int");
case uint: write_string(buf, "uint");
case uintptr: write_string(buf, "uintptr");
@@ -263,8 +262,7 @@ write_type :: proc(buf: ^String_Buffer, ti: ^runtime.Type_Info) {
write_string(buf, "string");
}
case runtime.Type_Info_Boolean:
a := any{id = ti.id};
switch in a {
switch ti.id {
case bool: write_string(buf, "bool");
case:
write_byte(buf, 'b');
+2 -4
View File
@@ -63,8 +63,7 @@ print_type :: proc(fd: os.Handle, ti: ^Type_Info) {
case Type_Info_Named:
os.write_string(fd, info.name);
case Type_Info_Integer:
a := any{id = ti.id};
switch _ in a {
switch ti.id {
case int: os.write_string(fd, "int");
case uint: os.write_string(fd, "uint");
case uintptr: os.write_string(fd, "uintptr");
@@ -83,8 +82,7 @@ print_type :: proc(fd: os.Handle, ti: ^Type_Info) {
case Type_Info_String:
os.write_string(fd, "string");
case Type_Info_Boolean:
a := any{id = ti.id};
switch _ in a {
switch ti.id {
case bool: os.write_string(fd, "bool");
case:
os.write_byte(fd, 'b');