v2: reorder types idxs, > string defined with v struct. rm unresovled

pull/3790/head
joe-conigliaro 2020-02-20 11:39:59 +11:00
parent d2cb5ad725
commit aab1045045
3 changed files with 15 additions and 29 deletions

View File

@ -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'
}

View File

@ -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

View File

@ -57,12 +57,6 @@ pub fn new_type_ptr(idx, nr_muls int) Type {
return idx<<i16(16) | nr_muls
}
// true if the type of unresolved expression
[inline]
pub fn type_is_unresolved(t Type) bool {
return type_idx(t) < 0
}
pub const (
void_type = new_type(void_type_idx)
voidptr_type = new_type(voidptr_type_idx)