mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: volatile globals
This commit is contained in:
parent
0dff050735
commit
3b36f16365
@ -663,6 +663,7 @@ pub:
|
|||||||
pos token.Pos
|
pos token.Pos
|
||||||
typ_pos token.Pos
|
typ_pos token.Pos
|
||||||
is_markused bool // an explict `[markused]` tag; the global will NOT be removed by `-skip-unused`
|
is_markused bool // an explict `[markused]` tag; the global will NOT be removed by `-skip-unused`
|
||||||
|
is_volatile bool
|
||||||
pub mut:
|
pub mut:
|
||||||
expr Expr
|
expr Expr
|
||||||
typ Type
|
typ Type
|
||||||
|
@ -4417,7 +4417,8 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
|
|||||||
g.definitions.writeln('$fn_type_name = ${g.table.sym(field.typ).name}; // global2')
|
g.definitions.writeln('$fn_type_name = ${g.table.sym(field.typ).name}; // global2')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
g.definitions.write_string('$visibility_kw$styp $attributes $field.name')
|
modifier := if field.is_volatile { ' volatile ' } else { '' }
|
||||||
|
g.definitions.write_string('$visibility_kw$modifier$styp $attributes $field.name')
|
||||||
if field.has_expr || cinit {
|
if field.has_expr || cinit {
|
||||||
if g.pref.translated {
|
if g.pref.translated {
|
||||||
g.definitions.write_string(' = ${g.expr_string(field.expr)}')
|
g.definitions.write_string(' = ${g.expr_string(field.expr)}')
|
||||||
|
@ -3364,6 +3364,10 @@ fn (mut p Parser) global_decl() ast.GlobalDecl {
|
|||||||
mut comments := []ast.Comment{}
|
mut comments := []ast.Comment{}
|
||||||
for {
|
for {
|
||||||
comments = p.eat_comments()
|
comments = p.eat_comments()
|
||||||
|
is_volatile := p.tok.kind == .key_volatile
|
||||||
|
if is_volatile {
|
||||||
|
p.next()
|
||||||
|
}
|
||||||
if is_block && p.tok.kind == .eof {
|
if is_block && p.tok.kind == .eof {
|
||||||
p.error('unexpected eof, expecting `)`')
|
p.error('unexpected eof, expecting `)`')
|
||||||
return ast.GlobalDecl{}
|
return ast.GlobalDecl{}
|
||||||
@ -3416,6 +3420,7 @@ fn (mut p Parser) global_decl() ast.GlobalDecl {
|
|||||||
typ: typ
|
typ: typ
|
||||||
comments: comments
|
comments: comments
|
||||||
is_markused: is_markused
|
is_markused: is_markused
|
||||||
|
is_volatile: is_volatile
|
||||||
}
|
}
|
||||||
fields << field
|
fields << field
|
||||||
p.table.global_scope.register(field)
|
p.table.global_scope.register(field)
|
||||||
|
Loading…
Reference in New Issue
Block a user