Skip to content

v3.util

fn arm64_asm_register_names #

fn arm64_asm_register_names() []string

arm64_asm_register_names returns the register names an arm64 assembly block can use.

fn asm_clobber_is_special #

fn asm_clobber_is_special(name string) bool

asm_clobber_is_special reports whether name is one of the GNU pseudo clobbers that never name a register.

fn asm_register_names #

fn asm_register_names(arch string) []string

asm_register_names returns every register name an assembly block for arch can use. An empty result means the architecture has no table here, so callers must not treat unknown names as errors.

fn closest_asm_register #

fn closest_asm_register(name string, registers []string) ?string

closest_asm_register returns the register in registers that name was most likely meant to be, or none when nothing is close enough to be worth suggesting.

fn contains_capital #

fn contains_capital(s string) bool

contains_capital reports whether s contains an uppercase character.

fn githash #

fn githash(path string) !string

githash returns the current seven-character Git commit hash for path.

fn is_escape_sequence #

fn is_escape_sequence(c u8) bool

is_escape_sequence reports whether c is a valid escape sequence denoter.

fn nearest_vmod_root #

fn nearest_vmod_root(path string) ?string

nearest_vmod_root returns the closest directory containing a v.mod for path.

fn new_suggestion #

fn new_suggestion(wanted string, possibilities []string, params SuggestionParams) Suggestion

new_suggestion creates a diagnostic suggestion from wanted and possibilities.

fn parse_inline_asm_header #

fn parse_inline_asm_header(source string) InlineAsmHeader

parse_inline_asm_header reads the instruction set and template modifiers from the text preceding an assembly block's opening brace.

fn tokenize_c_flag #

fn tokenize_c_flag(value string) []string

tokenize_c_flag splits a C flag on unquoted whitespace while preserving quotes.

fn x86_asm_register_names #

fn x86_asm_register_names() []string

x86_asm_register_names mirrors the i386 and amd64 register set V's assembly blocks accept, including the numbered general purpose, vector, mask, control and debug ones.

type CalculateSuggestionSimilarityFN #

type CalculateSuggestionSimilarityFN = fn (s1 string, s2 string) f32

CalculateSuggestionSimilarityFN compares two suggestion candidates.

fn (Suggestion) say #

fn (s Suggestion) say(message string) string

say appends the best suggestion, or a short possibility list, to message.

struct InlineAsmHeader #

struct InlineAsmHeader {
pub:
	arch        string
	is_goto     bool
	is_volatile bool
	is_raw      bool
	is_intel    bool
}

InlineAsmHeader describes the words a V assembly block writes before its {, for example asm amd64 raw intel {.

struct SuggestionParams #

@[params]
struct SuggestionParams {
pub mut:
	similarity_threshold f32 = 0.5
	similarity_fn        CalculateSuggestionSimilarityFN = strings.dice_coefficient
}

SuggestionParams configures new_suggestion.