From e2947eab8c5da27cbabaf52135556d24b8bcf217 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 1 Oct 2022 17:21:17 -0400 Subject: [PATCH] Added permissions to analyzed sections --- analyzer/analyzer.go | 2 +- analyzer/primitives.go | 2 +- analyzer/table.go | 14 ++++++++++++-- analyzer/type-section.go | 7 ++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/analyzer/analyzer.go b/analyzer/analyzer.go index 7c90066..953697f 100644 --- a/analyzer/analyzer.go +++ b/analyzer/analyzer.go @@ -187,7 +187,7 @@ func (analyzer *AnalysisOperation) resolvePrimitive ( case "U16": section = &PrimitiveU16 case "U32": section = &PrimitiveU32 case "U64": section = &PrimitiveU64 - case "Objt": section = &PrimitiveObjt + case "Obj": section = &PrimitiveObj case "Face": section = &PrimitiveFace case "Func": section = &PrimitiveFunc case "String": section = &BuiltInString diff --git a/analyzer/primitives.go b/analyzer/primitives.go index adf2a2f..2b10afb 100644 --- a/analyzer/primitives.go +++ b/analyzer/primitives.go @@ -12,7 +12,7 @@ var PrimitiveU8 = createPrimitive("U8", Type {}) var PrimitiveU16 = createPrimitive("U16", Type {}) var PrimitiveU32 = createPrimitive("U32", Type {}) var PrimitiveU64 = createPrimitive("U64", Type {}) -var PrimitiveObjt = createPrimitive("Objt", Type {}) +var PrimitiveObj = createPrimitive("Obj", Type {}) var PrimitiveFace = createPrimitive("Face", Type {}) var PrimitiveFunc = createPrimitive("Func", Type {}) diff --git a/analyzer/table.go b/analyzer/table.go index 709be85..b0732c1 100644 --- a/analyzer/table.go +++ b/analyzer/table.go @@ -3,6 +3,7 @@ package analyzer import "os" import "sort" import "path/filepath" +import "git.tebibyte.media/arf/arf/types" // locator uniquely identifies a section in the section table. type locator struct { @@ -77,6 +78,7 @@ type Section interface { Complete () (complete bool) ModulePath () (path string) ModuleName () (path string) + Permission () (permission types.Permission) locator () (where locator) // Must be implemented by each individual section @@ -85,8 +87,9 @@ type Section interface { // sectionBase is a struct that all sections must embed. type sectionBase struct { - where locator - complete bool + where locator + complete bool + permission types.Permission } // Name returns the name of the section. @@ -113,6 +116,13 @@ func (section sectionBase) Complete () (complete bool) { 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) { where = section.where return diff --git a/analyzer/type-section.go b/analyzer/type-section.go index 3b757d6..39f027f 100644 --- a/analyzer/type-section.go +++ b/analyzer/type-section.go @@ -41,7 +41,10 @@ func (member ObjectMember) ToString (indent int) (output string) { // ToString returns all data stored within the type section, in string form. 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) if section.argument != nil { output += section.argument.ToString(indent + 1) @@ -68,6 +71,8 @@ func (analyzer AnalysisOperation) analyzeTypeSection () ( infoerr.ErrorKindError) } + outputSection.permission = inputSection.Permission() + outputSection.what, err = analyzer.analyzeType(inputSection.Type()) if err != nil { return }