Some stuff on the func sections babey
This commit is contained in:
parent
a9a1c6ae9b
commit
5641220986
@ -131,6 +131,8 @@ func (analyzer *analysisOperation) fetchSection (
|
|||||||
section, err = analyzer.analyzeDataSection()
|
section, err = analyzer.analyzeDataSection()
|
||||||
if err != nil { return}
|
if err != nil { return}
|
||||||
case parser.FuncSection:
|
case parser.FuncSection:
|
||||||
|
section, err = analyzer.analyzeFuncSection()
|
||||||
|
if err != nil { return}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -1,14 +1,60 @@
|
|||||||
package analyzer
|
package analyzer
|
||||||
|
|
||||||
|
import "git.tebibyte.media/arf/arf/types"
|
||||||
|
import "git.tebibyte.media/arf/arf/parser"
|
||||||
|
import "git.tebibyte.media/arf/arf/infoerr"
|
||||||
|
|
||||||
// FuncSection represents a type definition section.
|
// FuncSection represents a type definition section.
|
||||||
type FuncSection struct {
|
type FuncSection struct {
|
||||||
sectionBase
|
sectionBase
|
||||||
external bool
|
external bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToString returns all data stored within the function section, in string form.
|
||||||
|
func (section FuncSection) ToString (indent int) (output string) {
|
||||||
|
output += doIndent(indent, "funcSection ")
|
||||||
|
output += section.permission.ToString() + " "
|
||||||
|
output += section.where.ToString()
|
||||||
|
output += "\n"
|
||||||
|
|
||||||
|
// TODO: arguments
|
||||||
|
// TODO: root block
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// analyzeFuncSection analyzes a function section.
|
||||||
func (analyzer *analysisOperation) analyzeFuncSection () (
|
func (analyzer *analysisOperation) analyzeFuncSection () (
|
||||||
section Section,
|
section Section,
|
||||||
err error,
|
err error,
|
||||||
) {
|
) {
|
||||||
|
outputSection := FuncSection { }
|
||||||
|
outputSection.where = analyzer.currentPosition
|
||||||
|
|
||||||
|
section = &outputSection
|
||||||
|
analyzer.addSection(section)
|
||||||
|
|
||||||
|
inputSection := analyzer.currentSection.(parser.FuncSection)
|
||||||
|
outputSection.location = analyzer.currentSection.Location()
|
||||||
|
|
||||||
|
// TODO: do not do this if it is a method
|
||||||
|
if inputSection.Permission() == types.PermissionReadWrite {
|
||||||
|
err = inputSection.NewError (
|
||||||
|
"read-write (rw) permission not understood in this " +
|
||||||
|
"context, try read-only (ro)",
|
||||||
|
infoerr.ErrorKindError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
outputSection.permission = inputSection.Permission()
|
||||||
|
|
||||||
|
// TODO: analyze inputs and outputs and reciever
|
||||||
|
|
||||||
|
if inputSection.External() {
|
||||||
|
outputSection.external = true
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// TODO: analyze root block if not nil
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@ import "testing"
|
|||||||
|
|
||||||
func TestFuncSection (test *testing.T) {
|
func TestFuncSection (test *testing.T) {
|
||||||
checkTree ("../tests/analyzer/funcSection", false,
|
checkTree ("../tests/analyzer/funcSection", false,
|
||||||
`
|
`typeSection ro ../tests/analyzer/funcSection.aCString
|
||||||
typeSection ro ../tests/analyzer/funcSection.aCString
|
|
||||||
type 1 pointer {
|
type 1 pointer {
|
||||||
type 1 basic U8
|
type 1 basic U8
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user