Remove #opaque types

This commit is contained in:
gingerBill
2021-02-23 15:45:06 +00:00
parent 28f279329d
commit 41b854f192
23 changed files with 2 additions and 262 deletions
-3
View File
@@ -308,9 +308,6 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
write_u64(b, bit_data);
return .Unsupported_Type;
case Type_Info_Opaque:
return .Unsupported_Type;
}
-48
View File
@@ -1247,49 +1247,6 @@ fmt_write_array :: proc(fi: ^Info, array_data: rawptr, count: int, elem_size: in
}
}
fmt_opaque :: proc(fi: ^Info, v: any) {
is_nil :: proc(data: rawptr, n: int) -> bool {
if data == nil { return true; }
if n == 0 { return true; }
a := (^byte)(data);
for i in 0..<n {
if mem.ptr_offset(a, i)^ != 0 {
return false;
}
}
return true;
}
rt :: runtime;
type_info := type_info_of(v.id);
if is_nil(v.data, type_info.size) {
io.write_string(fi.writer, "nil");
return;
}
if ot, ok := rt.type_info_base(type_info).variant.(rt.Type_Info_Opaque); ok {
elem := rt.type_info_base(ot.elem);
if elem == nil { return; }
reflect.write_type(fi.writer, type_info);
io.write_byte(fi.writer, '{');
defer io.write_byte(fi.writer, '}');
#partial switch in elem.variant {
case rt.Type_Info_Integer, rt.Type_Info_Pointer, rt.Type_Info_Float:
fmt_value(fi, any{v.data, elem.id}, 'v');
case:
// Okay
}
} else {
reflect.write_type(fi.writer, type_info);
io.write_byte(fi.writer, '{');
io.write_byte(fi.writer, '}');
}
}
fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
write_padded_number :: proc(fi: ^Info, i: i64, width: int) {
n := width-1;
@@ -1553,8 +1510,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_Opaque:
fmt_opaque(fi, v);
case:
fmt_value(fi, any{v.data, info.base.id}, verb);
}
@@ -1924,9 +1879,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_Opaque:
fmt_opaque(fi, v);
case runtime.Type_Info_Relative_Pointer:
ptr := reflect.relative_pointer_to_absolute_raw(v.data, info.base_integer.id);
absolute_ptr := any{ptr, info.pointer.id};
-1
View File
@@ -121,7 +121,6 @@ type_is_valid_map_key :: proc($T: typeid) -> bool ---
type_is_named :: proc($T: typeid) -> bool ---
type_is_pointer :: proc($T: typeid) -> bool ---
type_is_opaque :: proc($T: typeid) -> bool ---
type_is_array :: proc($T: typeid) -> bool ---
type_is_enumerated_array :: proc($T: typeid) -> bool ---
type_is_slice :: proc($T: typeid) -> bool ---
-5
View File
@@ -630,11 +630,6 @@ Distinct_Type :: struct {
type: ^Expr,
}
Opaque_Type :: struct {
using node: Expr,
type: ^Expr,
}
Poly_Type :: struct {
using node: Expr,
dollar: tokenizer.Pos,
-2
View File
@@ -243,8 +243,6 @@ clone_node :: proc(node: ^Node) -> ^Node {
r.type = clone(r.type);
case Distinct_Type:
r.type = clone(r.type);
case Opaque_Type:
r.type = clone(r.type);
case Poly_Type:
r.type = auto_cast clone(r.type);
r.specialization = clone(r.specialization);
-2
View File
@@ -339,8 +339,6 @@ walk :: proc(v: ^Visitor, node: ^Node) {
walk(v, n.type);
case Distinct_Type:
walk(v, n.type);
case Opaque_Type:
walk(v, n.type);
case Poly_Type:
walk(v, n.type);
if n.specialization != nil {
-6
View File
@@ -2101,12 +2101,6 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
tok := expect_token(p, .Hash);
name := expect_token(p, .Ident);
switch name.text {
case "opaque":
type := parse_type(p);
ot := ast.new(ast.Opaque_Type, tok.pos, type.end);
ot.type = type;
return ot;
case "type":
type := parse_type(p);
hp := ast.new(ast.Helper_Type, tok.pos, type.end);
-5
View File
@@ -29,7 +29,6 @@ Type_Info_Union :: runtime.Type_Info_Union;
Type_Info_Enum :: runtime.Type_Info_Enum;
Type_Info_Map :: runtime.Type_Info_Map;
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;
Type_Info_Relative_Pointer :: runtime.Type_Info_Relative_Pointer;
Type_Info_Relative_Slice :: runtime.Type_Info_Relative_Slice;
@@ -60,7 +59,6 @@ Type_Kind :: enum {
Enum,
Map,
Bit_Set,
Opaque,
Simd_Vector,
Relative_Pointer,
Relative_Slice,
@@ -93,7 +91,6 @@ type_kind :: proc(T: typeid) -> Type_Kind {
case Type_Info_Enum: return .Enum;
case Type_Info_Map: return .Map;
case Type_Info_Bit_Set: return .Bit_Set;
case Type_Info_Opaque: return .Opaque;
case Type_Info_Simd_Vector: return .Simd_Vector;
case Type_Info_Relative_Pointer: return .Relative_Pointer;
case Type_Info_Relative_Slice: return .Relative_Slice;
@@ -136,7 +133,6 @@ type_info_core :: proc(info: ^runtime.Type_Info) -> ^runtime.Type_Info {
#partial switch i in base.variant {
case Type_Info_Named: base = i.base;
case Type_Info_Enum: base = i.base;
case Type_Info_Opaque: base = i.elem;
case: break loop;
}
}
@@ -174,7 +170,6 @@ typeid_elem :: proc(id: typeid) -> typeid {
case 256: return f64;
}
case Type_Info_Pointer: return v.elem.id;
case Type_Info_Opaque: return v.elem.id;
case Type_Info_Array: return v.elem.id;
case Type_Info_Enumerated_Array: return v.elem.id;
case Type_Info_Slice: return v.elem.id;
-14
View File
@@ -162,11 +162,6 @@ are_types_identical :: proc(a, b: ^Type_Info) -> bool {
if !ok { return false; }
return x.elem == y.elem && x.lower == y.lower && x.upper == y.upper;
case Type_Info_Opaque:
y, ok := b.variant.(Type_Info_Opaque);
if !ok { return false; }
return x.elem == y.elem;
case Type_Info_Simd_Vector:
y, ok := b.variant.(Type_Info_Simd_Vector);
if !ok { return false; }
@@ -317,11 +312,6 @@ is_enum :: proc(info: ^Type_Info) -> bool {
_, ok := type_info_base(info).variant.(Type_Info_Enum);
return ok;
}
is_opaque :: proc(info: ^Type_Info) -> bool {
if info == nil { return false; }
_, ok := type_info_base(info).variant.(Type_Info_Opaque);
return ok;
}
is_simd_vector :: proc(info: ^Type_Info) -> bool {
if info == nil { return false; }
_, ok := type_info_base(info).variant.(Type_Info_Simd_Vector);
@@ -574,10 +564,6 @@ write_type_writer :: proc(w: io.Writer, ti: ^Type_Info) -> (n: int) {
}
n += _n(io.write_byte(w, ']'));
case Type_Info_Opaque:
n += write_string(w, "#opaque ");
n += write_type(w, info.elem);
case Type_Info_Simd_Vector:
if info.is_x86_mmx {
n += write_string(w, "intrinsics.x86_mmx");
-6
View File
@@ -140,9 +140,6 @@ Type_Info_Bit_Set :: struct {
lower: i64,
upper: i64,
};
Type_Info_Opaque :: struct {
elem: ^Type_Info,
};
Type_Info_Simd_Vector :: struct {
elem: ^Type_Info,
elem_size: int,
@@ -193,7 +190,6 @@ Type_Info :: struct {
Type_Info_Enum,
Type_Info_Map,
Type_Info_Bit_Set,
Type_Info_Opaque,
Type_Info_Simd_Vector,
Type_Info_Relative_Pointer,
Type_Info_Relative_Slice,
@@ -224,7 +220,6 @@ Typeid_Kind :: enum u8 {
Enum,
Map,
Bit_Set,
Opaque,
Simd_Vector,
Relative_Pointer,
Relative_Slice,
@@ -399,7 +394,6 @@ type_info_core :: proc "contextless" (info: ^Type_Info) -> ^Type_Info {
#partial switch i in base.variant {
case Type_Info_Named: base = i.base;
case Type_Info_Enum: base = i.base;
case Type_Info_Opaque: base = i.elem;
case: break loop;
}
}
-3
View File
@@ -345,9 +345,6 @@ print_type :: proc "contextless" (ti: ^Type_Info) {
}
print_byte(']');
case Type_Info_Opaque:
print_string("#opaque ");
print_type(info.elem);
case Type_Info_Simd_Vector:
if info.is_x86_mmx {