Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/design/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ system, subsystem, and unit levels:
reference
- **SymbolTable** (Unit) — registry mapping qualified names to declaration nodes
- **ReferenceResolver** (Unit) — resolves supertype, typing, metadata-type,
redefinition, import, satisfy, verify, allocate, expose, and (in a final pass) dotted
feature-chain connect/transition references by KerML 8.2.3.5 name resolution (delegating
to `NameResolver`: member visibility, filtered imports, import scoping); detects circular
redefinition, import, satisfy, verify, allocate, expose, and (in a final pass) connect/
binding/transition references — any of them possibly a dotted feature chain — by KerML
8.2.3.5 name resolution (delegating
to `NameResolver`: member visibility, filtered imports, import scoping, feature chains);
detects circular
imports; returns a `SemanticIndex` of resolved edges; also resolves the references written
inside expressions (guards, triggers, effects, `accept`/`send` payloads, constraints, `render`
targets) and reports each unresolved one at its token position; chooses the unresolved-reference
Expand All @@ -67,7 +69,9 @@ system, subsystem, and unit levels:
SysML2Tools extension selector
- **NameResolver** (Unit) — public KerML 8.2.3.5 name resolver (owned, imported, inherited
— including the implicit specializations of every element kind, which are lookup input
only and never edges —, aliased, and short-named memberships; full and visible resolution)
only and never edges —, aliased, and short-named memberships; full and visible resolution;
dotted feature chains resolved segment by segment through the previous feature's own and
inherited members)
used by `ReferenceResolver` (in an internal resolving mode) and by layout strategies for
references the semantic model did not resolve
- **SupertypeWalker** (Unit) — walks specialization chains; detects cyclic specialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,13 @@ presence/absence of the `FROM` keyword token itself. `ReferenceResolver` resolve

`VisitSatisfyRequirementUsage` builds a `SysmlSatisfyNode` for `satisfy X by Y;` usages. The
satisfied requirement's raw reference text is taken from `ownedReferenceSubsetting()` when the
`satisfy <ref>` form is used, falling back to the declared/typed name of the
`satisfy requirement <usageDeclaration>` form. The optional satisfying subject's raw reference
`satisfy <ref>` form is used. The `satisfy requirement r : R by s;` form declares its own
requirement usage `r`; that name is introduced by the statement and is not a reference, so the
requirement is the usage's feature typing (`R`), falling back to the declared name only for a
declaration without typing. The optional satisfying subject's raw reference
text comes from `satisfactionSubjectMember()` (the `by <subject>` clause), or is `null` when
absent.
absent. Either reference may be a dotted feature chain (`by system.sub1`), resolved by
`ReferenceResolver`.

**KerML declarations.** The KerML library files are parsed with the same grammar (see Local
Patch 4 in `Grammar/README.md`), so every named KerML declaration is indexed with the existing
Expand Down
54 changes: 46 additions & 8 deletions docs/design/sysml2-tools-language/semantic/model/name-resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,27 @@ instance serves one workspace.
listed target is checked to exist in the embedded standard library by a test.
- The global namespace is every top-level declaration of every loaded root namespace, user and
standard library alike (KerML 8.2.3.5.2).
- *Feature chains* (`a.b.c`, KerML 8.2.3.5.1): a reference containing a `.` outside single quotes
is split into **parts**. The first part is an ordinary (possibly qualified or `$::`-prefixed)
name, resolved by full resolution from the local namespace; every later part is resolved as
a sequence of **visible** lookups, starting in the element the previous part resolved to. That
lookup already has the semantics a chain needs: the feature's own inline members first, then
everything it inherits through its lookup general types (explicit typing, subsetting,
redefinition, and the implicit specializations — so `p1 :> p; p1.x` reaches the members of
`p`'s type, a port typed by a conjugated port definition reaches that definition's members, and
a member a nested usage redefines is the nested usage), transitively; only public memberships
are found, so a private or protected member is not reachable through a chain even by
subsetting, while the **first** part still sees its namespace's private members; and an alias
member resolves to its target. A chain resolves only when every part does; a part that does not
resolve leaves the whole reference unresolved. The result of a chain is the declared element of
the last part (`Resolve`) and, for callers that key relationships by feature instances, the
**instance path** (`ResolveFeatureChain`, internal): the first part's element followed by the
simple name of each later part's element — `P::p1::x::x1` for `p1.x.x1` although `x` is
declared by the type of `p`. For a reference without a chain the instance path equals the
element, so non-chain behavior is unchanged.
- *Quoted names* compare equal with and without their enclosing single quotes (`'PowerTrain'` and
`PowerTrain` name the same element, KerML 8.2.2.2.1) in owned and imported memberships, alias
short names, and top-level (global) names; dots and `::` inside quotes never split a name.
- *File-root imports* (resolving mode only): the imports written at the root of a source file are
not part of any namespace's `Children` in the declarations, so `RegisterRootImports` records
them against the qualified name of **every declaration the file contributes** (not merely its
Expand All @@ -131,17 +152,26 @@ instance serves one workspace.

- `Resolve(reference, localNamespace)` (KerML 8.2.3.5.1): a single segment by full resolution; a
`$::name` in the global namespace; otherwise the qualification part by this same process (it
must yield a namespace), then the last segment by visible resolution in that namespace. An
internal overload additionally accepts the file-root imports for a reference whose local
namespace is the file root itself.
must yield a namespace), then the last segment by visible resolution in that namespace. A
dotted reference is a **feature chain** (see Data Model): `SplitChain` splits it on `.` outside
quotes (a reference with no `.` takes a fast path that skips the split), the first part is
resolved as above, and each later part by `Lookup(segment, current, Visible)` (the cache and
the in-progress guard apply to every chain step). An internal overload additionally accepts the
file-root imports for a reference whose local namespace is the file root itself.
- `ResolveFeatureChain(reference, localNamespace, fileRootImports)` (internal): `Resolve` that
also returns the instance path of a chain (`FeatureChainResolution(Element, InstancePath)`).
`ReferenceResolver` records relationship ends (connect, bind, transition, allocate, satisfy,
verify) at the instance path, which is what `GeneralViewLayoutStrategy` maps to boxes, and the
declared element for type-like references (supertype, typing, redefinition).
- `ResolveRedefinedFeature(reference, owningType)` (KerML 8.2.3.5.1, Redefinition): `Resolve`
with each lookup general type (declared, then implicit) of `owningType` as the local namespace,
in turn. A bare name is looked up in the general type itself with the **RedefinitionTarget** scope —
as Inheritable (the redefining feature inherits from it, so the general type's private members
cannot be redefined, protected ones can) but without the redefined-member exclusion described
below, because library associations routinely redefine a name that a general type's own
feature already redefined; the enclosing namespaces outward from it, and qualified names,
resolve as in `Resolve`.
resolve as in `Resolve`. A redefinition target that is a chain (`:>> localClock.currentTime`)
resolves its first part this way and the remaining parts by visible resolution.
- `ResolveRedefinition(reference, owningType, redefiningFeature, fileRootImports)` (internal):
`ResolveRedefinedFeature`, then — a documented lenient deviation — ordinary `Resolve` from the
owning type; the redefining feature itself is never an acceptable target. When ordinary
Expand Down Expand Up @@ -192,14 +222,22 @@ rejected match does not stop the search for a later one that satisfies the condi
The lookup cache is keyed by (name, namespace, scope), so the implicit general types add one cached
lookup per (name, library type) the first time a name is searched through them. Measured on the OMG
corpus lint (251 files) the cost is about +3% CPU time (alternating runs, noisy machine), and the
embedded standard library compiles in comparable time.
embedded standard library compiles in comparable time. Feature chains add one cached visible
lookup per chain part, and quote equivalence a length check and, only for names that differ in
length by exactly two, a comparison; measured on the same corpus lint (four alternating runs
against the previous stage on a noisy machine) the chain stage costs about +2.5% mean CPU time
(wall time unchanged within noise).

##### Error Handling

Unresolvable names return `null` (`Resolve`, `ResolveRedefinedFeature`). Imports and
specializations may be circular (KerML 8.2.3.5.1); a lookup already
Unresolvable names return `null` (`Resolve`, `ResolveRedefinedFeature`, `ResolveFeatureChain`).
Imports and specializations may be circular (KerML 8.2.3.5.1); a lookup already
in progress for the same (name, namespace, scope) contributes nothing instead of recursing, so
resolution always terminates. Null arguments throw `ArgumentNullException`.
resolution always terminates. A feature that specializes a chain through itself
(`ref x : T :> x.y`) re-enters its own general types while they are being derived; the re-entry
contributes nothing, and a lookup that missed while that happened is not cached, so the answer
does not depend on which reference is resolved first. Null arguments throw
`ArgumentNullException`.

##### Dependencies

Expand Down
Loading
Loading