semantics

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package semantics provides the derived semantic model that validation depth-C constraint checks rely on: a specialization/typing graph (with cycle detection), and — in later increments — inherited-member resolution, multiplicity extraction, and a bounded model-level expression evaluator.

All results are memoized in side tables keyed by *symbols.Symbol, consistent with the project rule that semantic information lives outside the immutable AST. A Model is built per resolution session over an existing symbol index and name resolver.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrArithmeticDomain reports operands an operation is not defined for, such
	// as a negative base raised to a fractional exponent.
	ErrArithmeticDomain = errors.New("arithmetic domain error")

	// ErrArithmeticOverflow reports a result outside the range of the kind it
	// would have: an Integer that does not fit int64, or a non-finite Real.
	ErrArithmeticOverflow = errors.New("arithmetic overflow")

	// ErrRealNotation reports text that is not decimal Real notation, such as
	// NaN, an infinity or a hexadecimal float.
	ErrRealNotation = errors.New("not decimal Real notation")
)
View Source
var (
	// ErrFilterUnevaluable reports a filter condition outside the subset of
	// predicates the evaluator implements, or one naming something that does
	// not resolve. Such a condition selects nothing and rejects nothing: it is
	// reported, and the candidate is kept, so that an unevaluable filter never
	// silently hides model content.
	ErrFilterUnevaluable = errors.New("filter condition cannot be evaluated")

	// ErrFilterNotBoolean reports a filter condition that evaluates to
	// something other than a boolean, which cannot select elements.
	ErrFilterNotBoolean = errors.New("filter condition is not boolean-valued")
)
View Source
var (
	// ErrNotAUnit reports a feature used as a measurement reference that is not
	// one: it does not conform to MeasurementReferences::MeasurementUnit.
	ErrNotAUnit = errors.New("not a measurement unit")

	// ErrUnitExpr reports an expression in unit position that is not a product
	// of powers of measurement units.
	ErrUnitExpr = errors.New("not a measurement unit expression")

	// ErrUnitConversion reports a unit whose conversion to its reference unit is
	// declared but cannot be read as a number, so no factor can be derived.
	ErrUnitConversion = errors.New("undetermined unit conversion")

	// ErrUnitCycle reports a unit that is defined, directly or through other
	// units, in terms of itself.
	ErrUnitCycle = errors.New("cyclic unit definition")
)
View Source
var ErrNotAView = errors.New("not a view")

ErrNotAView is returned when the exposed set is asked of an element that is no view; only a view usage or a view definition exposes elements.

View Source
var ErrNotAViewpoint = errors.New("not a viewpoint")

ErrNotAViewpoint reports a `satisfy` in a view body whose target is no viewpoint, so it asserts no viewpoint conformance.

Functions

func ActionDeclaration added in v0.5.0

func ActionDeclaration(decl ast.Node) bool

ActionDeclaration reports whether decl declares an ActionDefinition or an ActionUsage (SysML v2 8.3.17), including the state, calculation, case, transition, and control-node kinds that specialize them.

func AnnotationScope added in v0.5.0

func AnnotationScope(sym *symbols.Symbol) *symbols.Scope

AnnotationScope is where an annotation on sym names its type: sym's own scope, or the enclosing one when sym has none.

func ConjugateDirection

func ConjugateDirection(d ast.FeatureDirection) ast.FeatureDirection

ConjugateDirection returns the conjugate of a feature direction (§7.12.2): in and out are each other's conjugate, inout and none are their own.

func ConvertMagnitude

func ConvertMagnitude(magnitude float64, from, to Scale) float64

ConvertMagnitude expresses a magnitude given over the scale factor from over the scale factor to, as one ratio so that no intermediate rounding enters.

func DeclaresRedefinition added in v0.2.0

func DeclaresRedefinition(sym *symbols.Symbol) bool

DeclaresRedefinition reports whether sym carries a `redefines`/`:>>` clause, whether or not its target resolves.

func DeclaresVariant

func DeclaresVariant(sym *symbols.Symbol) bool

DeclaresVariant reports whether sym is declared with the `variant` keyword, which makes it one of the choices of the variation that owns it.

func DeclaresVariation

func DeclaresVariation(sym *symbols.Symbol) bool

DeclaresVariation reports whether sym is declared with the `variation` modifier, which makes it a variation point: an abstract classifier of the variants declared for it (SysML v2 §7.20, VariantMembership).

func EnumerationDefinitionOwning added in v0.5.0

func EnumerationDefinitionOwning(sym *symbols.Symbol) *symbols.Symbol

EnumerationDefinitionOwning returns the enumeration definition whose body declares sym, whatever sym is, or nil when its owner is not one.

func EnumerationOwning

func EnumerationOwning(sym *symbols.Symbol) *symbols.Symbol

EnumerationOwning returns the enumeration definition sym is a literal of, or nil when sym is no enumeration literal: a literal is an enumeration usage declared in an enumeration definition's body (SysML v2 §7.6.4).

func GeneralizationKind

func GeneralizationKind(k ast.RelationshipKind) bool

GeneralizationKind reports whether a relationship kind forms a conformance ("is-a" / "conforms-to") edge for the specialization graph: specialization on definitions, and subsetting/redefinition/typing on usages.

Reference subsetting (`references`) is excluded even though KerML 8.3.3.3.9 makes it a kind of Subsetting: it contributes members through MemberSources instead, so that a referencing feature does not silently acquire the referenced feature's type for conformance and implicit-typing purposes. crosses is a feature-value edge, not generalization, and is excluded too.

func IntArith added in v0.4.3

func IntArith(op ast.OperatorKind, a, b int64) (int64, bool)

IntArith is Integer addition, subtraction and multiplication, shared by the folder, the operators and the library functions, reporting ok=false on overflow.

func IntQuotient added in v0.4.3

func IntQuotient(a, b int64) (float64, bool)

IntQuotient is the exact rational quotient of two Integers rounded once to the nearest float64, shared by the folder and the runtime; ok=false on a zero divisor. Rounding each operand first would move quotients of operands beyond 2^53, where int64 loses exactness in float64.

func IsCollection added in v0.5.0

func IsCollection(sym *symbols.Symbol) bool

IsCollection reports whether sym is a Kernel Data Type Library collection shape, which the runtime reads as its elements; a type elsewhere specializing one (a quantity value) is its own kind.

func IsElementType added in v0.5.0

func IsElementType(sym *symbols.Symbol) bool

IsElementType reports whether sym is KerML::Root::Element, the metaclass every model element is an instance of, so a parameter it types takes the element any argument names.

func IsMetadataType added in v0.5.0

func IsMetadataType(sym *symbols.Symbol) bool

IsMetadataType reports whether a symbol is a metadata definition or a KerML metaclass — the types an annotation can have.

func IsShapeFeature added in v0.5.0

func IsShapeFeature(sym *symbols.Symbol) bool

IsShapeFeature reports whether sym is a kind of feature an object carries a value of (an attribute, part, port, action…), as opposed to a nested type, a calculation or an enumeration.

func IsValueType added in v0.5.0

func IsValueType(sym *symbols.Symbol) bool

IsValueType reports whether sym is a type whose instances are values rather than objects: an attribute or enumeration definition or usage.

func IsVariant added in v0.5.0

func IsVariant(sym *symbols.Symbol) bool

IsVariant reports whether sym is a variant: declared `variant`, or an enumerated value, held by a variant membership (SysML v2 §7.6.4).

func IsVariation added in v0.5.0

func IsVariation(sym *symbols.Symbol) bool

IsVariation reports whether sym is a variation: declared `variation`, or an enumeration definition, whose isVariation is always true (SysML v2 §8.3.9).

func IsView

func IsView(sym *symbols.Symbol) bool

IsView reports whether sym is a view usage or a view definition, the two elements that own Expose relationships.

func IsViewpoint

func IsViewpoint(sym *symbols.Symbol) bool

IsViewpoint reports whether sym is a viewpoint usage or definition.

func IsViewpointSatisfy

func IsViewpointSatisfy(sat *symbols.Symbol) bool

IsViewpointSatisfy reports whether a satisfy member claims conformance to what it names — `satisfy vp;`. A satisfy stating a subject asserts its requirement of that subject instead (`satisfy requirement r by that;`, as the stdlib View does), which is no claim about the view.

func KindBaseFQN added in v0.2.0

func KindBaseFQN(sym *symbols.Symbol, isKerML bool) (string, bool)

KindBaseFQN returns the standard-library base every declaration of sym's kind conforms to, implicitly or through its declared chain.

func LiteralValue

func LiteralValue(sym *symbols.Symbol) ast.Node

LiteralValue returns the value expression a literal declares, or nil when it declares none and is identified by itself: a literal of an enumeration specializing a scalar type — `enum def GradePoints :> Real { A = 4.0; }` — is a value of that type.

func MultiplicityMetaclassName added in v0.5.0

func MultiplicityMetaclassName(sym *symbols.Symbol) string

MultiplicityMetaclassName is the metaclass of a named multiplicity: a range (`multiplicity m [1..2]`) is a MultiplicityRange, a subset a Multiplicity.

func NotYetMember added in v0.2.0

func NotYetMember(sym, declaring *symbols.Symbol) bool

NotYetMember reports whether a member of a namespace a declaration is being written in is that declaration: the one identified, or, when the caller cannot tell which it is, any redefinition the namespace declares (KerML 8.3.3.3.6).

func ParseReal added in v0.5.0

func ParseReal(text string) (float64, error)

ParseReal reads decimal Real notation as a finite binary64 Real. Any other notation is ErrRealNotation; a magnitude that overflows to an infinity, or a nonzero one that underflows to zero, is ErrArithmeticOverflow.

func PrimConforms

func PrimConforms(from, to PrimType) bool

PrimConforms reports whether a value of type from is acceptable where to is expected. PrimUnknown on either side conforms, so partial information never produces a diagnostic.

func QualifiedNameText

func QualifiedNameText(qn *ast.QualifiedName) string

QualifiedNameText renders a qualified name as "A::B::C".

func RealArith added in v0.4.3

func RealArith(op ast.OperatorKind, a, b float64) (float64, bool)

RealArith is Real addition, subtraction, multiplication and division, reporting ok=false for an operator it does not define or a division by zero.

func RelationshipsOf

func RelationshipsOf(sym *symbols.Symbol) []*ast.Relationship

RelationshipsOf returns the declared relationships of a symbol's def/usage declaration, or nil for symbols that are not def/usage.

func UnevaluableClassification

func UnevaluableClassification(reason string, span source.Span) error

UnevaluableClassification reports a classification whose subject the caller could not settle — an expression denoting no element — as the same ErrFilterUnevaluable a filter condition outside the evaluable subset reports.

func UnitExprText

func UnitExprText(node ast.Node) string

UnitExprText renders an expression in unit position as written, so a diagnostic, a printed value or an exported type fact names the unit the model used rather than its reduction. Grouping and quoting the text needs to read back are kept: `'A/m'` is one unit, `A/m` a quotient of two.

func UnitNameText added in v0.5.0

func UnitNameText(qn *ast.QualifiedName) string

UnitNameText renders a unit's qualified name as the notation spells it, a segment that is not a basic name in quotes: `SI::'A/m'`.

func UsageMultiplicityOf added in v0.5.0

func UsageMultiplicityOf(sym *symbols.Symbol) *ast.Multiplicity

UsageMultiplicityOf returns the multiplicity a usage symbol declares, a subject or the constraint an assume/require member owns included, or nil.

func VariantValue

func VariantValue(sym *symbols.Symbol) ast.Node

VariantValue returns the value expression a variant declares, or nil when it declares none and stands for an object of itself.

func VariationOwning

func VariationOwning(sym *symbols.Symbol) *symbols.Symbol

VariationOwning returns the variation sym is a variant of — the declaration owning the variant membership — or nil when sym is not a variant. An enumerated value is a variant of the enumeration definition owning it.

Types

type ActionSuccession added in v0.5.0

type ActionSuccession struct {
	// Decl is the syntax declaring the succession.
	Decl ast.Node
	// Owner is the action whose body declares Decl; nil for a body-local block
	// such as a loop or branch, or for an action queried by body alone.
	Owner *symbols.Symbol
	// Source and Target are the two ends, in connector-end order.
	Source, Target ActionSuccessionEnd
}

ActionSuccession is one Succession an action's body declares or inherits, with each end resolved to the member it attaches to. It is the KerML view a Feature's sourceConnector/targetConnector give of the successions written as `succession s first a then b`, `first a then b`, `then b`, a guarded `if`/`else` edge or `succession s first a if g then b` (a transition owning a succession), or `succession flow from a.x to b.y` (a flow that is a succession).

type ActionSuccessionEnd added in v0.5.0

type ActionSuccessionEnd struct {
	// Node is the declaration the end attaches to; nil when it names none the
	// model declares (an implied `start`/`done`, or an unresolved name).
	Node ast.Node
	// Symbol declares Node when the end reached it by name; nil for an end
	// bound by position, whose Node is a member of the succession's owner.
	Symbol *symbols.Symbol
	// Multiplicity is the multiplicity the end writes, nil when it writes none.
	Multiplicity *ast.Multiplicity
	// Span is the reference the end was resolved from; empty when the end is
	// bound by position or implied, and so rests on no reference.
	Span source.Span
}

ActionSuccessionEnd is one end of an ActionSuccession.

type AnnotationSite added in v0.4.3

type AnnotationSite struct {
	TypeFQN string
	Node    ast.Node
	// Scope is where the annotating node is declared; for an `about`-form
	// annotation that may be another document than the annotated element's.
	Scope  *symbols.Scope
	About  bool
	Values []symbols.AnnotationValueFacts
}

AnnotationSite is one metadata annotation of an element together with the node stating it — a prefix/body annotation of the element itself, or a metadata usage annotating it from elsewhere with an `about` clause.

type Argument added in v0.5.0

type Argument struct {
	Prim  PrimType
	Type  *symbols.Symbol // the declared type of the feature or result named, nil when none
	Exact bool
	Name  string // the parameter a named argument binds to; "" for positional
}

Argument is one invocation argument as the checker types it; Exact holds of a literal, whose type is written out rather than only bounded.

type ArgumentTyper added in v0.5.0

type ArgumentTyper interface {
	InvocationArguments(scope *symbols.Scope, e *ast.InvocationExpr) []Argument
}

ArgumentTyper types a call's arguments as the checker does, so a call read anywhere in the model selects the overload the checker selects.

type BehaviorParameter added in v0.4.1

type BehaviorParameter struct {
	Symbol    *symbols.Symbol
	Direction ast.FeatureDirection
	IsResult  bool
}

BehaviorParameter is one effective parameter of a behavior, in invocation order.

type Bound

type Bound struct {
	Value    int64
	Infinite bool
	Known    bool
}

Bound is one end of a multiplicity range. Known is false when the bound expression is not model-level-evaluable (checks then skip it). Infinite marks the `*` unbounded upper.

func (Bound) Text added in v0.5.0

func (b Bound) Text() string

Text renders one bound: a number, `*`, or `?` when it is not evaluable.

type ConcernCheck

type ConcernCheck struct {
	Element *symbols.Symbol
	Holds   bool
	Err     error
}

ConcernCheck is the verdict of one framed concern against one exposed element.

type ConcernConformance

type ConcernConformance struct {
	// Concern is the viewpoint's framing and Target the concern it names, nil
	// when the framing names nothing resolvable.
	Concern *symbols.Symbol
	Target  *symbols.Symbol
	// Name is how the framed concern is written, for reporting.
	Name string
	// FramedBy is the view's framing of the same concern and FramedIn the view
	// declaring it. Both are nil when the view does not frame the concern.
	FramedBy *symbols.Symbol
	FramedIn *symbols.Symbol
	// Checks are the per-element verdicts, in exposed-element order.
	Checks  []ConcernCheck
	Verdict Verdict
	Reason  string
}

ConcernConformance is what became of one concern the viewpoint frames.

type ConcernEvaluator

type ConcernEvaluator interface {
	EvaluateConcern(concern, element *symbols.Symbol) (bool, error)
}

ConcernEvaluator evaluates a framed concern's conditions with one exposed element bound as its subject. It is implemented over the runtime's requirement engine, which the semantic model cannot import.

type ConformanceViolation added in v0.2.0

type ConformanceViolation struct {
	Kind ConformanceViolationKind
	// Feature is the subsetting or redefining feature.
	Feature *symbols.Symbol
	// Target is the subsetted or redefined feature.
	Target *symbols.Symbol
	// Ref is the node the diagnostic is reported at: the target reference of an
	// explicit clause, or the declaration itself for an implicit redefinition.
	Ref ast.Node
}

ConformanceViolation is one broken conformance rule: the relationship that breaks it, and the reference to report it at.

type ConformanceViolationKind added in v0.2.0

type ConformanceViolationKind int

ConformanceViolationKind names the conformance rule a relationship breaks.

const (
	// ViolationDirection: a redefining feature's direction differs from the
	// direction the redefined feature has in the owning type.
	ViolationDirection ConformanceViolationKind = iota
	// ViolationUniqueness: a nonunique feature subsets or redefines a unique one.
	ViolationUniqueness
	// ViolationConstancy: a variable feature subsets or redefines a constant one.
	ViolationConstancy
)

type ConnectorEndAttachment

type ConnectorEndAttachment struct {
	// Name is the effective name of the end feature this position occupies: the
	// name the end declares for itself, else the name of the end it implicitly
	// redefines in the connector it specializes, else the name a binary
	// connector's ends have in the library. It is empty when none of those
	// answers a name — an end of an untyped connector with an arity other than
	// two, whose ends are the participants of a link and are unnamed.
	Name string
	// Attachment is the expression naming the connected feature (`a.p`).
	Attachment ast.Node
	// End is the syntax of the end itself, which carries its source location.
	End *ast.ConnectorEnd
	// EndFeature is the end feature Name comes from, when a declaration in the
	// model declares it: the end's own symbol, or the end it redefines. It is nil
	// for a name taken from the library, whose declarations are indexed without
	// bodies.
	EndFeature *symbols.Symbol
}

ConnectorEndAttachment is one end of a connector usage as an object of that usage carries it: the name of the end feature the position occupies, and the node naming the feature the end attaches to. A connector end reference-subsets what it attaches to (KerML 1.0 §7.4.6, SysML v2 §7.13.2), so an object of the connector holds that very feature at the end rather than an object of the end's declared type.

type Dimension

type Dimension struct {
	Term UnitTerm
	// Unit is the unit as written or the operand's quantity type, for the
	// diagnostic; empty for a computed dimension, described by Term alone.
	Unit string
}

Dimension is the quantity dimension of a measurement: a product of powers of base quantities (ISQ's L, M, T, ...), held as a UnitTerm over the base-quantity features so that UnitTerm.Commensurable — the same commensurability the runtime applies to units — decides whether two dimensions are comparable.

func (Dimension) String

func (d Dimension) String() string

String renders the dimension over its base quantities ("M", "L·T^-1"), or "1" for the dimension of a count. Base quantities are named as declared (ISQ's L, M, T, ...) rather than by qualified name, which no dimension is written with.

type FilterError

type FilterError struct {
	Reason string
	Span   source.Span
	Err    error
}

FilterError is why a filter condition could not decide a candidate. Reason describes the part at fault in the terms a diagnostic message uses, and Span locates it.

func (*FilterError) Error

func (e *FilterError) Error() string

func (*FilterError) Unwrap

func (e *FilterError) Unwrap() error

type FilterProblem

type FilterProblem struct {
	// Kind distinguishes a specification fault from an evaluator limitation.
	Kind   FilterProblemKind
	Reason string
	Span   source.Span
}

FilterProblem is a fault in a filter condition itself, found without any candidate to evaluate it for: a part of it the evaluator cannot decide, or one that yields something other than a boolean where the condition needs a truth value. Reason describes the fault for a diagnostic message, and Span locates the part of the condition at fault.

type FilterProblemKind added in v0.2.1

type FilterProblemKind uint8

FilterProblemKind classifies a filter condition fault.

const (
	FilterProblemNotBoolean FilterProblemKind = iota
	FilterProblemNotEvaluable
	FilterProblemUnsupported
)

type FlowEndAttachment added in v0.2.0

type FlowEndAttachment struct {
	Attachment ast.Node
}

FlowEndAttachment is one declared from/to target of a flow usage.

type InvocationSelection added in v0.5.0

type InvocationSelection struct {
	Candidates []*symbols.Symbol // what the name denotes, in lookup order, aliases followed
	Applicable []*symbols.Symbol // the candidates the arguments bind to
	Selected   *symbols.Symbol   // the one called; nil when none applies or they tie
	Ambiguous  bool              // several applicable candidates are equally specific
	Tied       []*symbols.Symbol // the applicable candidates none is more specific than, when Ambiguous
	// contains filtered or unexported fields
}

InvocationSelection is which declaration an invocation calls, out of every declaration its written name is visible as.

func (*InvocationSelection) Called added in v0.5.0

func (s *InvocationSelection) Called() *symbols.Symbol

Called is the declaration a call runs: the one selected, or when no candidate fits the first callable one (else the first at all), which then reports the mismatch; nil when none.

func (*InvocationSelection) Resolved added in v0.5.0

func (s *InvocationSelection) Resolved() bool

Resolved reports whether the name denotes at least one declaration.

type MetadataAnnotation added in v0.2.0

type MetadataAnnotation struct {
	Node   *ast.PrefixMetadata
	Prefix bool
}

MetadataAnnotation is a metadata feature annotating an element, written either as a prefix (`#A part p`) or as a member of the element's body (`@A;`).

func MetadataAnnotationsAboutOthers added in v0.5.0

func MetadataAnnotationsAboutOthers(decl ast.Node) []MetadataAnnotation

MetadataAnnotationsAboutOthers returns the metadata features written on a declaration that annotate other elements (`@A about x`), in declaration order.

func MetadataAnnotationsOf added in v0.2.0

func MetadataAnnotationsOf(decl ast.Node) []MetadataAnnotation

MetadataAnnotationsOf returns the metadata features annotating a declaration, in declaration order. `@A about x` annotates other elements, so it is not one.

func MetadataAnnotationsWritten added in v0.5.0

func MetadataAnnotationsWritten(decl ast.Node) []MetadataAnnotation

MetadataAnnotationsWritten returns every metadata feature written on decl, as prefixes then as members of its body, in declaration order.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the derived semantic model over a symbol index. It memoizes the specialization graph computed from resolved def/usage relationships.

func NewModel

func NewModel(resolver *resolve.Resolver) *Model

NewModel creates a semantic model backed by the given name resolver. The resolver must already be associated with the index whose symbols will be queried. The model attaches itself to the resolver so name resolution sees inherited members, which a redefinition target may only be reachable through.

func (*Model) AboutAnnotatedElementViolations added in v0.5.0

func (m *Model) AboutAnnotatedElementViolations(scope *symbols.Scope, typeRef *ast.QualifiedName, about []*ast.QualifiedName) []string

AboutAnnotatedElementViolations names, in order, the metaclass of each element an `about` clause names that the metadata type typeRef names may not annotate.

func (*Model) AboutAnnotatedSymbols added in v0.4.3

func (m *Model) AboutAnnotatedSymbols() []*symbols.Symbol

AboutAnnotatedSymbols returns every element an `about` metadata usage annotates, in the deterministic order the index is built in — bundled library elements a workspace annotation targets included.

func (*Model) ActionSuccessions added in v0.5.0

func (m *Model) ActionSuccessions(sym *symbols.Symbol) []ActionSuccession

ActionSuccessions returns the successions of an action definition or usage: those inherited from what it specializes or is typed by, most general first, then its own in declaration order. A redefined inherited succession is masked.

func (*Model) AllRedefinedFeatures added in v0.5.0

func (m *Model) AllRedefinedFeatures(sym *symbols.Symbol) []*symbols.Symbol

AllRedefinedFeatures returns every feature sym redefines, directly or through the features those redefine: explicit clauses and the implicit redefinitions of parameters, connector ends and case roles alike. sym itself is excluded.

func (*Model) AllSupertypes

func (m *Model) AllSupertypes(sym *symbols.Symbol) []*symbols.Symbol

AllSupertypes returns the transitive closure of DirectSupertypes, excluding sym itself, in a deterministic order (breadth-first over declaration order). It is safe on cyclic graphs. The result is memoized.

func (*Model) AnnotatedElementViolation added in v0.2.0

func (m *Model) AnnotatedElementViolation(annotated *symbols.Symbol, scope *symbols.Scope, typeRef *ast.QualifiedName) (string, bool)

AnnotatedElementViolation names the metaclass of annotated when the metadata type typeRef names may not annotate it (validateMetadataFeatureAnnotatedElement).

func (*Model) AnnotationFactsOf

func (m *Model) AnnotationFactsOf(sym *symbols.Symbol) []symbols.AnnotationFacts

AnnotationFactsOf states the metadata annotating sym as names and constants, so that how an element filter classifies it can be compared across loads. The values an annotation binds are reported as read; a binding whose value is not constant is reported with an unknown value, which a condition reading it reports as unevaluable rather than silently treating as absent.

func (*Model) AnnotationSitesOf added in v0.4.3

func (m *Model) AnnotationSitesOf(sym *symbols.Symbol) []AnnotationSite

AnnotationSitesOf returns the metadata annotating sym with the nodes stating it, inline annotations first and `about`-form ones after, each in declaration order.

func (*Model) BehaviorParametersOf added in v0.4.1

func (m *Model) BehaviorParametersOf(sym *symbols.Symbol) []BehaviorParameter

BehaviorParametersOf returns a behavior's inherited and declared parameters.

func (*Model) CheckElementFilter

func (m *Model) CheckElementFilter(f symbols.ElementFilter) []FilterProblem

CheckElementFilter reports the faults of a filter condition, in the order they appear in it. It is what the validation pass reports: the same compiled predicate the enumeration evaluates is examined, so a condition diagnosed here is exactly one whose verdict is not trusted there.

Only faults that hold for every candidate are reported. Whether an annotation actually binds a feature is a property of the candidate, not of the condition, so it surfaces as an unevaluable verdict during enumeration rather than here.

func (*Model) CompileElementFilter

func (m *Model) CompileElementFilter(f symbols.ElementFilter) *symbols.FilterPredicate

CompileElementFilter returns the condition compiled to a predicate over a candidate element, by resolving the elements it names against the scope it was written in. Returns nil for an empty condition.

func (*Model) ConcernEvaluationTarget

func (m *Model) ConcernEvaluationTarget(fc *symbols.Symbol) *symbols.Symbol

ConcernEvaluationTarget returns the element whose conditions answer a framing: the framing when it declares a concern of its own, else the concern it names, whose conditions a bare `frame <concern>;` does not restate.

func (*Model) ConformanceViolations added in v0.2.0

func (m *Model) ConformanceViolations(sym *symbols.Symbol) []ConformanceViolation

ConformanceViolations returns the feature-conformance rules the declaration of sym breaks against the features it subsets and redefines, explicitly or as a parameter of its owning behavior.

func (*Model) Conforms

func (m *Model) Conforms(a, b *symbols.Symbol) bool

Conforms reports whether a conforms to b: a == b, b is a (transitive) supertype of a, or a is the union of types that all conform to b. Symbols are compared as elements, so one declaration reached through two scope trees (a document's and the index's) conforms to itself.

func (*Model) ConnectorEndAttachments

func (m *Model) ConnectorEndAttachments(sym *symbols.Symbol) []ConnectorEndAttachment

ConnectorEndAttachments returns the ends of the connector usage sym in declaration order, one entry per end of its `connect` clause. It returns nothing for a symbol that is no connector usage.

func (*Model) ConnectorEndCount

func (m *Model) ConnectorEndCount(sym *symbols.Symbol) int

ConnectorEndCount returns the number of effective ends of the connector sym.

func (*Model) ConstantFeatureValues added in v0.4.2

func (m *Model) ConstantFeatureValues(sym *symbols.Symbol, feature string) ([]symbols.FilterValue, bool)

ConstantFeatureValues returns a feature's ordered constant values.

func (*Model) ConstructibleFeatureFor added in v0.5.0

func (m *Model) ConstructibleFeatureFor(typ, feature *symbols.Symbol) *symbols.Symbol

ConstructibleFeatureFor returns the constructible feature of typ standing for feature (itself, or one it redefines or is redefined by); nil when none does.

func (*Model) ConstructibleFeatures added in v0.5.0

func (m *Model) ConstructibleFeatures(typ *symbols.Symbol) []*symbols.Symbol

ConstructibleFeatures returns the features a constructor's positional arguments bind, in shape order: those declared or restated in the constructed type's own tier (the model's for a model type, a library's for one of its types), not the ones a more general library declares for every object of the kind. A redefinition and its target are one feature, so they take one position.

func (*Model) CouldHold added in v0.2.0

func (m *Model) CouldHold(sym *symbols.Symbol, prim PrimType) bool

CouldHold reports whether a feature of the given type could hold a value of the scalar type prim: either the type conforms to it, or it conforms to the type, as every value does to `Anything`.

func (*Model) DeclaredFeatureTypes added in v0.5.0

func (m *Model) DeclaredFeatureTypes(sym *symbols.Symbol) []*symbols.Symbol

DeclaredFeatureTypes is FeatureTypes without the kind's base: the types a feature is written with, directly or through the features it specializes.

func (*Model) DeclaredFeatureValues added in v0.4.2

func (m *Model) DeclaredFeatureValues(sym *symbols.Symbol, feature string) ([]symbols.FilterValue, bool)

DeclaredFeatureValues returns a declared member feature's ordered constant values, never answering reflective metaclass features of the same name.

func (*Model) DeclaredSuccessions added in v0.5.0

func (m *Model) DeclaredSuccessions(scope *symbols.Scope, owner *symbols.Symbol, members []ast.Node) []ActionSuccession

DeclaredSuccessions returns the successions members declare, in order, with end names resolved in scope; owner, which may be nil, is recorded on each.

func (*Model) DimensionFactsOf

func (m *Model) DimensionFactsOf(sym *symbols.Symbol, idx *symbols.Index) *symbols.DimensionFacts

DimensionFactsOf returns the dimension to record for a library symbol, or nil when it is undetermined or its base quantities have no qualified name to restore them by.

func (*Model) DimensionOfExpr

func (m *Model) DimensionOfExpr(scope *symbols.Scope, node ast.Node) (Dimension, bool)

DimensionOfExpr reports the dimension of an expression's value when the declarations it names determine it statically. A dimension that only evaluation determines — an untyped feature or parameter, a calculation result, an unresolved reference, an unbound redefinition — is reported as unknown rather than guessed.

func (*Model) DimensionOfFeature

func (m *Model) DimensionOfFeature(sym *symbols.Symbol) (Dimension, bool)

DimensionOfFeature reports the dimension a feature's values are measured in, as its declared quantity type fixes it.

func (*Model) DimensionOfType added in v0.4.0

func (m *Model) DimensionOfType(sym *symbols.Symbol) (Dimension, bool)

DimensionOfType reports the dimension a declared type fixes for the values it types, as DimensionOfFeature does for a feature's own declaration. A write target known only by the type it was declared with is judged through this.

func (*Model) DimensionOfUnit

func (m *Model) DimensionOfUnit(unit UnitTerm) (Dimension, bool)

DimensionOfUnit reports the dimension a reduced unit measures in, so a value carrying a unit can be checked against the dimension a feature declares.

func (*Model) DirectMemberSources added in v0.2.0

func (m *Model) DirectMemberSources(sym *symbols.Symbol) []*symbols.Symbol

DirectMemberSources returns the symbols that contribute members to sym in one step, deduplicated: the edges MemberSources takes the closure of. A caller enumerating names needs the steps, not the closure, to tell which types a derivation traversed (KerML 8.2.3.5, inheritedMemberships' excluded types).

func (*Model) DirectSupertypes

func (m *Model) DirectSupertypes(sym *symbols.Symbol) []*symbols.Symbol

DirectSupertypes returns the immediate supertype symbols of sym: the resolved targets of its generalization relationships. Unresolved or non-def/usage targets are skipped. The result is memoized and deterministic (declaration order, duplicates removed).

func (*Model) EffectiveMultiplicityOf

func (m *Model) EffectiveMultiplicityOf(sym *symbols.Symbol) Range

EffectiveMultiplicityOf returns the multiplicity governing a usage symbol: the one it declares, or the assumed 1..1 when it declares none.

func (*Model) EffectiveNameOf added in v0.4.2

func (m *Model) EffectiveNameOf(sym *symbols.Symbol) string

EffectiveNameOf returns a declaration's name, including one inherited through a unique redefinition.

func (*Model) Eval

func (m *Model) Eval(n ast.Node) (Value, bool)

Eval attempts to evaluate n as a model-level constant. It returns ok=false for anything outside the supported subset (feature references, strings, null, unsupported operators, or arithmetic on infinity) — callers then skip the check, matching the pilot's model-level-evaluable gating.

func (*Model) EvalClassification

func (m *Model) EvalClassification(scope *symbols.Scope, e *ast.OperatorExpr, elem *symbols.Symbol) (bool, error)

EvalClassification evaluates the classification `@T`/`@@T` that e writes against one element, for a caller that has settled which element the subject denotes — the runtime value evaluator, whose `@` has a subject expression a filter condition has no equivalent of. e's operand is not looked at here.

The type is resolved and the verdict decided by the same code a filter condition is compiled and run with, so a classification cannot answer one way in a filter and another in an expression. A condition outside the evaluable subset — a type that does not resolve — is a *FilterError wrapping ErrFilterUnevaluable, as it is at the model level.

func (*Model) EvalElementFilter

func (m *Model) EvalElementFilter(f symbols.ElementFilter, cand *symbols.Symbol) (bool, error)

EvalElementFilter evaluates a filter condition for one candidate element, returning whether the candidate is selected, or a *FilterError saying why no verdict is possible.

func (*Model) Evaluates added in v0.5.0

func (m *Model) Evaluates(sym *symbols.Symbol) bool

Evaluates reports whether calling sym yields a result: it is a calc (a KerML function), or a feature typed by one, which is what an expression evaluates.

func (*Model) ExposedElements

func (m *Model) ExposedElements(view *symbols.Symbol) ([]*symbols.Symbol, error)

ExposedElements returns what view exposes, in declaration order and once each: its own `expose` relationships followed by those of the views it specializes, since an Expose is protected. An empty set is no error, a non-view is ErrNotAView, and a nested view's own set is asked of it directly.

func (*Model) FeatureBaseFQN added in v0.2.0

func (m *Model) FeatureBaseFQN(sym *symbols.Symbol) (string, bool)

FeatureBaseFQN returns the standard-library element a feature declaration takes its type from when it declares none: the base feature its kind implies, or the base definition a SysML usage of that kind is typed by.

func (*Model) FeatureIsVariable added in v0.5.0

func (m *Model) FeatureIsVariable(sym *symbols.Symbol) bool

FeatureIsVariable derives KerML Feature::isVariable (KerML 1.1 §8.3.3.1): declared by `var` or `const` in KerML, and redefined as Usage::mayTimeVary for a SysML usage.

func (*Model) FeatureTypes added in v0.5.0

func (m *Model) FeatureTypes(sym *symbols.Symbol) []*symbols.Symbol

FeatureTypes returns a feature's effective types: those it declares, else those of the features it redefines or subsets (KerML §8.3.3.3), else its kind's base.

func (*Model) FlowEndAttachments added in v0.2.0

func (m *Model) FlowEndAttachments(sym *symbols.Symbol) []FlowEndAttachment

FlowEndAttachments returns the declared from/to targets of a flow usage.

func (*Model) FrameFeature added in v0.5.0

func (m *Model) FrameFeature(sym *symbols.Symbol) bool

FrameFeature reports whether a library-declared member frames the object rather than describing it, so that the shape leaves it out.

func (*Model) FramedConcernTarget

func (m *Model) FramedConcernTarget(fc *symbols.Symbol) *symbols.Symbol

FramedConcernTarget returns the concern a `frame` member frames: the concern definition it is typed by, or the concern usage it references — the element named, not what that element in turn specializes, whose values it may mask. It is nil when the framing names no concern.

func (*Model) FramedConcernsOf

func (m *Model) FramedConcernsOf(sym *symbols.Symbol) []*symbols.Symbol

FramedConcernsOf returns the `frame` concern usages a viewpoint or view declares followed by those it inherits, in declaration order and once each.

func (*Model) HasMember added in v0.5.0

func (m *Model) HasMember(sym, member *symbols.Symbol) bool

HasMember reports whether member is among MembersOf(sym), without enumerating the members past it.

func (*Model) HasSpecializationCycle

func (m *Model) HasSpecializationCycle(sym *symbols.Symbol) bool

HasSpecializationCycle reports whether sym participates in a specialization cycle: sym is reachable from itself through one or more generalization edges (including a direct self-specialization). AllSupertypes excludes its own starting node, so sym is detected via a back-edge from one of its supertypes.

func (*Model) ImplicitEndRedefinitions

func (m *Model) ImplicitEndRedefinitions(sym *symbols.Symbol) []*symbols.Symbol

ImplicitEndRedefinitions returns the ends of the connectors its owner specializes that sym redefines by occupying their position, which no clause of its declaration names. The features it redefines are one feature with it, so an object holds one set of values under all their names.

func (*Model) ImplicitGenerals added in v0.2.0

func (m *Model) ImplicitGenerals(sym *symbols.Symbol) []*symbols.Symbol

ImplicitGenerals returns the general types sym has by its kind rather than by declaration. A scope reached through a recursive import does not traverse them (KerML 8.2.3.5).

func (*Model) ImplicitRoleRedefinitions added in v0.2.0

func (m *Model) ImplicitRoleRedefinitions(sym *symbols.Symbol) []*symbols.Symbol

ImplicitRoleRedefinitions returns the same-role features of the owner's generals that sym does not redefine by name: a role redefines every one it inherits.

func (*Model) InheritanceMasked added in v0.2.0

func (m *Model) InheritanceMasked(sym, candidate *symbols.Symbol) bool

InheritanceMasked reports whether sym does not inherit candidate because one of its features redefines it. Callers enumerating or resolving inherited members ask here; resolving a redefinition target itself must not, as that reference names the masked feature (KerML 7.3.4.5).

func (*Model) InheritanceMaskedDeclaring added in v0.2.0

func (m *Model) InheritanceMaskedDeclaring(sym, candidate *symbols.Symbol, declName string) bool

InheritanceMaskedDeclaring is InheritanceMasked as the declaration named declName, being written in sym, sees it: sym's own redefinitions mask nothing, so the target such a declaration names stays resolvable (KerML 8.3.3.3.6).

func (*Model) InterfaceEndPortMismatch

func (m *Model) InterfaceEndPortMismatch(sym *symbols.Symbol) (a, b *symbols.Symbol, mismatch bool)

InterfaceEndPortMismatch returns the port types of the two ends of the interface sym when they do not match with conjugate directions (§7.12.2). Ends whose port type is not resolvable, and interfaces whose ends are not both declared, are not reported.

func (*Model) IsAngularMeasureUnit added in v0.5.0

func (m *Model) IsAngularMeasureUnit(sym *symbols.Symbol) bool

IsAngularMeasureUnit reports whether sym is a unit of plane angle (rad, °, ′): one of the dimension-one units a trigonometric function may take.

func (*Model) IsBinaryConnector added in v0.2.0

func (m *Model) IsBinaryConnector(sym *symbols.Symbol) bool

IsBinaryConnector reports whether sym conforms to the library's binary-link base, including through cached/index-only specialization edges.

func (*Model) IsConjugated

func (m *Model) IsConjugated(sym *symbols.Symbol) bool

IsConjugated reports whether sym's inherited features have reversed directions. Conjugation composes, so `~` of a conjugate is the original.

func (*Model) IsConnectorUsage

func (m *Model) IsConnectorUsage(sym *symbols.Symbol) bool

IsConnectorUsage reports whether sym declares a connector usage that joins features it names — a `connection`/`interface`/`allocation`/`connector` usage with a `connect … to …` clause. Such a usage is materialized from the features its ends attach to, unlike a usage that only holds objects of its own.

func (*Model) IsDataType added in v0.5.0

func (m *Model) IsDataType(sym *symbols.Symbol) bool

IsDataType reports whether sym is Base::DataValue or conforms to it, so its values are data (scalars, enumerations, attribute values) and never elements.

func (*Model) IsMeasurementUnit

func (m *Model) IsMeasurementUnit(sym *symbols.Symbol) bool

IsMeasurementUnit reports whether sym is a feature typed by a measurement unit, which is what may stand in the unit position of a quantity expression.

func (*Model) IsOptionalParameter added in v0.5.0

func (m *Model) IsOptionalParameter(usage *ast.Usage) bool

IsOptionalParameter reports whether a parameter may be left without an argument: its declared multiplicity admits no value (KerML 1.0 §7.4.7.2, an input parameter with lower bound 0). One declaring none holds one value.

func (*Model) IsVariationFeature

func (m *Model) IsVariationFeature(sym *symbols.Symbol) bool

IsVariationFeature reports whether sym is a variation point: a variation itself (declared, or an enumeration definition) or a usage specializing a declared one. A usage typed by an enumeration holds one of its values, as any attribute does.

func (*Model) LiteralConforms added in v0.5.0

func (m *Model) LiteralConforms(sym, expected *symbols.Symbol) bool

LiteralConforms reports whether sym is an enumeration literal whose enumeration conforms to expected: a literal is a value of its enumeration.

func (*Model) LiteralsOf

func (m *Model) LiteralsOf(sym *symbols.Symbol) []*symbols.Symbol

LiteralsOf returns the literals an enumeration definition declares, including the ones it inherits from an enumeration it specializes.

func (*Model) LookupContributedMember

func (m *Model) LookupContributedMember(sym *symbols.Symbol, name string) (*symbols.Symbol, bool)

LookupContributedMember is LookupMember without sym's own declarations: only the members contributed by what sym specializes, is typed by or reference-subsets. Callers that must not see a local binding — resolving a reference subsetting's target past the borrowed name it binds itself — ask for the contributed member instead.

func (*Model) LookupContributedMembers added in v0.5.0

func (m *Model) LookupContributedMembers(sym *symbols.Symbol, name string) []*symbols.Symbol

LookupContributedMembers is LookupContributedMember collecting the member each source contributes under name, in source order, without duplicates.

func (*Model) LookupMember

func (m *Model) LookupMember(sym *symbols.Symbol, name string) (*symbols.Symbol, bool)

LookupMember returns the first visible member of sym — declared by it, or contributed by what it specializes or reference-subsets — registered under name, honoring masking.

func (*Model) MeasurementUnitOf added in v0.5.0

func (m *Model) MeasurementUnitOf(sym *symbols.Symbol) (*symbols.Symbol, bool)

MeasurementUnitOf is the measurement unit sym names: sym itself, or the unit an alias such as SI::'m/s²' stands for; false for anything else.

func (*Model) MemberSources

func (m *Model) MemberSources(sym *symbols.Symbol) []*symbols.Symbol

MemberSources returns the symbols whose scopes contribute members to sym, in deterministic breadth-first order and excluding sym itself: what sym specializes (DirectSupertypes) and what it reference-subsets (ReferencedFeature), transitively.

Reference subsetting is a kind of subsetting, and subsetting is a kind of specialization (KerML 8.3.3.3.9), so a referencing feature inherits the referenced feature's features: `perform action takePhoto references takePicture` makes takePicture's members reachable as `takePhoto.focus`. It is kept out of DirectSupertypes because that relation also drives conformance and implicit typing, which this implementation does not yet derive from reference subsetting — see docs/project/spec-compliance.md.

func (*Model) MemberSourcesStable added in v0.5.0

func (m *Model) MemberSourcesStable(sym *symbols.Symbol) bool

MemberSourcesStable reports whether the last MemberSources answer for sym was complete and memoized, so a caller may memoize what it derived from it.

func (*Model) MembersOf

func (m *Model) MembersOf(sym *symbols.Symbol) []*symbols.Symbol

MembersOf returns the members visible on sym: those declared directly in its owned scope plus members inherited from what it specializes and what it reference-subsets. Two maskings apply: a member declared closer to sym hides an inherited member of the same name, and a feature redefined by one of sym's features is not inherited at all (see masking.go). Results are deterministic: local members first (declaration order), then contributed members in MemberSources order.

func (*Model) MembersOfDeclaring added in v0.2.0

func (m *Model) MembersOfDeclaring(sym, declaring *symbols.Symbol) []*symbols.Symbol

MembersOfDeclaring returns the members of sym as a declaration being written in it sees them: that declaration is not yet a member of its own owner and the redefinition it carries masks nothing, so its target stays resolvable (KerML 8.3.3.3.6). Sym's other declarations, and the masks they cause, are present. A nil declaring — the caller cannot tell which declaration is being written — stands for every redefinition sym declares.

func (*Model) MembersOfIncludingRedefined added in v0.2.0

func (m *Model) MembersOfIncludingRedefined(sym *symbols.Symbol) []*symbols.Symbol

MembersOfIncludingRedefined is MembersOf without redefinition masking: the members a type would have if none of its features redefined anything. A redefinition shares its target's feature value, so the runtime shape needs both.

func (*Model) MemoSize added in v0.5.0

func (m *Model) MemoSize() int

MemoSize is the number of invocation selections the model retains by node.

func (*Model) MetaclassConforms added in v0.4.2

func (m *Model) MetaclassConforms(cand *symbols.Symbol, typeFQN string) bool

MetaclassConforms reports whether a candidate's metaclass conforms to a type.

func (*Model) MetadataBodyInevaluableValues added in v0.2.0

func (m *Model) MetadataBodyInevaluableValues(scope *symbols.Scope, prefix *ast.PrefixMetadata) []ast.Node

MetadataBodyInevaluableValues returns the values written in the body of the annotation that are not model-level evaluable, at any nesting depth. A metadata feature is a model-level element, so its value must be one the model alone decides (KerML 7.4.7, Expression::isModelLevelEvaluable).

func (*Model) MetadataBodyInevaluableValuesOf added in v0.5.0

func (m *Model) MetadataBodyInevaluableValuesOf(scope *symbols.Scope, body []ast.Node) []ast.Node

MetadataBodyInevaluableValuesOf is MetadataBodyInevaluableValues for a body whose declarations are registered in scope, such as that of `metadata m : A { … }`.

func (*Model) MetadataBodyViolations added in v0.2.0

func (m *Model) MetadataBodyViolations(scope *symbols.Scope, prefix *ast.PrefixMetadata) []ast.Node

MetadataBodyViolations returns the declarations in the body of the annotation that redefine no feature of the metadata type it names, at any nesting depth. It returns nothing when the type does not resolve: an unresolved reference is reported by name resolution, and every name under it would be a false report.

func (*Model) MetadataBodyViolationsOf added in v0.5.0

func (m *Model) MetadataBodyViolationsOf(def *symbols.Symbol, scope *symbols.Scope, body []ast.Node) []ast.Node

MetadataBodyViolationsOf is MetadataBodyViolations for a body whose metadata type is already resolved and whose declarations are registered in scope — the body of `metadata m : A { … }` as much as of `@A { … }`.

func (*Model) ModelLevelEvaluable added in v0.2.0

func (m *Model) ModelLevelEvaluable(scope *symbols.Scope, expr ast.Node) bool

ModelLevelEvaluable reports whether an expression written in scope can be evaluated from the model alone (KerML 1.0 §7.4.9, Expression::isModelLevelEvaluable).

func (*Model) MultiplicityOf

func (m *Model) MultiplicityOf(sym *symbols.Symbol) (Range, bool)

MultiplicityOf returns the extracted multiplicity range of a usage symbol, a subject or a requirement constraint included, or ok=false when the symbol is not a usage or declares none.

func (*Model) NestedViews

func (m *Model) NestedViews(view *symbols.Symbol) ([]*symbols.Symbol, error)

NestedViews returns the views declared in view's body, in declaration order, so a caller can walk a view tree.

func (*Model) OptionalParameter added in v0.5.0

func (m *Model) OptionalParameter(sym *symbols.Symbol) bool

OptionalParameter reports whether a call may omit the parameter: it or a parameter it redefines declares a default, or the nearest stated multiplicity admits no value.

func (*Model) OwnerAnnotatedElementViolation added in v0.5.0

func (m *Model) OwnerAnnotatedElementViolation(scope *symbols.Scope, typeRef *ast.QualifiedName) (string, bool)

OwnerAnnotatedElementViolation judges an `about`-less annotation written in scope against scope's owner: a document root is a Namespace, an annotation body its metadata feature.

func (*Model) ParameterDefault added in v0.5.0

func (m *Model) ParameterDefault(sym *symbols.Symbol) (ast.Node, *symbols.Scope)

ParameterDefault is the value the parameter takes when a call binds none: the nearest declared along its redefinitions, with the scope it resolves in. Nil when none is.

func (*Model) ParameterRedefinitionChain added in v0.5.0

func (m *Model) ParameterRedefinitionChain(sym *symbols.Symbol) []*symbols.Symbol

ParameterRedefinitionChain is sym followed by the parameters it redefines, explicitly or by position, nearest first; each declares a usage.

func (*Model) Performable added in v0.5.0

func (m *Model) Performable(p Performs, sym *symbols.Symbol) bool

Performable reports whether a call site of kind p can run sym: a behavior, or for an evaluated call a feature typed by one, which performs that behavior.

func (*Model) PortFeatures

func (m *Model) PortFeatures(sym *symbols.Symbol) []PortFeature

PortFeatures returns the features of the port sym, declared and inherited, with the direction each has as seen through sym. A closer declaration masks an inherited feature of the same name.

func (*Model) PortsConform

func (m *Model) PortsConform(a, b *symbols.Symbol) bool

PortsConform reports whether every feature of port a matches one on port b (§7.12.2): conforming types, and conjugate or absent directions.

func (*Model) PrimTypeOf

func (m *Model) PrimTypeOf(sym *symbols.Symbol) PrimType

PrimTypeOf classifies sym against the scalar lattice. A definition is classified by itself or its nearest scalar supertype; a usage by the type it is typed by (typing is a generalization edge, so the same walk covers both). Symbols with no scalar ancestor are PrimUnknown.

func (*Model) RangeOf

func (m *Model) RangeOf(mult *ast.Multiplicity) (Range, bool)

RangeOf extracts the multiplicity range declared on a usage node, or ok=false when it declares none.

func (*Model) RedefinedFeatures added in v0.2.0

func (m *Model) RedefinedFeatures(sym *symbols.Symbol) []*symbols.Symbol

RedefinedFeatures returns the features sym redefines: the resolved target of each explicit `redefines`/`:>>` clause. Alias targets are resolved through, so the result names elements rather than the bindings that reach them. The implicit redefinitions of parameters and connector ends are matched by position rather than declared, and are reported by DirectSupertypes only. Memoized.

func (*Model) ReferencedFeature

func (m *Model) ReferencedFeature(sym *symbols.Symbol) *symbols.Symbol

ReferencedFeature returns the feature sym reference-subsets: the target of the single `references` / `::>` edge its declaration may carry (KerML 8.3.3.3.9, "A Feature can have at most one ownedReferenceSubsetting"), or nil when it has none or the target does not resolve.

The `perform` and `event` shorthands declare that edge without the keyword: `perform providePower.generateTorque` is a perform action usage whose performed action is related to it by reference subsetting (SysML 7.17.6).

The result is memoized. Resolution of the target runs member lookup, which consults this relation in turn, so a symbol already being resolved yields nil rather than recursing.

func (*Model) ReflectiveFeatureValue added in v0.4.2

func (m *Model) ReflectiveFeatureValue(sym *symbols.Symbol, feature string) (symbols.FilterValue, bool)

ReflectiveFeatureValue reads a metaclass feature derived from the candidate's declaration; ok is false where none is derived.

func (*Model) RelationshipTarget added in v0.2.0

func (m *Model) RelationshipTarget(sym *symbols.Symbol, rel *ast.Relationship) *symbols.Symbol

RelationshipTarget resolves the element rel names from sym's scope.

func (*Model) RenderingTarget

func (m *Model) RenderingTarget(member *symbols.Symbol) (*symbols.Symbol, string)

RenderingTarget returns the rendering a `render`/`rendering` member names and the reference as written: the rendering it references (`render asTreeDiagram;`) or the rendering definition it is typed by (`render rendering r : AsTree;`).

func (*Model) ResultParameterOf added in v0.2.0

func (m *Model) ResultParameterOf(sym *symbols.Symbol) *symbols.Symbol

ResultParameterOf returns the result parameter of a behavior or step, inherited ones included, or nil when it has none.

func (*Model) SatisfiesElementFilter

func (m *Model) SatisfiesElementFilter(f symbols.ElementFilter, cand *symbols.Symbol) bool

SatisfiesElementFilter reports whether cand is selected by the filter condition. It is the form the symbol layer's enumeration installs (see symbols.Index.SetElementFilter): a condition that cannot be evaluated, or that is not boolean-valued, keeps the candidate rather than dropping it — the diagnostic is what reports it (see passes.checkElementFilters), because losing model content silently is worse than surfacing an element a filter meant to hide.

func (*Model) SatisfyMembersOf

func (m *Model) SatisfyMembersOf(view *symbols.Symbol) []*symbols.Symbol

SatisfyMembersOf returns the viewpoint-claiming `satisfy` usages in a view's body followed by those of the views it specializes, in declaration order and once each: a satisfy is inherited the way an expose is.

func (*Model) SatisfyTarget

func (m *Model) SatisfyTarget(sat *symbols.Symbol) (*symbols.Symbol, string)

SatisfyTarget returns the element a satisfy member names and the reference as written. A satisfy reference is recorded as a subsetting rather than a reference subsetting, so it has no effective name to read the target from.

func (*Model) ScalarSymbol added in v0.5.0

func (m *Model) ScalarSymbol(prim PrimType) *symbols.Symbol

ScalarSymbol returns the library definition a lattice element stands for (`ScalarValues::Natural` for PrimNatural), or nil when none is loaded.

func (*Model) SelectCall added in v0.5.0

func (m *Model) SelectCall(scope *symbols.Scope, e *ast.InvocationExpr, performs Performs) *InvocationSelection

SelectCall selects what e calls, its arguments typed as the checker types them; with no checker's typing installed the arguments are unknown, so arity and names alone decide.

func (*Model) SelectInvocation added in v0.5.0

func (m *Model) SelectInvocation(scope *symbols.Scope, e *ast.InvocationExpr, args []Argument, performs Performs) *InvocationSelection

SelectInvocation chooses the declaration e calls: the most specific candidate the arguments fit, or the first in lookup order when an argument's type is unknown. Memoized per node/scope.

func (*Model) SelectsVariantOf

func (m *Model) SelectsVariantOf(sym, variant *symbols.Symbol) bool

SelectsVariantOf reports whether variant is a variant sym may be bound to: one declared for sym itself, or for a variation sym specializes — a usage redefining a variation selects among the variants of what it redefines.

func (*Model) SetArgumentTyper added in v0.5.0

func (m *Model) SetArgumentTyper(t ArgumentTyper)

SetArgumentTyper installs the checker's argument typing on the model. Selections memoized under a different typing are dropped, so none outlives the typing it read; installing the typing already in place keeps them.

func (*Model) ShapeFeatures added in v0.5.0

func (m *Model) ShapeFeatures(typ *symbols.Symbol) []ShapeFeature

ShapeFeatures returns the features an object of typ carries, in shape order: its own then its inherited members, less what is no feature, what frames every object, and the variants a variation offers.

func (*Model) SupertypesProvisional added in v0.2.0

func (m *Model) SupertypesProvisional(sym *symbols.Symbol) bool

SupertypesProvisional reports whether sym's supertypes were last derived from a metadata annotation whose type had not resolved yet, so the answer may still change and must not be recorded as a fact.

func (*Model) UnioningTypes added in v0.1.2

func (m *Model) UnioningTypes(sym *symbols.Symbol) []*symbols.Symbol

UnioningTypes returns the resolved targets of sym's `unions` relationships: the types sym is declared to be the union of (KerML 1.0 §8.3.3). Unioning is not a generalization edge — a union is constrained by its members rather than inheriting from them — so it is resolved on its own. The result is memoized.

func (*Model) UnitProductOfExpr added in v0.5.0

func (m *Model) UnitProductOfExpr(scope *symbols.Scope, node ast.Node) (UnitProduct, error)

UnitProductOfExpr reads a unit expression as the product of the named units it multiplies, divides and raises; it accepts and rejects exactly what UnitTermOfExpr does.

func (*Model) UnitProductOfExprBy added in v0.5.0

func (m *Model) UnitProductOfExprBy(node ast.Node, lookup UnitLookup) (UnitProduct, error)

UnitProductOfExprBy reads a unit expression, identifying each named unit by what lookup resolves it to; a name lookup does not know is kept by its text.

func (*Model) UnitTermOf

func (m *Model) UnitTermOf(sym *symbols.Symbol) (UnitTerm, error)

UnitTermOf reduces a measurement unit to base units. A unit declared with a conversion to a reference unit contributes that conversion's factor; a unit declared as an expression of other units reduces through that expression; a unit of dimension one reduces to no base unit at all; and a unit that is declared in terms of nothing else is itself a base unit.

The reduction is memoized per symbol, and read from the facts installed for a library symbol rather than derived again.

func (*Model) UnitTermOfExpr

func (m *Model) UnitTermOfExpr(scope *symbols.Scope, node ast.Node) (UnitTerm, error)

UnitTermOfExpr reduces an expression in unit position — a measurement unit, or a product, quotient or power of them — resolving names in scope.

func (*Model) UnmatchedConnectorEnds

func (m *Model) UnmatchedConnectorEnds(sym *symbols.Symbol) (*symbols.Symbol, []*symbols.Symbol)

UnmatchedConnectorEnds returns the ends the connector sym declares that redefine no end of a general connector, together with the general connector that has too few ends. A connector with no connector-like general — an untyped `connect a to b` — has none: there is nothing to match against.

func (*Model) UsageMayTimeVary added in v0.2.0

func (m *Model) UsageMayTimeVary(sym *symbols.Symbol) bool

UsageMayTimeVary derives SysML Usage::mayTimeVary (SysML v2 §8.3.6.4).

func (*Model) VariantOf

func (m *Model) VariantOf(sym *symbols.Symbol, name string) (*symbols.Symbol, bool)

VariantOf returns the variant of sym named name, and whether sym offers one.

func (*Model) VariantsOf

func (m *Model) VariantsOf(sym *symbols.Symbol) []*symbols.Symbol

VariantsOf returns the variants sym offers, in declaration order: those declared for it and those it inherits from the variation it specializes, the enumerated values of an enumeration among them. A `variant` inherited from a type that is not a variation point offers no choice, so it is an ordinary member here too.

func (*Model) VariationPointOwning

func (m *Model) VariationPointOwning(sym *symbols.Symbol) *symbols.Symbol

VariationPointOwning returns the variation point sym is a variant of, or nil when sym is not a variant of one: unlike VariationOwning it accepts an owner that is a variation by specialization without restating the modifier.

func (*Model) ViewConformance

func (m *Model) ViewConformance(view *symbols.Symbol, eval ConcernEvaluator) (*ViewConformance, error)

ViewConformance evaluates whether view conforms to the viewpoints its body satisfies: every concern a viewpoint frames must be framed by the view and must hold of what the view exposes. A nil evaluator answers the structural question alone; a non-view is ErrNotAView, a view satisfying nothing no error.

func (*Model) ViewRenderings

func (m *Model) ViewRenderings(view *symbols.Symbol) ([]ViewRendering, error)

ViewRenderings returns the rendering members of view: its own in declaration order, followed by those of the views it specializes, once each. A view stating no rendering returns none, which is no error; a non-view is ErrNotAView. An abstract member states no rendering — every view inherits the standard library's `abstract ref rendering viewRendering` — so it is left out.

type PartyBinding

type PartyBinding struct {
	Party  *symbols.Symbol
	Kind   string // "stakeholder" or "actor"
	Name   string
	Owner  *symbols.Symbol
	Bound  *symbols.Symbol
	Reason string
}

PartyBinding is a stakeholder or actor of a viewpoint or view and what it is bound to. Reason is empty when the binding resolves.

type Performs added in v0.5.0

type Performs int

Performs is what a call site does with the declaration it names, which decides the kinds of declaration it may select.

const (
	// PerformsBehavior evaluates an expression: a calc answers; another behavior only
	// when no calc is named.
	PerformsBehavior Performs = iota
	// PerformsAction runs an action, as `action a = tag(x);` does: only actions answer.
	PerformsAction
)

type PortFeature

type PortFeature struct {
	Symbol    *symbols.Symbol
	Name      string
	Direction ast.FeatureDirection
}

PortFeature is a feature of a port, with the direction it has as seen through the port that was queried.

type PrimType

type PrimType int

PrimType classifies a symbol against the stdlib scalar value types (`ScalarValues`). It is the lattice the expression type checker reasons over; anything outside it (parts, items, enumerations, collections, unresolved names) is PrimUnknown and suppresses checking.

const (
	PrimUnknown PrimType = iota
	PrimBoolean
	PrimString
	PrimNatural
	PrimInteger
	PrimRational
	PrimReal
	PrimComplex
	PrimNumber
)

func PrimTypeOfValue added in v0.4.3

func PrimTypeOfValue(v Value) PrimType

PrimTypeOfValue returns the narrowest scalar type a constant is a value of; a whole number is an Integer (or Natural) whatever kind computed it.

func PrimWiden

func PrimWiden(a, b PrimType) PrimType

PrimWiden returns the more general of two numeric types, or PrimUnknown if either is not numeric.

func (PrimType) IsNumeric

func (p PrimType) IsNumeric() bool

IsNumeric reports whether p is part of the numeric tower.

func (PrimType) String

func (p PrimType) String() string

String returns the stdlib name of the type, or "unknown".

type Range

type Range struct {
	Lower Bound
	Upper Bound
}

Range is an extracted multiplicity [lower..upper]. For the single-bound form `[n]`, Lower and Upper are both n, except for `[*]`, whose lower bound is 0 (KerML 1.0 §8.2.5.11, multiplicity textual notation).

func AssumedRange

func AssumedRange() Range

AssumedRange is the multiplicity of a feature that declares none: a feature holds exactly one value unless it says otherwise (KerML 1.0 §7.4.5). It is the one notion of implicit multiplicity every layer holds a feature to.

func (Range) AllowsNone added in v0.5.0

func (r Range) AllowsNone() bool

AllowsNone reports whether the range admits no value at all: a known lower bound of 0, as `[0..1]` and `[*]` declare.

func (Range) CountViolation

func (r Range) CountViolation(count int64) string

CountViolation returns why count values do not conform to the range, phrased for a diagnostic, or "" when they conform or a bound is not evaluable. It is the one wording for a count against a multiplicity, shared by the static check on a bound value and the runtime check on a materialized default.

func (Range) HasBounds added in v0.5.0

func (r Range) HasBounds(lower, upper int64) (holds bool, ok bool)

HasBounds reports whether the range is exactly lower..upper — the spec's multiplicityHasBounds (SysML v2 8.3.3.1). ok is false when a bound is not evaluable, so callers can skip the check.

func (Range) Intersect added in v0.5.0

func (r Range) Intersect(o Range) Range

Intersect returns the range both ranges allow: the greater lower bound and the lesser upper bound, an unknown bound deferring to a known one.

func (Range) LowerLeUpper

func (r Range) LowerLeUpper() (valid bool, ok bool)

LowerLeUpper reports whether a range's lower bound does not exceed its upper bound. It returns ok=false when either bound is unknown (not evaluable), so callers can skip the check. An infinite upper always satisfies the ordering; an infinite lower is only valid when the upper is also infinite.

func (Range) Text added in v0.5.0

func (r Range) Text() string

Text renders the range in multiplicity notation: `[1]`, `[0..1]`, `[1..*]`. A bound that is not evaluable renders as `?`.

type Scale

type Scale struct {
	Num float64
	Den float64
}

Scale is a unit's scale factor as a ratio kept unevaluated, so a conversion whose factor is exact stays exact: `5.4 [km/h]` is `5.4·1000/3600 = 1.5 [m/s]`, where evaluating 1000/3600 first would answer 1.4999999999999998 and make a requirement's `<=` at its boundary come out wrong.

func UnitScale

func UnitScale(n float64) Scale

UnitScale is the scale factor n, as a whole ratio.

func (Scale) DividedBy

func (s Scale) DividedBy(other Scale) Scale

DividedBy returns the quotient of two ratios.

func (Scale) IsZero

func (s Scale) IsZero() bool

IsZero reports whether the ratio is zero or undefined, which no unit's scale factor is.

func (Scale) Pow

func (s Scale) Pow(exp float64) Scale

Pow raises the ratio to an exponent. A negative exponent inverts the ratio rather than raising it to a negative power, which would evaluate it: `h^-1` stays 1/3600 instead of becoming 0.0002777777777777778.

func (Scale) String

func (s Scale) String() string

String renders the ratio, as a ratio when it is not whole.

func (Scale) Times

func (s Scale) Times(other Scale) Scale

Times returns the product of two ratios.

type ShadowedUnitError

type ShadowedUnitError struct {
	Name     string          // the name as written in unit position
	Resolved *symbols.Symbol // the declaration the name resolved to
	Shadowed *symbols.Symbol // the measurement unit that declaration hid, or nil
	// ShadowedName is the qualified name of Shadowed, which is how a message names
	// a unit the model did not write.
	ShadowedName string
	Namespace    string // qualified name of the namespace Resolved was declared in
	Suggestion   string // qualified spelling that names the shadowed unit
}

ShadowedUnitError reports a name in unit position that resolved to a declaration which is not a measurement unit, naming the unit it hid.

func (*ShadowedUnitError) Error

func (e *ShadowedUnitError) Error() string

func (*ShadowedUnitError) Unwrap

func (e *ShadowedUnitError) Unwrap() error

Unwrap reports the error as a not-a-unit error, which is the condition a caller tests for.

type ShapeFeature added in v0.5.0

type ShapeFeature struct {
	Name string
	// Symbol is the last declaration of Name in the type's members, own then inherited.
	Symbol *symbols.Symbol
	// Declared is the first: the model's own restatement where it has one.
	Declared *symbols.Symbol
}

ShapeFeature is one feature of an object's shape: the name it is held under and the declaration whose value it holds, which for a redefined name is the redefinition's target (a redefinition shares its target's value).

type UnitFactor

type UnitFactor struct {
	Unit     *symbols.Symbol
	Exponent float64
}

UnitFactor is one base unit raised to an exponent.

type UnitLookup added in v0.5.0

type UnitLookup func(qn *ast.QualifiedName) (*symbols.Symbol, bool)

UnitLookup resolves a unit name written in a unit expression to its declaration, reporting false for a name it does not know.

type UnitPower added in v0.5.0

type UnitPower struct {
	Unit         *symbols.Symbol // the unit the name resolves to, nil where it resolves to none
	Name         string          // the unit as the model wrote it, quoted where the notation must (`'A/m'`)
	Exponent     float64
	DimensionOne bool      // the unit reduces to no base unit: an angle, a ratio, a count
	Reduces      *UnitTerm // what a unit resolving to none reduces to, where known; nil otherwise
}

UnitPower is a named measurement unit raised to an exponent: one factor of a unit product, `N*m` being the powers N¹ and m¹.

type UnitProduct added in v0.5.0

type UnitProduct struct {
	Powers []UnitPower
}

UnitProduct is a unit as a sorted product of powers of the units the model named, the canonical display form (`N*m`, `m**2`); UnitTerm, not this, decides conversion.

func NamedUnitProduct added in v0.5.0

func NamedUnitProduct(unit *symbols.Symbol, name string, dimensionOne bool) UnitProduct

NamedUnitProduct is the product of one named unit to the first power, spelt as one name: text that is no name is quoted so the product reads back as itself.

func OpaqueUnitProduct added in v0.5.0

func OpaqueUnitProduct(name string, reduces UnitTerm) UnitProduct

OpaqueUnitProduct is the product of one unit that resolves to no declaration, known by its text and what it reduces to; the reduction tells two so spelt apart.

func (UnitProduct) DividedBy added in v0.5.0

func (p UnitProduct) DividedBy(q UnitProduct) UnitProduct

DividedBy returns the quotient of two unit products.

func (UnitProduct) Equal added in v0.5.0

func (p UnitProduct) Equal(q UnitProduct) bool

Equal reports whether two products are the same units to the same exponents.

func (UnitProduct) IsEmpty added in v0.5.0

func (p UnitProduct) IsEmpty() bool

IsEmpty reports whether the product names no unit, as a bare number does.

func (UnitProduct) NamesDimensionOne added in v0.5.0

func (p UnitProduct) NamesDimensionOne() bool

NamesDimensionOne reports whether the product is a named dimension-one unit (`rad`, `°`, `sr`) rather than nothing or a ratio (`°/rad`) that cancels to a number.

func (UnitProduct) Pow added in v0.5.0

func (p UnitProduct) Pow(exp float64) UnitProduct

Pow raises every power of the product to exp.

func (UnitProduct) Root added in v0.5.0

func (p UnitProduct) Root(n float64) (UnitProduct, bool)

Root divides every power by n, reporting false where a power does not divide into a whole exponent: `m**2` has a square root `m`, `rad` and `km*m` have none.

func (UnitProduct) String added in v0.5.0

func (p UnitProduct) String() string

String renders the product as the notation reads it back: positive powers joined by `*`, negative ones grouped after one `/`, an exponent other than one as `**n`.

func (UnitProduct) Times added in v0.5.0

func (p UnitProduct) Times(q UnitProduct) UnitProduct

Times returns the product of two unit products.

type UnitTerm

type UnitTerm struct {
	Scale   Scale
	Factors []UnitFactor
}

UnitTerm is a measurement unit reduced to a scale factor over base units: the product of Scale and each base unit raised to its exponent. `km/h` reduces to Scale 1000/3600 over `SI::m` and `SI::s^-1`, which is what makes two units comparable — they are commensurable when their factors agree, and a magnitude converts between them by the ratio of their scales.

Factors are ordered by base-unit qualified name and carry no zero exponents, so two terms over the same base units compare element-wise.

func (UnitTerm) BaseProduct added in v0.5.0

func (t UnitTerm) BaseProduct() UnitProduct

BaseProduct is the term's base units as a product named by their symbols (`m`, `s`); a magnitude over it is the term's magnitude times the term's scale.

func (UnitTerm) Commensurable

func (t UnitTerm) Commensurable(other UnitTerm) bool

Commensurable reports whether both terms are expressed over the same base units with the same exponents, so a magnitude in one converts to the other.

func (UnitTerm) DimensionKey

func (t UnitTerm) DimensionKey() string

DimensionKey identifies the base units the term is over, exponents included but scale excluded: two terms share a key exactly when they are commensurable.

func (UnitTerm) Dimensionless

func (t UnitTerm) Dimensionless() bool

Dimensionless reports whether the term has no base units, as a count or a ratio of like quantities has.

func (UnitTerm) DividedBy

func (t UnitTerm) DividedBy(other UnitTerm) UnitTerm

DividedBy returns the quotient of two terms.

func (UnitTerm) Normalized

func (t UnitTerm) Normalized() UnitTerm

Normalized restores the term's invariant: repeated base units summed, those that cancel dropped, the rest ordered by name. For a term built from outside.

func (UnitTerm) Pow

func (t UnitTerm) Pow(exp float64) UnitTerm

Pow raises the term to an exponent, scale included.

func (UnitTerm) Same added in v0.5.0

func (t UnitTerm) Same(other UnitTerm) bool

Same reports whether two terms are one reduction: commensurable at equal scale.

func (UnitTerm) String

func (t UnitTerm) String() string

String renders the term over its base units ("1000·m·s⁻¹"), for a diagnostic that has to say what a unit reduced to.

func (UnitTerm) Times

func (t UnitTerm) Times(other UnitTerm) UnitTerm

Times returns the product of two terms.

type Value

type Value struct {
	Kind ValueKind
	Int  int64
	Real float64
	Bool bool
}

Value is a model-level-evaluated constant. Only the field selected by Kind is meaningful. This is a deliberately small subset: the constraint checks that need evaluation (multiplicity bounds, some guards) operate over integers, reals, booleans, and the infinity bound.

func EvalBinary

func EvalBinary(op ast.OperatorKind, l, r Value) (Value, bool)

EvalBinary evaluates a binary operator on two constant values. Returns (result, true) if successful, (zero, false) otherwise.

func EvalUnary

func EvalUnary(op ast.OperatorKind, v Value) (Value, bool)

EvalUnary evaluates a unary operator on a constant value. Returns (result, true) if successful, (zero, false) otherwise.

func Pow

func Pow(l, r Value) (Value, error)

Pow evaluates l ** r (equivalently l ^ r) — the single implementation the constant folder and the runtime share, so a folded and an evaluated exponentiation agree. Integer operands with a non-negative exponent give an Integer, as IntegerFunctions::'**' declares; every other numeric combination gives a Real, as RealFunctions::'**' does. A result that is not a finite value of that kind is an error rather than a NaN, an infinity, or a wrapped integer: the folder declines on it, the runtime reports it.

func (Value) IsNumeric

func (v Value) IsNumeric() bool

IsNumeric reports whether the value is an integer or a real.

func (Value) WholeNumber added in v0.4.3

func (v Value) WholeNumber() (int64, bool)

WholeNumber returns the value as an Integer when it is one: an integer, or a finite real with no fractional part within the Integer range (4 / 2 is 2.0).

type ValueKind

type ValueKind int

ValueKind discriminates a model-level constant value.

const (
	ValInvalid ValueKind = iota
	ValInt
	ValReal
	ValBool
	ValInfinity // the `*` bound / unbounded value
)

type Verdict

type Verdict int

Verdict is the outcome of a conformance question. A verdict is never guessed: what could not be evaluated is VerdictUnevaluable with a reason, never a pass.

const (
	// VerdictConforms is a question answered in the affirmative.
	VerdictConforms Verdict = iota
	// VerdictViolated is a question answered in the negative: a concern the view
	// does not frame, or a condition that evaluated to false.
	VerdictViolated
	// VerdictUnevaluable is a question no answer could be reached for.
	VerdictUnevaluable
	// VerdictNotEvaluated is a structurally conforming concern whose conditions
	// were not evaluated, because the caller supplied no evaluator.
	VerdictNotEvaluated
)

func (Verdict) String

func (v Verdict) String() string

type ViewConformance

type ViewConformance struct {
	View       *symbols.Symbol
	Exposed    []*symbols.Symbol
	Viewpoints []ViewpointConformance
	Verdict    Verdict
}

ViewConformance is a view's conformance to the viewpoints it satisfies.

type ViewRendering

type ViewRendering struct {
	// Member is the `render`/`rendering` member itself.
	Member *symbols.Symbol
	// Ref is the rendering as written, empty for a member naming none.
	Ref string
	// Rendering is what Ref resolves to, nil when it names nothing or does not
	// resolve.
	Rendering *symbols.Symbol
	// DeclaredIn is the view declaring the member: the view itself, or one it
	// specializes.
	DeclaredIn *symbols.Symbol
}

ViewRendering is one rendering member of a view, and the rendering it names.

type ViewpointConformance

type ViewpointConformance struct {
	// Satisfy is the satisfy usage, Ref its target as written and Viewpoint the
	// viewpoint it resolves to, nil when that is unresolved or no viewpoint.
	Satisfy   *symbols.Symbol
	Ref       string
	Viewpoint *symbols.Symbol
	// SatisfiedIn is the view declaring the satisfy: the view itself or one it
	// specializes.
	SatisfiedIn *symbols.Symbol
	Concerns    []ConcernConformance
	Parties     []PartyBinding
	Verdict     Verdict
	Reason      string
}

ViewpointConformance is what became of one `satisfy` in a view's body.

type ViolationReporter

type ViolationReporter interface {
	IsViolation(err error) bool
}

ViolationReporter tells whether an evaluator's error is a false verdict rather than a failure to evaluate. Without it, every error reads as a failure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL