Got rid of useless setters for the traits

This commit is contained in:
Sasha Koshka 2022-09-03 22:58:35 -04:00
parent ef375810fb
commit 3f7c779e2b
8 changed files with 9 additions and 24 deletions

View File

@ -16,7 +16,7 @@ var validArgumentStartTokens = []lexer.TokenKind {
}
func (parser *ParsingOperation) parseArgument () (argument Argument, err error) {
argument.setLocation(parser.token.Location())
argument.location = parser.token.Location()
err = parser.expect(validArgumentStartTokens...)
if err != nil { return }
@ -44,8 +44,8 @@ func (parser *ParsingOperation) parseArgument () (argument Argument, err error)
declaration := Declaration { }
declaration.what = what
declaration.setName(identifier.trail[0])
declaration.setLocation(argument.Location())
declaration.name = identifier.trail[0]
declaration.location = argument.Location()
argument.kind = ArgumentKindDeclaration
argument.value = declaration

View File

@ -12,7 +12,7 @@ func (parser *ParsingOperation) parseDataSection () (
if err != nil { return }
section = &DataSection { }
section.setLocation(parser.token.Location())
section.location = parser.token.Location()
err = parser.nextToken(lexer.TokenKindPermission)
if err != nil { return }

View File

@ -12,7 +12,7 @@ func (parser *ParsingOperation) parseEnumSection () (
if err != nil { return }
section = &EnumSection { }
section.setLocation(parser.token.Location())
section.location = parser.token.Location()
// get permission
err = parser.nextToken(lexer.TokenKindPermission)

View File

@ -15,7 +15,7 @@ func (parser *ParsingOperation) parseFaceSection () (
section = &FaceSection {
behaviors: make(map[string] FaceBehavior),
}
section.setLocation(parser.token.Location())
section.location = parser.token.Location()
// get permission
err = parser.nextToken(lexer.TokenKindPermission)

View File

@ -13,7 +13,7 @@ func (parser *ParsingOperation) parseFuncSection () (
if err != nil { return }
section = &FuncSection { }
section.setLocation(parser.token.Location())
section.location = parser.token.Location()
// get permission
err = parser.nextToken(lexer.TokenKindPermission)

View File

@ -14,11 +14,6 @@ func (trait locatable) Location () (location file.Location) {
return
}
// setLocation sets the location of the node.
func (trait* locatable) setLocation (location file.Location) {
trait.location = location
}
// NewError creates a new error at the node's location.
func (trait locatable) NewError (
message string,
@ -39,11 +34,6 @@ func (trait nameable) Name () (name string) {
name = trait.name
return
}
// setName sets the name of the node.
func (trait *nameable) setName (name string) {
trait.name = name
}
// typeable allows a node to have a type.
type typeable struct {
what Type
@ -53,8 +43,3 @@ type typeable struct {
func (trait typeable) Type () (what Type) {
return trait.what
}
// setType sets the type of the node.
func (trait *typeable) setType (what Type) () {
}

View File

@ -14,7 +14,7 @@ func (parser *ParsingOperation) parseObjtSection () (
if err != nil { return }
section = &ObjtSection { }
section.setLocation(parser.token.Location())
section.location = parser.token.Location()
// get permission
err = parser.nextToken(lexer.TokenKindPermission)

View File

@ -14,7 +14,7 @@ func (parser *ParsingOperation) parseTypeSection () (
if err != nil { return }
section = &TypeSection { }
section.setLocation(parser.token.Location())
section.location = parser.token.Location()
// get permission
err = parser.nextToken(lexer.TokenKindPermission)