Altered syntax tree accordingly
🦀🦀🦀 Object sections are gone 🦀🦀🦀 and members are now stored in the type specifier.
This commit is contained in:
parent
0af08a4d24
commit
3e9ff7dcd6
@ -29,12 +29,6 @@ func (section TypeSection) Kind () (kind SectionKind) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kind returns the section's kind (SectionKindObjt).
|
|
||||||
func (section ObjtSection) Kind () (kind SectionKind) {
|
|
||||||
kind = SectionKindObjt
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Kind returns the section's kind (SectionKindEnum).
|
// Kind returns the section's kind (SectionKindEnum).
|
||||||
func (section EnumSection) Kind () (kind SectionKind) {
|
func (section EnumSection) Kind () (kind SectionKind) {
|
||||||
kind = SectionKindEnum
|
kind = SectionKindEnum
|
||||||
@ -111,6 +105,26 @@ func (what Type) Points () (points Type) {
|
|||||||
return
|
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.
|
// Values returns an iterator for the initialization values.
|
||||||
func (values ObjectInitializationValues) Sections () (
|
func (values ObjectInitializationValues) Sections () (
|
||||||
iterator types.Iterator[Argument],
|
iterator types.Iterator[Argument],
|
||||||
@ -144,25 +158,6 @@ func (argument Argument) Value () (value any) {
|
|||||||
return
|
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.
|
// Length returns the amount of members in the section.
|
||||||
func (section EnumSection) Length () (length int) {
|
func (section EnumSection) Length () (length int) {
|
||||||
length = len(section.members)
|
length = len(section.members)
|
||||||
|
@ -20,7 +20,6 @@ type SectionKind int
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
SectionKindType = iota
|
SectionKindType = iota
|
||||||
SectionKindObjt
|
|
||||||
SectionKindEnum
|
SectionKindEnum
|
||||||
SectionKindFace
|
SectionKindFace
|
||||||
SectionKindData
|
SectionKindData
|
||||||
@ -59,6 +58,17 @@ const (
|
|||||||
TypeKindVariableArray
|
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 represents a type specifier
|
||||||
type Type struct {
|
type Type struct {
|
||||||
locatable
|
locatable
|
||||||
@ -72,6 +82,9 @@ type Type struct {
|
|||||||
|
|
||||||
// not applicable for basic.
|
// not applicable for basic.
|
||||||
points *Type
|
points *Type
|
||||||
|
|
||||||
|
// if non-nil, this type defines new members.
|
||||||
|
members []TypeMember
|
||||||
}
|
}
|
||||||
|
|
||||||
// Declaration represents a variable declaration.
|
// Declaration represents a variable declaration.
|
||||||
@ -173,7 +186,7 @@ type DataSection struct {
|
|||||||
external bool
|
external bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeSection represents a blind type definition.
|
// TypeSection represents a type definition.
|
||||||
type TypeSection struct {
|
type TypeSection struct {
|
||||||
locatable
|
locatable
|
||||||
nameable
|
nameable
|
||||||
@ -182,27 +195,6 @@ type TypeSection struct {
|
|||||||
valuable
|
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.
|
// EnumMember represents a member of an enum section.
|
||||||
type EnumMember struct {
|
type EnumMember struct {
|
||||||
locatable
|
locatable
|
||||||
|
Reference in New Issue
Block a user