Remove bit_field in type info, runtime, and general core library

This commit is contained in:
gingerBill
2021-02-19 11:36:23 +00:00
parent efdee0dafb
commit 595885d3db
9 changed files with 0 additions and 142 deletions

View File

@@ -258,34 +258,6 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
case Type_Info_Enum:
return marshal_arg(b, any{v.data, info.base.id});
case Type_Info_Bit_Field:
data: u64 = 0;
switch ti.size {
case 1: data = cast(u64) (^u8)(v.data)^;
case 2: data = cast(u64)(^u16)(v.data)^;
case 4: data = cast(u64)(^u32)(v.data)^;
case 8: data = cast(u64)(^u64)(v.data)^;
}
write_byte(b, '{');
for name, i in info.names {
if i > 0 { write_string(b, ", "); }
bits := u64(info.bits[i]);
offset := u64(info.offsets[i]);
marshal_arg(b, name);
write_string(b, ": ");
n := 8*u64(size_of(u64));
sa := n - bits;
u := data>>offset;
u <<= sa;
u >>= sa;
write_u64(b, u, 10);
}
write_byte(b, '}');
case Type_Info_Bit_Set:
is_bit_set_different_endian_to_platform :: proc(ti: ^runtime.Type_Info) -> bool {
if ti == nil {

View File

@@ -1210,50 +1210,6 @@ fmt_bit_set :: proc(fi: ^Info, v: any, name: string = "") {
}
}
}
fmt_bit_field :: proc(fi: ^Info, v: any, bit_field_name: string = "") {
type_info := type_info_of(v.id);
#partial switch info in type_info.variant {
case runtime.Type_Info_Named:
val := v;
val.id = info.base.id;
fmt_bit_field(fi, val, info.name);
case runtime.Type_Info_Bit_Field:
data: u64 = 0;
switch type_info.size {
case 1: data = cast(u64) (^u8)(v.data)^;
case 2: data = cast(u64)(^u16)(v.data)^;
case 4: data = cast(u64)(^u32)(v.data)^;
case 8: data = cast(u64)(^u64)(v.data)^;
}
if bit_field_name != "" {
io.write_string(fi.writer, bit_field_name);
io.write_byte(fi.writer, '{');
} else {
io.write_string(fi.writer, "bit_field{");
}
for name, i in info.names {
if i > 0 {
io.write_string(fi.writer, ", ");
}
bits := u64(info.bits[i]);
offset := u64(info.offsets[i]);
io.write_string(fi.writer, name);
io.write_string(fi.writer, " = ");
n := 8*u64(size_of(u64));
sa := n - bits;
u := data>>offset;
u <<= sa;
u >>= sa;
io.write_u64(fi.writer, u, 10);
}
io.write_byte(fi.writer, '}');
}
}
fmt_write_indent :: proc(fi: ^Info) {
for in 0..<fi.indent {
@@ -1597,8 +1553,6 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
case runtime.Type_Info_Bit_Set:
fmt_bit_set(fi, v);
case runtime.Type_Info_Bit_Field:
fmt_bit_field(fi, v);
case runtime.Type_Info_Opaque:
fmt_opaque(fi, v);
case:
@@ -1967,9 +1921,6 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
id := (^typeid)(v.data)^;
reflect.write_typeid(fi.writer, id);
case runtime.Type_Info_Bit_Field:
fmt_bit_field(fi, v);
case runtime.Type_Info_Bit_Set:
fmt_bit_set(fi, v);

View File

@@ -131,8 +131,6 @@ type_is_struct :: proc($T: typeid) -> bool ---
type_is_union :: proc($T: typeid) -> bool ---
type_is_enum :: proc($T: typeid) -> bool ---
type_is_proc :: proc($T: typeid) -> bool ---
type_is_bit_field :: proc($T: typeid) -> bool ---
type_is_bit_field_value :: proc($T: typeid) -> bool ---
type_is_bit_set :: proc($T: typeid) -> bool ---
type_is_simd_vector :: proc($T: typeid) -> bool ---

View File

@@ -28,7 +28,6 @@ Type_Info_Struct :: runtime.Type_Info_Struct;
Type_Info_Union :: runtime.Type_Info_Union;
Type_Info_Enum :: runtime.Type_Info_Enum;
Type_Info_Map :: runtime.Type_Info_Map;
Type_Info_Bit_Field :: runtime.Type_Info_Bit_Field;
Type_Info_Bit_Set :: runtime.Type_Info_Bit_Set;
Type_Info_Opaque :: runtime.Type_Info_Opaque;
Type_Info_Simd_Vector :: runtime.Type_Info_Simd_Vector;
@@ -60,7 +59,6 @@ Type_Kind :: enum {
Union,
Enum,
Map,
Bit_Field,
Bit_Set,
Opaque,
Simd_Vector,
@@ -94,7 +92,6 @@ type_kind :: proc(T: typeid) -> Type_Kind {
case Type_Info_Union: return .Union;
case Type_Info_Enum: return .Enum;
case Type_Info_Map: return .Map;
case Type_Info_Bit_Field: return .Bit_Field;
case Type_Info_Bit_Set: return .Bit_Set;
case Type_Info_Opaque: return .Opaque;
case Type_Info_Simd_Vector: return .Simd_Vector;

View File

@@ -157,22 +157,6 @@ are_types_identical :: proc(a, b: ^Type_Info) -> bool {
if !ok { return false; }
return are_types_identical(x.key, y.key) && are_types_identical(x.value, y.value);
case Type_Info_Bit_Field:
y, ok := b.variant.(Type_Info_Bit_Field);
if !ok { return false; }
if len(x.names) != len(y.names) { return false; }
for _, i in x.names {
xb, yb := x.bits[i], y.bits[i];
xo, yo := x.offsets[i], y.offsets[i];
xn, yn := x.names[i], y.names[i];
if xb != yb { return false; }
if xo != yo { return false; }
if xn != yn { return false; }
}
return true;
case Type_Info_Bit_Set:
y, ok := b.variant.(Type_Info_Bit_Set);
if !ok { return false; }
@@ -570,22 +554,6 @@ write_type_writer :: proc(w: io.Writer, ti: ^Type_Info) -> (n: int) {
}
n += _n(io.write_byte(w, '}'));
case Type_Info_Bit_Field:
n += write_string(w, "bit_field ");
if ti.align != 1 {
n += write_string(w, "#align ");
n += _n(io.write_i64(w, i64(ti.align), 10));
n += _n(io.write_byte(w, ' '));
}
n += write_string(w, " {");
for name, i in info.names {
if i > 0 { n += write_string(w, ", "); }
n += write_string(w, name);
n += write_string(w, ": ");
n += _n(io.write_i64(w, i64(info.bits[i]), 10));
}
n += _n(io.write_byte(w, '}'));
case Type_Info_Bit_Set:
n += write_string(w, "bit_set[");
switch {

View File

@@ -136,11 +136,6 @@ Type_Info_Map :: struct {
key_equal: Equal_Proc,
key_hasher: Hasher_Proc,
};
Type_Info_Bit_Field :: struct {
names: []string,
bits: []i32,
offsets: []i32,
};
Type_Info_Bit_Set :: struct {
elem: ^Type_Info,
underlying: ^Type_Info, // Possibly nil
@@ -199,7 +194,6 @@ Type_Info :: struct {
Type_Info_Union,
Type_Info_Enum,
Type_Info_Map,
Type_Info_Bit_Field,
Type_Info_Bit_Set,
Type_Info_Opaque,
Type_Info_Simd_Vector,
@@ -231,7 +225,6 @@ Typeid_Kind :: enum u8 {
Union,
Enum,
Map,
Bit_Field,
Bit_Set,
Opaque,
Simd_Vector,

View File

@@ -324,22 +324,6 @@ print_type :: proc "contextless" (ti: ^Type_Info) {
}
print_string("}");
case Type_Info_Bit_Field:
print_string("bit_field ");
if ti.align != 1 {
print_string("#align ");
print_u64(u64(ti.align));
print_byte(' ');
}
print_string(" {");
for name, i in info.names {
if i > 0 { print_string(", "); }
print_string(name);
print_string(": ");
print_u64(u64(info.bits[i]));
}
print_string("}");
case Type_Info_Bit_Set:
print_string("bit_set[");

View File

@@ -2209,7 +2209,6 @@ void init_core_type_info(Checker *c) {
t_type_info_union = find_core_type(c, str_lit("Type_Info_Union"));
t_type_info_enum = find_core_type(c, str_lit("Type_Info_Enum"));
t_type_info_map = find_core_type(c, str_lit("Type_Info_Map"));
t_type_info_bit_field = find_core_type(c, str_lit("Type_Info_Bit_Field"));
t_type_info_bit_set = find_core_type(c, str_lit("Type_Info_Bit_Set"));
t_type_info_opaque = find_core_type(c, str_lit("Type_Info_Opaque"));
t_type_info_simd_vector = find_core_type(c, str_lit("Type_Info_Simd_Vector"));
@@ -2237,7 +2236,6 @@ void init_core_type_info(Checker *c) {
t_type_info_union_ptr = alloc_type_pointer(t_type_info_union);
t_type_info_enum_ptr = alloc_type_pointer(t_type_info_enum);
t_type_info_map_ptr = alloc_type_pointer(t_type_info_map);
t_type_info_bit_field_ptr = alloc_type_pointer(t_type_info_bit_field);
t_type_info_bit_set_ptr = alloc_type_pointer(t_type_info_bit_set);
t_type_info_opaque_ptr = alloc_type_pointer(t_type_info_opaque);
t_type_info_simd_vector_ptr = alloc_type_pointer(t_type_info_simd_vector);

View File

@@ -357,7 +357,6 @@ enum Typeid_Kind : u8 {
Typeid_Union,
Typeid_Enum,
Typeid_Map,
Typeid_Bit_Field,
Typeid_Bit_Set,
Typeid_Opaque,
Typeid_Simd_Vector,
@@ -633,7 +632,6 @@ gb_global Type *t_type_info_struct = nullptr;
gb_global Type *t_type_info_union = nullptr;
gb_global Type *t_type_info_enum = nullptr;
gb_global Type *t_type_info_map = nullptr;
gb_global Type *t_type_info_bit_field = nullptr;
gb_global Type *t_type_info_bit_set = nullptr;
gb_global Type *t_type_info_opaque = nullptr;
gb_global Type *t_type_info_simd_vector = nullptr;
@@ -661,7 +659,6 @@ gb_global Type *t_type_info_struct_ptr = nullptr;
gb_global Type *t_type_info_union_ptr = nullptr;
gb_global Type *t_type_info_enum_ptr = nullptr;
gb_global Type *t_type_info_map_ptr = nullptr;
gb_global Type *t_type_info_bit_field_ptr = nullptr;
gb_global Type *t_type_info_bit_set_ptr = nullptr;
gb_global Type *t_type_info_opaque_ptr = nullptr;
gb_global Type *t_type_info_simd_vector_ptr = nullptr;