1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: rename generic_struct_inst to generic_inst (#11044)

This commit is contained in:
Daniel Däschle 2021-08-04 02:37:27 +02:00 committed by GitHub
parent c13ba6d4b6
commit 815c4b7420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 13 deletions

View File

@ -16,7 +16,7 @@ import v.pref
pub type Type = int pub type Type = int
pub type TypeInfo = Aggregate | Alias | Array | ArrayFixed | Chan | Enum | FnType | GenericStructInst | pub type TypeInfo = Aggregate | Alias | Array | ArrayFixed | Chan | Enum | FnType | GenericInst |
Interface | Map | MultiReturn | Struct | SumType | Thread Interface | Map | MultiReturn | Struct | SumType | Thread
pub enum Language { pub enum Language {
@ -517,7 +517,7 @@ pub enum Kind {
chan chan
any any
struct_ struct_
generic_struct_inst generic_inst
multi_return multi_return
sum_type sum_type
alias alias
@ -750,7 +750,7 @@ pub fn (k Kind) str() string {
.any { 'any' } .any { 'any' }
.function { 'function' } .function { 'function' }
.interface_ { 'interface' } .interface_ { 'interface' }
.generic_struct_inst { 'generic_struct_inst' } .generic_inst { 'generic_inst' }
.rune { 'rune' } .rune { 'rune' }
.aggregate { 'aggregate' } .aggregate { 'aggregate' }
.thread { 'thread' } .thread { 'thread' }
@ -785,7 +785,7 @@ pub mut:
} }
// instantiation of a generic struct // instantiation of a generic struct
pub struct GenericStructInst { pub struct GenericInst {
pub mut: pub mut:
parent_idx int // idx of the base generic struct parent_idx int // idx of the base generic struct
concrete_types []Type // concrete types, e.g. <int, string> concrete_types []Type // concrete types, e.g. <int, string>
@ -1030,8 +1030,8 @@ pub fn (t &Table) type_to_str_using_aliases(typ Type, import_aliases map[string]
res = t.shorten_user_defined_typenames(res, import_aliases) res = t.shorten_user_defined_typenames(res, import_aliases)
} }
} }
.generic_struct_inst { .generic_inst {
info := sym.info as GenericStructInst info := sym.info as GenericInst
res = sym.name.all_before('<') res = sym.name.all_before('<')
res += '<' res += '<'
for i, ctyp in info.concrete_types { for i, ctyp in info.concrete_types {

View File

@ -793,8 +793,8 @@ fn (mut c Checker) unwrap_generic_type(typ ast.Type, generic_names []string, con
// generic struct instantiations to concrete types // generic struct instantiations to concrete types
pub fn (mut c Checker) generic_insts_to_concrete() { pub fn (mut c Checker) generic_insts_to_concrete() {
for mut typ in c.table.type_symbols { for mut typ in c.table.type_symbols {
if typ.kind == .generic_struct_inst { if typ.kind == .generic_inst {
info := typ.info as ast.GenericStructInst info := typ.info as ast.GenericInst
parent := c.table.type_symbols[info.parent_idx] parent := c.table.type_symbols[info.parent_idx]
if parent.kind == .placeholder { if parent.kind == .placeholder {
typ.kind = .placeholder typ.kind = .placeholder

View File

@ -171,7 +171,7 @@ pub fn (mut g JsGen) typ(t ast.Type) string {
.struct_ { .struct_ {
styp = g.struct_typ(sym.name) styp = g.struct_typ(sym.name)
} }
.generic_struct_inst {} .generic_inst {}
// 'multi_return_int_int' => '[number, number]' // 'multi_return_int_int' => '[number, number]'
.multi_return { .multi_return {
info := sym.info as ast.MultiReturn info := sym.info as ast.MultiReturn

View File

@ -912,8 +912,9 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) {
fn (mut p Parser) check_fn_mutable_arguments(typ ast.Type, pos token.Position) { fn (mut p Parser) check_fn_mutable_arguments(typ ast.Type, pos token.Position) {
sym := p.table.get_type_symbol(typ) sym := p.table.get_type_symbol(typ)
if sym.kind in [.array, .array_fixed, .interface_, .map, .placeholder, .struct_, if sym.kind in [.array, .array_fixed, .interface_, .map, .placeholder, .struct_, .generic_inst,
.generic_struct_inst, .sum_type] { .sum_type,
] {
return return
} }
if typ.is_ptr() || typ.is_pointer() { if typ.is_ptr() || typ.is_pointer() {

View File

@ -562,11 +562,11 @@ pub fn (mut p Parser) parse_generic_struct_inst_type(name string) ast.Type {
parent_idx = p.table.add_placeholder_type(name, .v) parent_idx = p.table.add_placeholder_type(name, .v)
} }
idx := p.table.register_type_symbol(ast.TypeSymbol{ idx := p.table.register_type_symbol(ast.TypeSymbol{
kind: .generic_struct_inst kind: .generic_inst
name: bs_name name: bs_name
cname: util.no_dots(bs_cname) cname: util.no_dots(bs_cname)
mod: p.mod mod: p.mod
info: ast.GenericStructInst{ info: ast.GenericInst{
parent_idx: parent_idx parent_idx: parent_idx
concrete_types: concrete_types concrete_types: concrete_types
} }