Added trail stack
This commit is contained in:
parent
5f3c5e3b14
commit
cc8ae6c124
@ -2,15 +2,16 @@ package analyzer
|
|||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
import "path/filepath"
|
import "path/filepath"
|
||||||
|
import "git.tebibyte.media/arf/arf/types"
|
||||||
import "git.tebibyte.media/arf/arf/parser"
|
import "git.tebibyte.media/arf/arf/parser"
|
||||||
|
import "git.tebibyte.media/arf/arf/infoerr"
|
||||||
|
|
||||||
// AnalysisOperation holds information about an ongoing analysis operation.
|
// AnalysisOperation holds information about an ongoing analysis operation.
|
||||||
type AnalysisOperation struct {
|
type AnalysisOperation struct {
|
||||||
sectionTable SectionTable
|
sectionTable SectionTable
|
||||||
modulePath string
|
modulePath string
|
||||||
|
|
||||||
// TODO: create trail stack to setect and prevent dependency cycles
|
trail types.Stack[locator]
|
||||||
// between sections
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Analyze performs a semantic analyisys on the module specified by path, and
|
// Analyze performs a semantic analyisys on the module specified by path, and
|
||||||
@ -77,6 +78,20 @@ func (analyzer *AnalysisOperation) fetchSection (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this does not take into account, for instance, recursive
|
||||||
|
// functions or objects that have pointers to themselves.
|
||||||
|
for _, plate := range analyzer.trail {
|
||||||
|
if plate == where {
|
||||||
|
parsedSection.NewError (
|
||||||
|
"cannot have cyclic section dependency",
|
||||||
|
infoerr.ErrorKindError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
analyzer.trail.Push(where)
|
||||||
|
defer analyzer.trail.Pop()
|
||||||
|
|
||||||
// TODO: analyze section
|
// TODO: analyze section
|
||||||
switch parsedSection.Kind() {
|
switch parsedSection.Kind() {
|
||||||
case parser.SectionKindType:
|
case parser.SectionKindType:
|
||||||
|
Reference in New Issue
Block a user