Added permissions to analyzed sections

This commit is contained in:
Sasha Koshka 2022-10-01 17:21:17 -04:00
parent 07540e0abc
commit e2947eab8c
4 changed files with 20 additions and 5 deletions

View File

@ -187,7 +187,7 @@ func (analyzer *AnalysisOperation) resolvePrimitive (
case "U16": section = &PrimitiveU16 case "U16": section = &PrimitiveU16
case "U32": section = &PrimitiveU32 case "U32": section = &PrimitiveU32
case "U64": section = &PrimitiveU64 case "U64": section = &PrimitiveU64
case "Objt": section = &PrimitiveObjt case "Obj": section = &PrimitiveObj
case "Face": section = &PrimitiveFace case "Face": section = &PrimitiveFace
case "Func": section = &PrimitiveFunc case "Func": section = &PrimitiveFunc
case "String": section = &BuiltInString case "String": section = &BuiltInString

View File

@ -12,7 +12,7 @@ var PrimitiveU8 = createPrimitive("U8", Type {})
var PrimitiveU16 = createPrimitive("U16", Type {}) var PrimitiveU16 = createPrimitive("U16", Type {})
var PrimitiveU32 = createPrimitive("U32", Type {}) var PrimitiveU32 = createPrimitive("U32", Type {})
var PrimitiveU64 = createPrimitive("U64", Type {}) var PrimitiveU64 = createPrimitive("U64", Type {})
var PrimitiveObjt = createPrimitive("Objt", Type {}) var PrimitiveObj = createPrimitive("Obj", Type {})
var PrimitiveFace = createPrimitive("Face", Type {}) var PrimitiveFace = createPrimitive("Face", Type {})
var PrimitiveFunc = createPrimitive("Func", Type {}) var PrimitiveFunc = createPrimitive("Func", Type {})

View File

@ -3,6 +3,7 @@ package analyzer
import "os" import "os"
import "sort" import "sort"
import "path/filepath" import "path/filepath"
import "git.tebibyte.media/arf/arf/types"
// locator uniquely identifies a section in the section table. // locator uniquely identifies a section in the section table.
type locator struct { type locator struct {
@ -77,6 +78,7 @@ type Section interface {
Complete () (complete bool) Complete () (complete bool)
ModulePath () (path string) ModulePath () (path string)
ModuleName () (path string) ModuleName () (path string)
Permission () (permission types.Permission)
locator () (where locator) locator () (where locator)
// Must be implemented by each individual section // Must be implemented by each individual section
@ -85,8 +87,9 @@ type Section interface {
// sectionBase is a struct that all sections must embed. // sectionBase is a struct that all sections must embed.
type sectionBase struct { type sectionBase struct {
where locator where locator
complete bool complete bool
permission types.Permission
} }
// Name returns the name of the section. // Name returns the name of the section.
@ -113,6 +116,13 @@ func (section sectionBase) Complete () (complete bool) {
return return
} }
// Permission returns the permission of the section.
func (section sectionBase) Permission () (permission types.Permission) {
permission = section.permission
return
}
// locator returns the module path and name of the section.
func (section sectionBase) locator () (where locator) { func (section sectionBase) locator () (where locator) {
where = section.where where = section.where
return return

View File

@ -41,7 +41,10 @@ func (member ObjectMember) ToString (indent int) (output string) {
// ToString returns all data stored within the type section, in string form. // ToString returns all data stored within the type section, in string form.
func (section TypeSection) ToString (indent int) (output string) { func (section TypeSection) ToString (indent int) (output string) {
output += doIndent(indent, "typeSection ", section.where.ToString(), "\n") output += doIndent(indent, "typeSection ")
output += section.permission.ToString() + " "
output += section.where.ToString()
output += "\n"
output += section.what.ToString(indent + 1) output += section.what.ToString(indent + 1)
if section.argument != nil { if section.argument != nil {
output += section.argument.ToString(indent + 1) output += section.argument.ToString(indent + 1)
@ -68,6 +71,8 @@ func (analyzer AnalysisOperation) analyzeTypeSection () (
infoerr.ErrorKindError) infoerr.ErrorKindError)
} }
outputSection.permission = inputSection.Permission()
outputSection.what, err = analyzer.analyzeType(inputSection.Type()) outputSection.what, err = analyzer.analyzeType(inputSection.Type())
if err != nil { return } if err != nil { return }