Added method to figure out if a type has a particular member

This commit is contained in:
Sasha Koshka 2022-10-12 02:57:18 -04:00
parent 2a8476282e
commit 32faab8b36
2 changed files with 33 additions and 7 deletions

View File

@ -185,10 +185,3 @@ func (literal StringLiteral) canBePassedAs (what Type) (allowed bool) {
}
return
}
// ToString outputs the data in the argument as a string.
func (literal RuneLiteral) ToString (indent int) (output string) {
output += doIndent(indent, fmt.Sprint("arg rune '", literal.value, "'\n"))
return
}

View File

@ -52,6 +52,39 @@ func (section TypeSection) ToString (indent int) (output string) {
return
}
// Member returns the membrs ksdn ,mn ,mxc lkzxjclkjxzc l,mnzc .,zxmn.,zxmc
// IT RECURSES!
func (section TypeSection) Member (
name string,
) (
member ObjectMember,
exists bool,
) {
switch section.what.kind {
case TypeKindBasic:
for _, currentMember := range section.members {
if currentMember.name == name {
member = currentMember
exists = true
break
}
}
if !exists {
actual := section.what.actual
if actual == nil { return }
member, exists = actual.Member(name)
}
case TypeKindPointer:
points := section.what.points
if points == nil { return }
member, exists = points.actual.Member(name)
}
return
}
// analyzeTypeSection analyzes a type section.
func (analyzer analysisOperation) analyzeTypeSection () (
section Section,