From 23072b54764153a23e14a0eef9511680bc07fe0d Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 29 Sep 2022 02:10:58 -0400 Subject: [PATCH] Type members actually get ToString'd now --- parser/tree-tostring.go | 43 ++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 68bb4ce..15e4ec2 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -66,24 +66,6 @@ func (identifier Identifier) ToString () (output string) { return } -func (member TypeSectionMember) ToString (indent int, breakLine bool) (output string) { - output += doIndent(indent, ".") - - output += member.permission.ToString() + " " - output += member.name + ":" - output += member.what.ToString() - - if member.bitWidth > 0 { - output += fmt.Sprint(" & ", member.bitWidth) - } - - if breakLine { - output += "\n" - } - - return -} - func (what Type) ToString () (output string) { if what.kind == TypeKindNil { output += "NIL-TYPE" @@ -202,6 +184,27 @@ func (section DataSection) ToString (indent int) (output string) { return } +func (member TypeSectionMember) ToString (indent int) (output string) { + output += doIndent(indent, member.permission.ToString()) + + if member.what.kind != TypeKindNil { + output += " " + member.name + ":" + output += member.what.ToString() + } + + if member.argument.kind != ArgumentKindNil { + output += " " + member.argument.ToString(indent, false) + } + + if member.bitWidth > 0 { + output += fmt.Sprint(" & ", member.bitWidth) + } + + output += "\n" + + return +} + func (section TypeSection) ToString (indent int) (output string) { output += doIndent ( indent, @@ -213,6 +216,10 @@ func (section TypeSection) ToString (indent int) (output string) { if section.argument.kind != ArgumentKindNil { output += section.argument.ToString(indent + 1, true) } + + for _, member := range section.members { + output += member.ToString(indent + 1) + } return }