v2: distinguish public and private constants
parent
46ec400cb3
commit
ca9fa6407f
|
@ -89,6 +89,7 @@ pub struct ConstDecl {
|
||||||
pub:
|
pub:
|
||||||
fields []Field
|
fields []Field
|
||||||
exprs []Expr
|
exprs []Expr
|
||||||
|
is_pub bool
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StructDecl {
|
pub struct StructDecl {
|
||||||
|
|
|
@ -127,6 +127,9 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast.ConstDecl {
|
ast.ConstDecl {
|
||||||
|
if it.is_pub {
|
||||||
|
f.write('pub ')
|
||||||
|
}
|
||||||
f.writeln('const (')
|
f.writeln('const (')
|
||||||
f.indent++
|
f.indent++
|
||||||
for i, field in it.fields {
|
for i, field in it.fields {
|
||||||
|
|
|
@ -18,6 +18,10 @@ const (
|
||||||
pi = 3.14
|
pi = 3.14
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pub const (
|
||||||
|
i_am_pub_const = true
|
||||||
|
)
|
||||||
|
|
||||||
struct User {
|
struct User {
|
||||||
name string
|
name string
|
||||||
age int
|
age int
|
||||||
|
|
|
@ -19,6 +19,10 @@ const (
|
||||||
pi=3.14
|
pi=3.14
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pub const (
|
||||||
|
i_am_pub_const=true
|
||||||
|
)
|
||||||
|
|
||||||
struct User {
|
struct User {
|
||||||
name string
|
name string
|
||||||
age int
|
age int
|
||||||
|
|
|
@ -1369,6 +1369,7 @@ fn (p mut Parser) const_decl() ast.ConstDecl {
|
||||||
return ast.ConstDecl{
|
return ast.ConstDecl{
|
||||||
fields: fields
|
fields: fields
|
||||||
exprs: exprs
|
exprs: exprs
|
||||||
|
is_pub: is_pub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue