objref

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 9 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 objref reads the references every surface names a held object by — `#<id>`, a declared name, or either followed by the features walked from it (`car.wheels[2]`) — and walks such a path through an object's feature values. The REPL's commands and the gRPC service's document-query bindings share it, so one spelling reaches one object on both.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectionElements

func CollectionElements(val runtime.Value) []runtime.Value

CollectionElements is what a multi-valued feature holds, in order; its contents are either a sequence or a set.

func CutSeparator

func CutSeparator(text string) (sep, rest string, ok bool)

CutSeparator splits the segment separator text starts with from what follows.

func DeclaredRun

func DeclaredRun(segments []Segment) string

DeclaredRun is the `::`-joined registered names of segments that may all name a declaration — none reached through `.` or an index — or "" when one is not.

func Head(segments []Segment) int

Head is the count of leading segments that may name a declaration: the run before the first `.` or index, since a segment after `.` is only ever a feature.

func IsID

func IsID(text string) bool

IsID reports whether text is an id alone, `#` followed by digits.

func IsNamespace

func IsNamespace(sym *symbols.Symbol) bool

IsNamespace reports whether sym is a package or namespace, which holds members but is never an object.

func JoinTyped

func JoinTyped(segments []Segment) string

JoinTyped spells segments as the qualified name they were written as.

func LeadingDigits

func LeadingDigits(text string) string

LeadingDigits returns the run of ASCII digits text starts with.

func LooksLikePath

func LooksLikePath(text string) bool

LooksLikePath reports whether text can only be an object reference — it starts with an id or walks a feature with `.` or an index — so a failure to resolve it is reported as such rather than tried as a declaration's name.

func NamespaceKind

func NamespaceKind(sym *symbols.Symbol) string

NamespaceKind names what a namespace symbol is for a message.

Types

type PathError

type PathError struct {
	Object  string
	Segment string
	Detail  string
	// Err is what kept the segment's feature value from materializing, nil when
	// the segment reached a value that is no object or no feature at all.
	Err error
}

PathError reports a segment of an object reference that names no object of the one before it: Object is that object as the surface reports it, Segment the offending segment as written.

func (*PathError) Error

func (e *PathError) Error() string

func (*PathError) Unwrap

func (e *PathError) Unwrap() error

type Ref

type Ref struct {
	Text     string
	ID       int64 // the root object's id, 0 when the root is a declared name
	Segments []Segment
}

Ref is a parsed object reference.

func Parse

func Parse(text string) (Ref, error)

Parse reads an object reference, reporting what makes text none.

type RefError

type RefError struct {
	Ref    string
	Detail string
	// Named is the `::`-joined run of names read before a character no unquoted
	// name holds stopped the text: `T::SA` in `T::SA-506`.
	Named string
	// Hint is what Named may have meant, appended to the report.
	Hint string
}

RefError reports text that is no object reference at all.

func (*RefError) Error

func (e *RefError) Error() string

type Segment

type Segment struct {
	Text   string // as written, quotes kept, so a lookup reads the notation
	Name   string // the declaration or feature it names
	Dotted bool   // written after a `.` rather than `::`
	Index  int    // 1-based element of a multi-valued feature, 0 for none
}

Segment is one segment of an object reference.

type Walker

type Walker struct {
	Runtime *runtime.Context
	// Index, when set, tells library-declared features apart in an unknown-feature
	// hint, which counts them rather than listing them.
	Index *symbols.Index
	// Format spells a value a path reached in place of an object; nil formats
	// as the runtime does.
	Format func(runtime.Value) string
}

Walker walks object paths through the feature values of a runtime's objects.

func (Walker) DeclaredFeatureHint

func (w Walker) DeclaredFeatureHint(features []runtime.EffectiveFeature) string

DeclaredFeatureHint is featureListHint for the features an object of a declaration will have, before one is materialized.

func (Walker) Walk

func (w Walker) Walk(inst *runtime.Instance, label string, segments []Segment) (*runtime.Instance, string, error)

Walk follows segments through feature values from inst, labelled label, to the object they reach. Each segment must name a feature of the object before it that holds an object — one, or one picked by index from a multi-valued feature — and the first that does not is a PathError. The label spells walked features after `.`, which only ever reads as a feature.

Jump to

Keyboard shortcuts

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