diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-03-02 11:49:19 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-03-05 12:10:27 +0100 |
| commit | 5110ff445ddb5a09a13e17b187c06d2dc3a7d52a (patch) | |
| tree | 4a482d23c3e284e996539a1677dee246e9e7b0a5 /pkg/ast/format.go | |
| parent | db01d57e9144125b368d14815d08e897ff496604 (diff) | |
pkg/compiler: switch attributes from Ident to Type
This allows parametrized attributes like size[10].
But this is not used for now.
Diffstat (limited to 'pkg/ast/format.go')
| -rw-r--r-- | pkg/ast/format.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pkg/ast/format.go b/pkg/ast/format.go index a7e0f568f..cf7edf975 100644 --- a/pkg/ast/format.go +++ b/pkg/ast/format.go @@ -68,7 +68,7 @@ func (res *Resource) serialize(w io.Writer) { } func (typedef *TypeDef) serialize(w io.Writer) { - fmt.Fprintf(w, "type %v%v", typedef.Name.Name, fmtIdentList(typedef.Args, false)) + fmt.Fprintf(w, "type %v%v", typedef.Name.Name, fmtIdentList(typedef.Args)) if typedef.Type != nil { fmt.Fprintf(w, " %v\n", fmtType(typedef.Type)) } @@ -120,7 +120,11 @@ func (str *Struct) serialize(w io.Writer) { for _, com := range str.Comments { fmt.Fprintf(w, "#%v\n", com.Text) } - fmt.Fprintf(w, "%c%v\n", closing, fmtIdentList(str.Attrs, true)) + fmt.Fprintf(w, "%c", closing) + if attrs := fmtTypeList(str.Attrs); attrs != "" { + fmt.Fprintf(w, " %v", attrs) + } + fmt.Fprintf(w, "\n") } func (flags *IntFlags) serialize(w io.Writer) { @@ -182,14 +186,11 @@ func fmtTypeList(args []*Type) string { return w.String() } -func fmtIdentList(args []*Ident, space bool) string { +func fmtIdentList(args []*Ident) string { if len(args) == 0 { return "" } w := new(bytes.Buffer) - if space { - fmt.Fprintf(w, " ") - } fmt.Fprintf(w, "[") for i, arg := range args { fmt.Fprintf(w, "%v%v", comma(i, ""), arg.Name) |
