Privated analysisOperation
This commit is contained in:
parent
1924892ab6
commit
89b432c6fd
@ -6,8 +6,8 @@ import "path/filepath"
|
|||||||
import "git.tebibyte.media/arf/arf/parser"
|
import "git.tebibyte.media/arf/arf/parser"
|
||||||
import "git.tebibyte.media/arf/arf/infoerr"
|
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
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ func Analyze (modulePath string, skim bool) (table SectionTable, err error) {
|
|||||||
modulePath = filepath.Join(cwd, modulePath)
|
modulePath = filepath.Join(cwd, modulePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
analyzer := AnalysisOperation {
|
analyzer := analysisOperation {
|
||||||
sectionTable: make(SectionTable),
|
sectionTable: make(SectionTable),
|
||||||
modulePath: modulePath,
|
modulePath: modulePath,
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ func Analyze (modulePath string, skim bool) (table SectionTable, err error) {
|
|||||||
|
|
||||||
// analyze performs an analysis operation given the state of the operation
|
// analyze performs an analysis operation given the state of the operation
|
||||||
// struct.
|
// struct.
|
||||||
func (analyzer *AnalysisOperation) analyze () (err error) {
|
func (analyzer *analysisOperation) analyze () (err error) {
|
||||||
tree, err := parser.Fetch(analyzer.modulePath, false)
|
tree, err := parser.Fetch(analyzer.modulePath, false)
|
||||||
sections := tree.Sections()
|
sections := tree.Sections()
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ func (analyzer *AnalysisOperation) analyze () (err error) {
|
|||||||
// been analyzed, it analyzes it first. If the section does not actually exist,
|
// been analyzed, it analyzes it first. If the section does not actually exist,
|
||||||
// a nil section is returned. When this happens, an error should be created on
|
// a nil section is returned. When this happens, an error should be created on
|
||||||
// whatever syntax tree node "requested" the section be analyzed.
|
// whatever syntax tree node "requested" the section be analyzed.
|
||||||
func (analyzer *AnalysisOperation) fetchSection (
|
func (analyzer *analysisOperation) fetchSection (
|
||||||
where locator,
|
where locator,
|
||||||
) (
|
) (
|
||||||
section Section,
|
section Section,
|
||||||
@ -123,7 +123,7 @@ func (analyzer *AnalysisOperation) fetchSection (
|
|||||||
// may have more items than 1 or 2, but those will be ignored. This method
|
// may have more items than 1 or 2, but those will be ignored. This method
|
||||||
// "consumes" items from the identifier, it will return an identifier without
|
// "consumes" items from the identifier, it will return an identifier without
|
||||||
// those items.
|
// those items.
|
||||||
func (analyzer *AnalysisOperation) fetchSectionFromIdentifier (
|
func (analyzer *analysisOperation) fetchSectionFromIdentifier (
|
||||||
which parser.Identifier,
|
which parser.Identifier,
|
||||||
) (
|
) (
|
||||||
section Section,
|
section Section,
|
||||||
@ -162,7 +162,7 @@ func (analyzer *AnalysisOperation) fetchSectionFromIdentifier (
|
|||||||
// resolvePrimitive checks to see if the locator is in the current module, and
|
// resolvePrimitive checks to see if the locator is in the current module, and
|
||||||
// refers to a primitive. If it does, it returns a pointer to that primitive
|
// refers to a primitive. If it does, it returns a pointer to that primitive
|
||||||
// and true for exists. If it doesn't, it returns nil and false.
|
// and true for exists. If it doesn't, it returns nil and false.
|
||||||
func (analyzer *AnalysisOperation) resolvePrimitive (
|
func (analyzer *analysisOperation) resolvePrimitive (
|
||||||
where locator,
|
where locator,
|
||||||
) (
|
) (
|
||||||
section Section,
|
section Section,
|
||||||
@ -201,7 +201,7 @@ func (analyzer *AnalysisOperation) resolvePrimitive (
|
|||||||
// addSection adds a section to the analyzer's section table. If a section with
|
// addSection adds a section to the analyzer's section table. If a section with
|
||||||
// that name already exists, it panics because the parser should not have given
|
// that name already exists, it panics because the parser should not have given
|
||||||
// that to us.
|
// that to us.
|
||||||
func (analyzer *AnalysisOperation) addSection (section Section) {
|
func (analyzer *analysisOperation) addSection (section Section) {
|
||||||
_, exists := analyzer.sectionTable[section.locator()]
|
_, exists := analyzer.sectionTable[section.locator()]
|
||||||
if exists {
|
if exists {
|
||||||
panic (
|
panic (
|
||||||
@ -215,7 +215,7 @@ func (analyzer *AnalysisOperation) addSection (section Section) {
|
|||||||
// typeCheck checks to see if source can fit as an argument into a slot of type
|
// typeCheck checks to see if source can fit as an argument into a slot of type
|
||||||
// destination. If it can, it retunrs nil. If it can't, it returns an error
|
// destination. If it can, it retunrs nil. If it can't, it returns an error
|
||||||
// explaining why.
|
// explaining why.
|
||||||
func (analyzer *AnalysisOperation) typeCheck (
|
func (analyzer *analysisOperation) typeCheck (
|
||||||
source Argument,
|
source Argument,
|
||||||
destination Type,
|
destination Type,
|
||||||
) (
|
) (
|
||||||
|
@ -53,7 +53,7 @@ type Argument interface {
|
|||||||
// length is 1
|
// length is 1
|
||||||
|
|
||||||
// analyzeArgument analyzes an argument
|
// analyzeArgument analyzes an argument
|
||||||
func (analyzer AnalysisOperation) analyzeArgument (
|
func (analyzer analysisOperation) analyzeArgument (
|
||||||
inputArgument parser.Argument,
|
inputArgument parser.Argument,
|
||||||
) (
|
) (
|
||||||
outputArgument Argument,
|
outputArgument Argument,
|
||||||
|
@ -53,7 +53,7 @@ func (section TypeSection) ToString (indent int) (output string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// analyzeTypeSection analyzes a type section.
|
// analyzeTypeSection analyzes a type section.
|
||||||
func (analyzer AnalysisOperation) analyzeTypeSection () (
|
func (analyzer analysisOperation) analyzeTypeSection () (
|
||||||
section Section,
|
section Section,
|
||||||
err error,
|
err error,
|
||||||
) {
|
) {
|
||||||
|
@ -169,7 +169,7 @@ func (what Type) reduce () (reduced Type, reducible bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// analyzeType analyzes a type specifier.
|
// analyzeType analyzes a type specifier.
|
||||||
func (analyzer AnalysisOperation) analyzeType (
|
func (analyzer analysisOperation) analyzeType (
|
||||||
inputType parser.Type,
|
inputType parser.Type,
|
||||||
) (
|
) (
|
||||||
outputType Type,
|
outputType Type,
|
||||||
|
Reference in New Issue
Block a user