1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vfmt: enum fix

This commit is contained in:
Alexander Medvednikov 2019-12-20 02:35:07 +03:00
parent 6af54d0207
commit 00b8a5d3e4
4 changed files with 17 additions and 16 deletions

View File

@ -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() {

View File

@ -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

View File

@ -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++ {

View File

@ -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