Altered syntax tree accordingly

🦀🦀🦀 Object sections are gone 🦀🦀🦀 and members are now stored
in the type specifier.
This commit is contained in:
Sasha Koshka 2022-09-11 16:15:02 -04:00
parent 0af08a4d24
commit 3e9ff7dcd6
2 changed files with 35 additions and 48 deletions

View File

@ -29,12 +29,6 @@ func (section TypeSection) Kind () (kind SectionKind) {
return
}
// Kind returns the section's kind (SectionKindObjt).
func (section ObjtSection) Kind () (kind SectionKind) {
kind = SectionKindObjt
return
}
// Kind returns the section's kind (SectionKindEnum).
func (section EnumSection) Kind () (kind SectionKind) {
kind = SectionKindEnum
@ -111,6 +105,26 @@ func (what Type) Points () (points Type) {
return
}
// MembersLength returns the amount of new members the type specifier defines.
// If it defines no new members, it returns zero.
func (what Type) MembersLength () (length int) {
length = len(what.members)
return
}
// Member returns the member at index.
func (what Type) Member (index int) (member TypeMember) {
member = what.members[index]
return
}
// BitWidth returns the bit width of the type member. If it is zero, it should
// be treated as unspecified.
func (member TypeMember) BitWidth () (width uint64) {
width = member.bitWidth
return
}
// Values returns an iterator for the initialization values.
func (values ObjectInitializationValues) Sections () (
iterator types.Iterator[Argument],
@ -144,25 +158,6 @@ func (argument Argument) Value () (value any) {
return
}
// BitWidth returns the bit width of the object member. If it is zero, it should
// be treated as unspecified.
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)

View File

@ -20,7 +20,6 @@ type SectionKind int
const (
SectionKindType = iota
SectionKindObjt
SectionKindEnum
SectionKindFace
SectionKindData
@ -59,6 +58,17 @@ const (
TypeKindVariableArray
)
// TypeMember represents a member variable of a type specifier.
type TypeMember struct {
locatable
nameable
typeable
permissionable
valuable
bitWidth uint64
}
// Type represents a type specifier
type Type struct {
locatable
@ -72,6 +82,9 @@ type Type struct {
// not applicable for basic.
points *Type
// if non-nil, this type defines new members.
members []TypeMember
}
// Declaration represents a variable declaration.
@ -173,7 +186,7 @@ type DataSection struct {
external bool
}
// TypeSection represents a blind type definition.
// TypeSection represents a type definition.
type TypeSection struct {
locatable
nameable
@ -182,27 +195,6 @@ type TypeSection struct {
valuable
}
// ObjtMember represents a part of an object type definition.
type ObjtMember struct {
locatable
nameable
typeable
permissionable
valuable
bitWidth uint64
}
// ObjtSection represents an object type definition.
type ObjtSection struct {
locatable
nameable
permissionable
inherits Identifier
members []ObjtMember
}
// EnumMember represents a member of an enum section.
type EnumMember struct {
locatable