From bc4b2bd33c5d0474f20f571c05bb4a4e69c6e734 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 5 Sep 2022 01:09:29 -0400 Subject: [PATCH] Added accessors for ObjtSection and EnumSection --- parser/accessors.go | 30 +++++++++++++++++++++++++++--- parser/tree.go | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/parser/accessors.go b/parser/accessors.go index 3b0a51a..955efdd 100644 --- a/parser/accessors.go +++ b/parser/accessors.go @@ -102,7 +102,7 @@ func (what Type) Points () (points Type) { return } -// Values returns an iterator for the initialization values +// Values returns an iterator for the initialization values. func (values ObjectInitializationValues) Sections () ( iterator types.Iterator[Argument], ) { @@ -110,13 +110,13 @@ func (values ObjectInitializationValues) Sections () ( return } -// Length returns the amount of values +// Length returns the amount of values. func (values ArrayInitializationValues) Length () (length int) { length = len(values.values) return } -// Item returns the value at index +// Item returns the value at index. func (values ArrayInitializationValues) Value (index int) (value Argument) { value = values.values[index] return @@ -141,3 +141,27 @@ func (member ObjtMember) BitWidth () (width uint64) { width = member.bitWidth return } + +// Length returns the amount of members in the section. +func (section ObjtSection) Length () (length int) { + length = len(section.members) + return +} + +// Item returns the member at index. +func (section ObjtSection) Item (index int) (member ObjtMember) { + member = section.members[index] + return +} + +// Length returns the amount of members in the section. +func (section EnumSection) Length () (length int) { + length = len(section.members) + return +} + +// Item returns the member at index. +func (section EnumSection) Item (index int) (member EnumMember) { + member = section.members[index] + return +} diff --git a/parser/tree.go b/parser/tree.go index 03a429f..bb70884 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -193,7 +193,7 @@ type ObjtMember struct { permissionable valuable - bitWidth uint64 + bitWidth uint64 } // ObjtSection represents an object type definition.