From aab1045045eb7e99da3d87562a058b3720bd364a Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Thu, 20 Feb 2020 11:39:59 +1100 Subject: [PATCH] v2: reorder types idxs, > string defined with v struct. rm unresovled --- vlib/v/table/atype_symbols.v | 29 ++++++++++++++--------------- vlib/v/table/table.v | 9 +-------- vlib/v/table/types.v | 6 ------ 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/vlib/v/table/atype_symbols.v b/vlib/v/table/atype_symbols.v index 9abb0d5820..53ce63603c 100644 --- a/vlib/v/table/atype_symbols.v +++ b/vlib/v/table/atype_symbols.v @@ -35,16 +35,16 @@ pub const ( f64_type_idx = 14 char_type_idx = 15 bool_type_idx = 16 + none_type_idx = 17 // advanced / defined from v structs - string_type_idx = 17 - array_type_idx = 18 - map_type_idx = 19 - none_type_idx = 20 + string_type_idx = 18 + array_type_idx = 19 + map_type_idx = 20 ) pub const ( builtin_type_names = ['void', 'voidptr', 'charptr', 'byteptr', 'i8', 'i16', 'int', 'i64', 'u16', 'u32', 'u64', - 'f32', 'f64', 'string', 'char', 'byte', 'bool', 'struct', 'array', 'array_fixed', 'map', + 'f32', 'f64', 'string', 'char', 'byte', 'bool', 'none', 'array', 'array_fixed', 'map', 'struct', 'mapnode', 'ustring'] ) @@ -73,16 +73,15 @@ pub enum Kind { f64 char bool + none_ string - struct_ array array_fixed map + struct_ multi_return sum_type alias - unresolved - none_ } [inline] @@ -226,6 +225,10 @@ pub fn (t mut Table) register_builtin_type_symbols() { kind: .bool name: 'bool' }) + t.register_type_symbol(TypeSymbol{ + kind: .none_ + name: 'none' + }) t.register_type_symbol(TypeSymbol{ kind: .string name: 'string' @@ -238,10 +241,6 @@ pub fn (t mut Table) register_builtin_type_symbols() { kind: .map name: 'map' }) - t.register_type_symbol(TypeSymbol{ - kind: .none_ - name: 'none' - }) // TODO: remove t.register_type_symbol(TypeSymbol{ parent_idx: map_type_idx @@ -267,9 +266,6 @@ pub fn (t &TypeSymbol) is_number() bool { pub fn (k Kind) str() string { k_str := match k { - .unresolved{ - 'unresolved' - } .placeholder{ 'placeholder' } @@ -327,6 +323,9 @@ pub fn (k Kind) str() string { .bool{ 'bool' } + .none_{ + 'none' + } .array{ 'array' } diff --git a/vlib/v/table/table.v b/vlib/v/table/table.v index 777c3b1f0e..580500b649 100644 --- a/vlib/v/table/table.v +++ b/vlib/v/table/table.v @@ -187,14 +187,7 @@ pub fn (t &Table) find_type(name string) ?TypeSymbol { [inline] pub fn (t &Table) get_type_symbol(typ Type) &TypeSymbol { idx := type_idx(typ) - if idx < 0 { - unresolved_idx := -idx - return &TypeSymbol{ - kind: .unresolved - name: 'unresolved-$unresolved_idx' - } - } - else if idx > 0 { + if idx > 0 { return &t.types[idx] } // this should never happen diff --git a/vlib/v/table/types.v b/vlib/v/table/types.v index 546a01f8ea..09e9e708c6 100644 --- a/vlib/v/table/types.v +++ b/vlib/v/table/types.v @@ -57,12 +57,6 @@ pub fn new_type_ptr(idx, nr_muls int) Type { return idx<