From 6179d4feb1e7e7f1ca2fa418de75e3695318049f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 8 Feb 2023 11:23:21 +0000 Subject: [PATCH] Rename to `Type_Info_Parameters` --- core/encoding/json/marshal.odin | 2 +- core/fmt/fmt.odin | 4 ++-- core/reflect/reflect.odin | 7 ++++--- core/reflect/types.odin | 16 +++++++++++----- core/runtime/core.odin | 10 ++++++---- core/runtime/print.odin | 4 ++-- src/checker.cpp | 4 ++-- src/llvm_backend_type.cpp | 3 +-- src/types.cpp | 4 ++-- 9 files changed, 31 insertions(+), 23 deletions(-) diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin index 1eb75d36a..f5914bc07 100644 --- a/core/encoding/json/marshal.odin +++ b/core/encoding/json/marshal.odin @@ -198,7 +198,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: case runtime.Type_Info_Procedure: return .Unsupported_Type - case runtime.Type_Info_Tuple: + case runtime.Type_Info_Parameters: return .Unsupported_Type case runtime.Type_Info_Simd_Vector: diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 26ddca0dd..c52869daa 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -1783,8 +1783,8 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { type_info := type_info_of(v.id) switch info in type_info.variant { - case runtime.Type_Info_Any: // Ignore - case runtime.Type_Info_Tuple: // Ignore + case runtime.Type_Info_Any: // Ignore + case runtime.Type_Info_Parameters: // Ignore case runtime.Type_Info_Named: fmt_named(fi, v, verb, info) diff --git a/core/reflect/reflect.odin b/core/reflect/reflect.odin index 58f5f6aff..2abf450fa 100644 --- a/core/reflect/reflect.odin +++ b/core/reflect/reflect.odin @@ -25,7 +25,8 @@ Type_Info_Array :: runtime.Type_Info_Array Type_Info_Enumerated_Array :: runtime.Type_Info_Enumerated_Array Type_Info_Dynamic_Array :: runtime.Type_Info_Dynamic_Array Type_Info_Slice :: runtime.Type_Info_Slice -Type_Info_Tuple :: runtime.Type_Info_Tuple +Type_Info_Parameters :: runtime.Type_Info_Parameters +Type_Info_Tuple :: runtime.Type_Info_Parameters Type_Info_Struct :: runtime.Type_Info_Struct Type_Info_Union :: runtime.Type_Info_Union Type_Info_Enum :: runtime.Type_Info_Enum @@ -96,7 +97,7 @@ type_kind :: proc(T: typeid) -> Type_Kind { case Type_Info_Enumerated_Array: return .Enumerated_Array case Type_Info_Dynamic_Array: return .Dynamic_Array case Type_Info_Slice: return .Slice - case Type_Info_Tuple: return .Tuple + case Type_Info_Parameters: return .Tuple case Type_Info_Struct: return .Struct case Type_Info_Union: return .Union case Type_Info_Enum: return .Enum @@ -1438,7 +1439,7 @@ equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_ switch v in t.variant { case Type_Info_Named: unreachable() - case Type_Info_Tuple: + case Type_Info_Parameters: unreachable() case Type_Info_Any: if !including_indirect_array_recursion { diff --git a/core/reflect/types.odin b/core/reflect/types.odin index 1ee09af9d..bfe894733 100644 --- a/core/reflect/types.odin +++ b/core/reflect/types.odin @@ -101,8 +101,8 @@ are_types_identical :: proc(a, b: ^Type_Info) -> bool { y := b.variant.(Type_Info_Slice) or_return return are_types_identical(x.elem, y.elem) - case Type_Info_Tuple: - y := b.variant.(Type_Info_Tuple) or_return + case Type_Info_Parameters: + y := b.variant.(Type_Info_Parameters) or_return if len(x.types) != len(y.types) { return false } for _, i in x.types { xt, yt := x.types[i], y.types[i] @@ -335,9 +335,15 @@ is_slice :: proc(info: ^Type_Info) -> bool { return ok } @(require_results) +is_parameters :: proc(info: ^Type_Info) -> bool { + if info == nil { return false } + _, ok := type_info_base(info).variant.(Type_Info_Parameters) + return ok +} +@(require_results, deprecated="prefer is_parameters") is_tuple :: proc(info: ^Type_Info) -> bool { if info == nil { return false } - _, ok := type_info_base(info).variant.(Type_Info_Tuple) + _, ok := type_info_base(info).variant.(Type_Info_Parameters) return ok } @(require_results) @@ -490,7 +496,7 @@ write_type_writer :: proc(w: io.Writer, ti: ^Type_Info, n_written: ^int = nil) - if info.params == nil { io.write_string(w, "()", &n) or_return } else { - t := info.params.variant.(Type_Info_Tuple) + t := info.params.variant.(Type_Info_Parameters) io.write_string(w, "(", &n) or_return for t, i in t.types { if i > 0 { @@ -504,7 +510,7 @@ write_type_writer :: proc(w: io.Writer, ti: ^Type_Info, n_written: ^int = nil) - io.write_string(w, " -> ", &n) or_return write_type(w, info.results, &n) or_return } - case Type_Info_Tuple: + case Type_Info_Parameters: count := len(info.names) if count != 1 { io.write_string(w, "(", &n) or_return diff --git a/core/runtime/core.odin b/core/runtime/core.odin index a74bf4285..c64ab7d3b 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -83,8 +83,8 @@ Type_Info_Multi_Pointer :: struct { elem: ^Type_Info, } Type_Info_Procedure :: struct { - params: ^Type_Info, // Type_Info_Tuple - results: ^Type_Info, // Type_Info_Tuple + params: ^Type_Info, // Type_Info_Parameters + results: ^Type_Info, // Type_Info_Parameters variadic: bool, convention: Calling_Convention, } @@ -104,10 +104,12 @@ Type_Info_Enumerated_Array :: struct { } Type_Info_Dynamic_Array :: struct {elem: ^Type_Info, elem_size: int} Type_Info_Slice :: struct {elem: ^Type_Info, elem_size: int} -Type_Info_Tuple :: struct { // Only used for procedures parameters and results + +Type_Info_Parameters :: struct { // Only used for procedures parameters and results types: []^Type_Info, names: []string, } +Type_Info_Tuple :: Type_Info_Parameters // Will be removed eventually Type_Info_Struct :: struct { types: []^Type_Info, @@ -208,7 +210,7 @@ Type_Info :: struct { Type_Info_Enumerated_Array, Type_Info_Dynamic_Array, Type_Info_Slice, - Type_Info_Tuple, + Type_Info_Parameters, Type_Info_Struct, Type_Info_Union, Type_Info_Enum, diff --git a/core/runtime/print.odin b/core/runtime/print.odin index 1925587fd..819cd5796 100644 --- a/core/runtime/print.odin +++ b/core/runtime/print.odin @@ -303,7 +303,7 @@ print_type :: proc "contextless" (ti: ^Type_Info) { if info.params == nil { print_string("()") } else { - t := info.params.variant.(Type_Info_Tuple) + t := info.params.variant.(Type_Info_Parameters) print_byte('(') for t, i in t.types { if i > 0 { print_string(", ") } @@ -315,7 +315,7 @@ print_type :: proc "contextless" (ti: ^Type_Info) { print_string(" -> ") print_type(info.results) } - case Type_Info_Tuple: + case Type_Info_Parameters: count := len(info.names) if count != 1 { print_byte('(') } for name, i in info.names { diff --git a/src/checker.cpp b/src/checker.cpp index 06048e154..601c693a0 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -2744,7 +2744,7 @@ gb_internal void init_core_type_info(Checker *c) { t_type_info_enumerated_array = find_core_type(c, str_lit("Type_Info_Enumerated_Array")); t_type_info_dynamic_array = find_core_type(c, str_lit("Type_Info_Dynamic_Array")); t_type_info_slice = find_core_type(c, str_lit("Type_Info_Slice")); - t_type_info_tuple = find_core_type(c, str_lit("Type_Info_Tuple")); + t_type_info_parameters = find_core_type(c, str_lit("Type_Info_Parameters")); t_type_info_struct = find_core_type(c, str_lit("Type_Info_Struct")); 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")); @@ -2773,7 +2773,7 @@ gb_internal void init_core_type_info(Checker *c) { t_type_info_enumerated_array_ptr = alloc_type_pointer(t_type_info_enumerated_array); t_type_info_dynamic_array_ptr = alloc_type_pointer(t_type_info_dynamic_array); t_type_info_slice_ptr = alloc_type_pointer(t_type_info_slice); - t_type_info_tuple_ptr = alloc_type_pointer(t_type_info_tuple); + t_type_info_parameters_ptr = alloc_type_pointer(t_type_info_parameters); t_type_info_struct_ptr = alloc_type_pointer(t_type_info_struct); t_type_info_union_ptr = alloc_type_pointer(t_type_info_union); t_type_info_enum_ptr = alloc_type_pointer(t_type_info_enum); diff --git a/src/llvm_backend_type.cpp b/src/llvm_backend_type.cpp index e2b5c9dd0..e8d286fda 100644 --- a/src/llvm_backend_type.cpp +++ b/src/llvm_backend_type.cpp @@ -541,8 +541,7 @@ gb_internal void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup break; } case Type_Tuple: { - tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_tuple_ptr); - + tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_parameters_ptr); lbValue memory_types = lb_type_info_member_types_offset(p, t->Tuple.variables.count); lbValue memory_names = lb_type_info_member_names_offset(p, t->Tuple.variables.count); diff --git a/src/types.cpp b/src/types.cpp index 69c1ebe68..7a1f17a16 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -624,7 +624,7 @@ gb_global Type *t_type_info_array = nullptr; gb_global Type *t_type_info_enumerated_array = nullptr; gb_global Type *t_type_info_dynamic_array = nullptr; gb_global Type *t_type_info_slice = nullptr; -gb_global Type *t_type_info_tuple = nullptr; +gb_global Type *t_type_info_parameters = nullptr; gb_global Type *t_type_info_struct = nullptr; gb_global Type *t_type_info_union = nullptr; gb_global Type *t_type_info_enum = nullptr; @@ -653,7 +653,7 @@ gb_global Type *t_type_info_array_ptr = nullptr; gb_global Type *t_type_info_enumerated_array_ptr = nullptr; gb_global Type *t_type_info_dynamic_array_ptr = nullptr; gb_global Type *t_type_info_slice_ptr = nullptr; -gb_global Type *t_type_info_tuple_ptr = nullptr; +gb_global Type *t_type_info_parameters_ptr = nullptr; 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;