ast: rename TypeSymbol.is_public to TypeSymbol.is_pub (#13710)

pull/13711/head
yuyi 2022-03-11 04:18:57 +08:00 committed by GitHub
parent f3388df577
commit dd06698ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 24 deletions

View File

@ -1933,7 +1933,7 @@ pub fn (mut t Table) generic_insts_to_concrete() {
fields: fields fields: fields
parent_type: new_type(info.parent_idx).set_flag(.generic) parent_type: new_type(info.parent_idx).set_flag(.generic)
} }
typ.is_public = true typ.is_pub = true
typ.kind = parent.kind typ.kind = parent.kind
parent_sym := t.sym(parent_info.parent_type) parent_sym := t.sym(parent_info.parent_type)
@ -1996,7 +1996,7 @@ pub fn (mut t Table) generic_insts_to_concrete() {
methods: imethods methods: imethods
parent_type: new_type(info.parent_idx).set_flag(.generic) parent_type: new_type(info.parent_idx).set_flag(.generic)
} }
typ.is_public = true typ.is_pub = true
typ.kind = parent.kind typ.kind = parent.kind
typ.methods = all_methods typ.methods = all_methods
} else { } else {
@ -2043,7 +2043,7 @@ pub fn (mut t Table) generic_insts_to_concrete() {
variants: variants variants: variants
parent_type: new_type(info.parent_idx).set_flag(.generic) parent_type: new_type(info.parent_idx).set_flag(.generic)
} }
typ.is_public = true typ.is_pub = true
typ.kind = parent.kind typ.kind = parent.kind
} else { } else {
util.verror('generic error', 'the number of generic types of sumtype `$parent.name` is inconsistent with the concrete types') util.verror('generic error', 'the number of generic types of sumtype `$parent.name` is inconsistent with the concrete types')

View File

@ -84,15 +84,15 @@ pub struct TypeSymbol {
pub: pub:
parent_idx int parent_idx int
pub mut: pub mut:
info TypeInfo info TypeInfo
kind Kind kind Kind
name string // the internal & source name of the type, i.e. `[5]int`. name string // the internal & source name of the type, i.e. `[5]int`.
cname string // the name with no dots for use in the generated C code cname string // the name with no dots for use in the generated C code
methods []Fn methods []Fn
mod string mod string
is_public bool is_pub bool
language Language language Language
idx int idx int
} }
// max of 8 // max of 8
@ -253,7 +253,7 @@ fn (ts TypeSymbol) dbg_common(mut res []string) {
res << 'name: $ts.name' res << 'name: $ts.name'
res << 'cname: $ts.cname' res << 'cname: $ts.cname'
res << 'kind: $ts.kind' res << 'kind: $ts.kind'
res << 'is_public: $ts.is_public' res << 'is_pub: $ts.is_pub'
res << 'language: $ts.language' res << 'language: $ts.language'
} }

View File

@ -2357,7 +2357,7 @@ fn (mut c Checker) import_stmt(node ast.Import) {
if sym.name[0].is_capital() { if sym.name[0].is_capital() {
if type_sym := c.table.find_sym(name) { if type_sym := c.table.find_sym(name) {
if type_sym.kind != .placeholder { if type_sym.kind != .placeholder {
if !type_sym.is_public { if !type_sym.is_pub {
c.error('module `$node.mod` type `$sym.name` is private', sym.pos) c.error('module `$node.mod` type `$sym.name` is private', sym.pos)
} }
continue continue
@ -3886,7 +3886,7 @@ pub fn (mut c Checker) enum_val(mut node ast.EnumVal) ast.Type {
c.error('not an enum', node.pos) c.error('not an enum', node.pos)
return ast.void_type return ast.void_type
} }
if !(typ_sym.is_public || typ_sym.mod == c.mod) { if !(typ_sym.is_pub || typ_sym.mod == c.mod) {
c.error('enum `$typ_sym.name` is private', node.pos) c.error('enum `$typ_sym.name` is private', node.pos)
} }
info := typ_sym.enum_info() info := typ_sym.enum_info()

View File

@ -210,7 +210,7 @@ pub fn (mut c Checker) struct_init(mut node ast.StructInit) ast.Type {
} }
} }
// allow init structs from generic if they're private except the type is from builtin module // allow init structs from generic if they're private except the type is from builtin module
if !type_sym.is_public && type_sym.kind != .placeholder && type_sym.language != .c if !type_sym.is_pub && type_sym.kind != .placeholder && type_sym.language != .c
&& (type_sym.mod != c.mod && !(node.typ.has_flag(.generic) && type_sym.mod != 'builtin')) { && (type_sym.mod != c.mod && !(node.typ.has_flag(.generic) && type_sym.mod != 'builtin')) {
c.error('type `$type_sym.name` is private', node.pos) c.error('type `$type_sym.name` is private', node.pos)
} }

View File

@ -611,7 +611,7 @@ pub fn (mut p Parser) parse_generic_type(name string) ast.Type {
cname: util.no_dots(name) cname: util.no_dots(name)
mod: p.mod mod: p.mod
kind: .any kind: .any
is_public: true is_pub: true
}) })
return ast.new_type(idx).set_flag(.generic) return ast.new_type(idx).set_flag(.generic)
} }

View File

@ -2798,7 +2798,7 @@ fn (mut p Parser) parse_generic_types() ([]ast.Type, []string) {
cname: util.no_dots(name) cname: util.no_dots(name)
mod: p.mod mod: p.mod
kind: .any kind: .any
is_public: true is_pub: true
}) })
} }
types << ast.new_type(idx).set_flag(.generic) types << ast.new_type(idx).set_flag(.generic)
@ -3517,7 +3517,7 @@ fn (mut p Parser) enum_decl() ast.EnumDecl {
is_flag: is_flag is_flag: is_flag
is_multi_allowed: is_multi_allowed is_multi_allowed: is_multi_allowed
} }
is_public: is_pub is_pub: is_pub
}) })
if idx == -1 { if idx == -1 {
p.error_with_pos('cannot register enum `$name`, another type with this name exists', p.error_with_pos('cannot register enum `$name`, another type with this name exists',
@ -3571,7 +3571,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
// function type: `type mycallback = fn(string, int)` // function type: `type mycallback = fn(string, int)`
fn_name := p.prepend_mod(name) fn_name := p.prepend_mod(name)
fn_type := p.parse_fn_type(fn_name) fn_type := p.parse_fn_type(fn_name)
p.table.sym(fn_type).is_public = is_pub p.table.sym(fn_type).is_pub = is_pub
type_pos = type_pos.extend(p.tok.pos()) type_pos = type_pos.extend(p.tok.pos())
comments = p.eat_comments(same_line: true) comments = p.eat_comments(same_line: true)
return ast.FnTypeDecl{ return ast.FnTypeDecl{
@ -3606,7 +3606,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
is_generic: generic_types.len > 0 is_generic: generic_types.len > 0
generic_types: generic_types generic_types: generic_types
} }
is_public: is_pub is_pub: is_pub
}) })
if typ == ast.invalid_type_idx { if typ == ast.invalid_type_idx {
p.error_with_pos('cannot register sum type `$name`, another type with this name exists', p.error_with_pos('cannot register sum type `$name`, another type with this name exists',
@ -3646,7 +3646,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
parent_type: parent_type parent_type: parent_type
language: parent_sym.language language: parent_sym.language
} }
is_public: is_pub is_pub: is_pub
}) })
type_end_pos := p.prev_tok.pos() type_end_pos := p.prev_tok.pos()
if idx == ast.invalid_type_idx { if idx == ast.invalid_type_idx {

View File

@ -304,7 +304,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
generic_types: generic_types generic_types: generic_types
attrs: attrs attrs: attrs
} }
is_public: is_pub is_pub: is_pub
} }
if p.table.has_deep_child_no_ref(&t, name) { if p.table.has_deep_child_no_ref(&t, name) {
p.error_with_pos('invalid recursive struct `$orig_name`', name_pos) p.error_with_pos('invalid recursive struct `$orig_name`', name_pos)
@ -478,7 +478,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
} }
// Declare the type // Declare the type
reg_idx := p.table.register_sym( reg_idx := p.table.register_sym(
is_public: is_pub is_pub: is_pub
kind: .interface_ kind: .interface_
name: interface_name name: interface_name
cname: util.no_dots(interface_name) cname: util.no_dots(interface_name)