Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vlib: add missing docstring for vlib/v/ast/types.v functions #19752

Merged
merged 2 commits into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions vlib/v/ast/types.v
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub enum Language {
wasm32
}

// pref_arch_to_table_language returns target language based on pref_arch
pub fn pref_arch_to_table_language(pref_arch pref.Arch) Language {
return match pref_arch {
.amd64 {
Expand Down Expand Up @@ -125,6 +126,7 @@ pub enum ShareType {
atomic_t
}

// str converts t to it's string form of ShareType i.e. mut, shared, atomic
pub fn (t ShareType) str() string {
match t {
.mut_t { return 'mut' }
Expand Down Expand Up @@ -287,11 +289,13 @@ pub fn (t Type) idx() int {
return u16(t) & 0xffff
}

// is_void return true if t is of type void
[inline]
pub fn (t Type) is_void() bool {
return t == ast.void_type
}

// is_full return true if t is not of type void
[inline]
pub fn (t Type) is_full() bool {
return t != 0 && t != ast.void_type
Expand All @@ -311,17 +315,20 @@ pub fn (t Type) is_ptr() bool {
return (int(t) >> 16) & 0xff > 0
}

// is_pointer returns true if typ is any of the builtin pointer types (voidptr, byteptr, charptr)
[inline]
pub fn (typ Type) is_pointer() bool {
// builtin pointer types (voidptr, byteptr, charptr)
return typ.idx() in ast.pointer_type_idxs
}

// is_voidptr returns true if typ is a voidptr
[inline]
pub fn (typ Type) is_voidptr() bool {
return typ.idx() == ast.voidptr_type_idx
}

// is_any_kind_of_pointer returns true if t is any type of pointer
[inline]
pub fn (t Type) is_any_kind_of_pointer() bool {
return (int(t) >> 16) & 0xff > 0 || (u16(t) & 0xffff) in ast.pointer_type_idxs
Expand Down
Loading