Permissions of sections in other modules are respected
This commit is contained in:
parent
15fa122547
commit
aaf268d0d1
@ -136,22 +136,25 @@ func (analyzer *analysisOperation) fetchSection (
|
|||||||
// of whatever module is currently being analyzed. The identifier in question
|
// of whatever module is currently being analyzed. The identifier in question
|
||||||
// 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. If the section comes from a different module (and permissions
|
||||||
|
// should therefore be respected), external will be set to true.
|
||||||
func (analyzer *analysisOperation) fetchSectionFromIdentifier (
|
func (analyzer *analysisOperation) fetchSectionFromIdentifier (
|
||||||
which parser.Identifier,
|
which parser.Identifier,
|
||||||
) (
|
) (
|
||||||
section Section,
|
section Section,
|
||||||
bitten parser.Identifier,
|
external bool,
|
||||||
err error,
|
bitten parser.Identifier,
|
||||||
|
err error,
|
||||||
) {
|
) {
|
||||||
item, bitten := which.Bite()
|
item, bitten := which.Bite()
|
||||||
|
|
||||||
path, exists := analyzer.currentTree.ResolveRequire(item)
|
path, exists := analyzer.currentTree.ResolveRequire(item)
|
||||||
if exists {
|
if exists {
|
||||||
// we have our module path, so get the section name
|
// we have our module path, so get the section name
|
||||||
item, bitten = bitten.Bite()
|
item, bitten = bitten.Bite()
|
||||||
|
external = true
|
||||||
} else {
|
} else {
|
||||||
// that wasn't a module name, so the module path must be the our
|
// that wasn't a module name, so the module path must be our
|
||||||
// current one
|
// current one
|
||||||
path = analyzer.currentPosition.modulePath
|
path = analyzer.currentPosition.modulePath
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package analyzer
|
package analyzer
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
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"
|
import "git.tebibyte.media/arf/arf/infoerr"
|
||||||
|
|
||||||
@ -185,15 +186,19 @@ func (analyzer analysisOperation) analyzeType (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// analyze type this type points to, if it exists
|
|
||||||
if inputType.Kind() != parser.TypeKindBasic {
|
if inputType.Kind() != parser.TypeKindBasic {
|
||||||
|
// analyze type this type points to, if it exists
|
||||||
var points Type
|
var points Type
|
||||||
points, err = analyzer.analyzeType(inputType.Points())
|
points, err = analyzer.analyzeType(inputType.Points())
|
||||||
outputType.points = &points
|
outputType.points = &points
|
||||||
} else {
|
} else {
|
||||||
|
// analyze the type section this type uses
|
||||||
var bitten parser.Identifier
|
var bitten parser.Identifier
|
||||||
|
var external bool
|
||||||
var actual Section
|
var actual Section
|
||||||
|
|
||||||
actual,
|
actual,
|
||||||
|
external,
|
||||||
bitten,
|
bitten,
|
||||||
err = analyzer.fetchSectionFromIdentifier(inputType.Name())
|
err = analyzer.fetchSectionFromIdentifier(inputType.Name())
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
@ -213,6 +218,14 @@ func (analyzer analysisOperation) analyzeType (
|
|||||||
infoerr.ErrorKindError)
|
infoerr.ErrorKindError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if external && actual.Permission() == types.PermissionPrivate {
|
||||||
|
err = bitten.NewError(
|
||||||
|
"this type is private, and cannot be used " +
|
||||||
|
"outside of its module",
|
||||||
|
infoerr.ErrorKindError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if bitten.Length() > 0 {
|
if bitten.Length() > 0 {
|
||||||
err = bitten.NewError(
|
err = bitten.NewError(
|
||||||
@ -223,6 +236,7 @@ func (analyzer analysisOperation) analyzeType (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
// TODO: figure out what todo ???
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user