Skip to content

Commit

Permalink
all: replace enum field name 'xxx_' with 'xxx'
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Oct 10, 2024
1 parent b97b2b1 commit 5fe4a18
Show file tree
Hide file tree
Showing 68 changed files with 380 additions and 385 deletions.
4 changes: 2 additions & 2 deletions cmd/tools/vdoc/highlight.v
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn color_highlight(code string, tb &ast.Table) string {
.boolean {
lit = term.bright_magenta(tok.lit)
}
.none_ {
.none {
lit = term.red(tok.lit)
}
.prefix {
Expand Down Expand Up @@ -133,7 +133,7 @@ fn color_highlight(code string, tb &ast.Table) string {
tok_typ = .punctuation
}
.key_none {
tok_typ = .none_
tok_typ = .none
}
else {
if token.is_key(tok.lit) || token.is_decl(tok.kind) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/html.v
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum HighlightTokenTyp {
partial_string
closing_string
symbol
none_
none
module_
prefix
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/tools/vls.v
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum UpdateSource {
}

enum SetupKind {
none_
none
install
update
}
Expand All @@ -39,7 +39,7 @@ enum OutputMode {
struct VlsUpdater {
mut:
output OutputMode = .text
setup_kind SetupKind = .none_
setup_kind SetupKind = .none
update_source UpdateSource = .github_releases
ls_path string // --path
pass_to_ls bool // --ls
Expand Down Expand Up @@ -348,7 +348,7 @@ fn (mut upd VlsUpdater) parse(mut fp flag.FlagParser) ! {

upd.ls_path = ls_path

if upd.setup_kind != .none_ {
if upd.setup_kind != .none {
upd.update_source = .local_file // use local path if both -p and --source are used
}
}
Expand All @@ -368,7 +368,7 @@ fn (mut upd VlsUpdater) parse(mut fp flag.FlagParser) ! {
}

upd.ls_path = ls_path
} else if upd.setup_kind == .none_ {
} else if upd.setup_kind == .none {
return server_not_found_err
}
}
Expand Down Expand Up @@ -455,7 +455,7 @@ fn (upd VlsUpdater) check_installation() {
fn (upd VlsUpdater) run(fp flag.FlagParser) ! {
if upd.is_check {
upd.check_installation()
} else if upd.setup_kind != .none_ {
} else if upd.setup_kind != .none {
upd.check_or_create_vls_folder()!

match upd.update_source {
Expand Down
50 changes: 25 additions & 25 deletions cmd/tools/vrepl.v
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ enum FnType {
}

enum DeclType {
include_ // #include ...
const_ // const ...
type_ // type ...
enum_ // enum ...
fn_ // fn ...
struct // struct ...
interface_ // interface ...
stmt_ // statement
include // #include ...
const // const ...
type // type ...
enum // enum ...
fn // fn ...
struct // struct ...
interface // interface ...
stmt // statement
}

fn new_repl(folder string) Repl {
Expand Down Expand Up @@ -249,35 +249,35 @@ fn (r &Repl) insert_source_code(typ DeclType, lines []string) string {
all_lines << r.vstartup_lines.filter(!it.starts_with('print'))
}
all_lines << r.includes
if typ == .include_ {
if typ == .include {
all_lines << lines
}
all_lines << r.types
if typ == .type_ {
if typ == .type {
all_lines << lines
}
all_lines << r.enums
if typ == .enum_ {
if typ == .enum {
all_lines << lines
}
all_lines << r.consts
if typ == .const_ {
if typ == .const {
all_lines << lines
}
all_lines << r.structs
if typ == .struct {
all_lines << lines
}
all_lines << r.interfaces
if typ == .interface_ {
if typ == .interface {
all_lines << lines
}
all_lines << r.functions
if typ == .fn_ {
if typ == .fn {
all_lines << lines
}
all_lines << r.lines
if typ == .stmt_ {
if typ == .stmt {
all_lines << lines
}
return all_lines.join('\n')
Expand Down Expand Up @@ -596,30 +596,30 @@ fn run_repl(workdir string, vrepl_prefix string) int {
}
} else if r.line.len == 0 {
if was_func {
temp_source_code = r.insert_source_code(DeclType.fn_, r.temp_lines)
temp_source_code = r.insert_source_code(DeclType.fn, r.temp_lines)
} else if was_struct {
temp_source_code = r.insert_source_code(DeclType.struct, r.temp_lines)
} else if was_enum {
temp_source_code = r.insert_source_code(DeclType.enum_, r.temp_lines)
temp_source_code = r.insert_source_code(DeclType.enum, r.temp_lines)
} else if was_interface {
temp_source_code = r.insert_source_code(DeclType.interface_, r.temp_lines)
temp_source_code = r.insert_source_code(DeclType.interface, r.temp_lines)
} else {
temp_source_code = r.insert_source_code(DeclType.stmt_, r.temp_lines)
temp_source_code = r.insert_source_code(DeclType.stmt, r.temp_lines)
}
} else if starts_with_include {
temp_source_code = r.insert_source_code(DeclType.include_, [r.line])
temp_source_code = r.insert_source_code(DeclType.include, [r.line])
} else if starts_with_fn {
temp_source_code = r.insert_source_code(DeclType.fn_, [r.line])
temp_source_code = r.insert_source_code(DeclType.fn, [r.line])
} else if starts_with_const {
temp_source_code = r.insert_source_code(DeclType.const_, [r.line])
temp_source_code = r.insert_source_code(DeclType.const, [r.line])
} else if starts_with_enum {
temp_source_code = r.insert_source_code(DeclType.enum_, [r.line])
temp_source_code = r.insert_source_code(DeclType.enum, [r.line])
} else if starts_with_struct {
temp_source_code = r.insert_source_code(DeclType.struct, [r.line])
} else if starts_with_interface {
temp_source_code = r.insert_source_code(DeclType.interface_, [r.line])
temp_source_code = r.insert_source_code(DeclType.interface, [r.line])
} else if starts_with_type {
temp_source_code = r.insert_source_code(DeclType.type_, [r.line])
temp_source_code = r.insert_source_code(DeclType.type, [r.line])
} else {
temp_source_code = r.current_source_code(true, false) + '\n${r.line}\n'
}
Expand Down
4 changes: 2 additions & 2 deletions examples/2048/2048.v
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ enum TileFormat {
log
exponent
shifts
none_
none
end_ // To know when to wrap around
}

Expand Down Expand Up @@ -671,7 +671,7 @@ fn (app &App) draw_tiles() {
size: fs2
})
}
.none_ {} // Don't draw any text here, colors only
.none {} // Don't draw any text here, colors only
.end_ {} // Should never get here
}
}
Expand Down
8 changes: 4 additions & 4 deletions vlib/v/ast/ast.v
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub mut:

pub enum ComptimeTypeKind {
unknown
map_
map
int
float
struct
Expand All @@ -150,7 +150,7 @@ pub enum ComptimeTypeKind {
array_fixed
array_dynamic
sum_type
enum_
enum
alias
function
option
Expand All @@ -166,7 +166,7 @@ pub:
pub fn (cty ComptimeType) str() string {
return match cty.kind {
.unknown { '\$unknown' }
.map_ { '\$map' }
.map { '\$map' }
.int { '\$int' }
.float { '\$float' }
.struct { '\$struct' }
Expand All @@ -175,7 +175,7 @@ pub fn (cty ComptimeType) str() string {
.array_dynamic { '\$array_dynamic' }
.array_fixed { '\$array_fixed' }
.sum_type { '\$sumtype' }
.enum_ { '\$enum' }
.enum { '\$enum' }
.alias { '\$alias' }
.function { '\$function' }
.option { '\$option' }
Expand Down
12 changes: 6 additions & 6 deletions vlib/v/ast/table.v
Original file line number Diff line number Diff line change
Expand Up @@ -1386,13 +1386,13 @@ pub fn (t &Table) is_sumtype_or_in_variant(parent Type, typ Type) bool {

@[inline]
pub fn (t &Table) is_interface_var(var ScopeObject) bool {
return var is Var && var.orig_type != 0 && t.sym(var.orig_type).kind == .interface_
&& t.sym(var.smartcasts.last()).kind != .interface_
return var is Var && var.orig_type != 0 && t.sym(var.orig_type).kind == .interface
&& t.sym(var.smartcasts.last()).kind != .interface
}

@[inline]
pub fn (t &Table) is_interface_smartcast(var ScopeObject) bool {
return var is Var && var.orig_type != 0 && t.sym(var.orig_type).kind == .interface_
return var is Var && var.orig_type != 0 && t.sym(var.orig_type).kind == .interface
&& var.smartcasts.len > 0
}

Expand Down Expand Up @@ -1510,7 +1510,7 @@ pub fn (t Table) does_type_implement_interface(typ Type, inter_typ Type) bool {
}
}
mut inter_sym := t.sym(inter_typ)
if sym.kind == .interface_ && inter_sym.kind == .interface_ {
if sym.kind == .interface && inter_sym.kind == .interface {
return false
}
if mut inter_sym.info is Interface {
Expand Down Expand Up @@ -2043,7 +2043,7 @@ pub fn (mut t Table) unwrap_generic_type_ex(typ Type, generic_names []string, co
for i in 0 .. variants.len {
if variants[i].has_flag(.generic) {
sym := t.sym(variants[i])
if sym.kind in [.struct, .sum_type, .interface_] {
if sym.kind in [.struct, .sum_type, .interface] {
variants[i] = t.unwrap_generic_type(variants[i], generic_names,
concrete_types)
} else {
Expand Down Expand Up @@ -2106,7 +2106,7 @@ pub fn (mut t Table) unwrap_generic_type_ex(typ Type, generic_names []string, co
info.fields = fields
info.methods = imethods
new_idx := t.register_sym(
kind: .interface_
kind: .interface
name: nrt
cname: util.no_dots(c_nrt)
mod: ts.mod
Expand Down
Loading

0 comments on commit 5fe4a18

Please sign in to comment.