From 00b8a5d3e4794d3e704757c4cd73077a659aa8fa Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 20 Dec 2019 02:35:07 +0300 Subject: [PATCH] vfmt: enum fix --- vlib/compiler/enum.v | 7 +++++-- vlib/compiler/msvc.v | 2 +- vlib/compiler/token.v | 2 -- vlib/compiler/x64/elf_obj.v | 22 +++++++++++----------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/vlib/compiler/enum.v b/vlib/compiler/enum.v index c4ee8779d5..317397f377 100644 --- a/vlib/compiler/enum.v +++ b/vlib/compiler/enum.v @@ -35,12 +35,13 @@ fn (p mut Parser) enum_decl(no_name bool) { p.warn('enum values cannot contain uppercase letters, use snake_case instead') } fields << field - p.fgen_nl() name := '${mod_gen_name(p.mod)}__${enum_name}_$field' if p.tok == .assign { + p.fspace() mut enum_assign_tidx := p.cur_tok_index() if p.peek() == .number { p.next() + p.fspace() val = p.lit.int() p.next() } @@ -56,6 +57,7 @@ fn (p mut Parser) enum_decl(no_name bool) { if p.tok == .comma { p.next() } + p.fgen_nl() val++ } is_flag := p.attr == 'flag' @@ -76,7 +78,8 @@ fn (p mut Parser) enum_decl(no_name bool) { } p.table.register_type(T) p.check(.rcbr) - p.fgenln('\n') + p.fgen_nl() + p.fgen_nl() } fn (p mut Parser) check_enum_member_access() { diff --git a/vlib/compiler/msvc.v b/vlib/compiler/msvc.v index 878ac425fe..24539e214a 100644 --- a/vlib/compiler/msvc.v +++ b/vlib/compiler/msvc.v @@ -16,8 +16,8 @@ struct MsvcResult { vs_include_path string shared_include_path string } -// shell32 for RegOpenKeyExW etc +// shell32 for RegOpenKeyExW etc // Mimics a HKEY type RegKey voidptr // Taken from the windows SDK diff --git a/vlib/compiler/token.v b/vlib/compiler/token.v index 4487b877a6..5e078d4ec2 100644 --- a/vlib/compiler/token.v +++ b/vlib/compiler/token.v @@ -123,8 +123,6 @@ enum TokenKind { // build_keys genereates a map with keywords' string values: // Keywords['return'] == .key_return - - fn build_keys() map[string]int { mut res := map[string]int for t := int(TokenKind.keyword_beg) + 1; t < int(TokenKind.keyword_end); t++ { diff --git a/vlib/compiler/x64/elf_obj.v b/vlib/compiler/x64/elf_obj.v index 832dc8a92f..e1f90de6a5 100644 --- a/vlib/compiler/x64/elf_obj.v +++ b/vlib/compiler/x64/elf_obj.v @@ -11,12 +11,12 @@ But it will be necessary once we have dynamic linking. enum SectionType { - null - =0progbits - =1symtab - =2strtab - =3rela - =4} + null = 0 + progbits = 1 + symtab = 2 + strtab = 3 + rela = 4 +} struct SectionConfig { name string @@ -62,7 +62,7 @@ fn genobj() { align:0 entsize: 0 }) - + /* for sect in sections { g.section_header(SectionConfig{ @@ -77,10 +77,10 @@ fn genobj() { align: sect.align entsize: sect.entsize }) - - } + + } */ - + g.section_header(SectionConfig{ name: '.DATA' typ: .progbits @@ -93,7 +93,7 @@ fn genobj() { align: 1 entsize: 0 }) - + g.section_header(SectionConfig{ name: '.TEXT' typ: .progbits