scope

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDepth = 25

Variables

This section is empty.

Functions

func FromRecord

func FromRecord(ks rt.Kinds, rec *rt.Record) rt.Scope

creates a scope from a record requires kinds so that unit tests can create sub-records safely

func NewReadOnlyValue

func NewReadOnlyValue(name string, val rt.Value) rt.Scope

creates a scope that provides a single named value; errors if the author tries to *replace* the value, noting that altering the *contents* of a value does not cause an error. ( ex. altering the fields of a record value or the elements of an array. )

Types

type Chain

type Chain struct {
	rt.Scope
	// contains filtered or unexported fields
}

a linked list of scopes: if a variable isnt found in the first scope, the next is searched, and so on.

func MakeChain

func MakeChain(top rt.Scope) Chain

func (*Chain) FieldByName

func (s *Chain) FieldByName(field string) (ret rt.Value, err error)

FieldByName returns the value at 'field'

func (*Chain) PopScope

func (s *Chain) PopScope()

func (*Chain) PushScope

func (s *Chain) PushScope(top rt.Scope)

func (*Chain) ReplaceScope

func (s *Chain) ReplaceScope(top rt.Scope) Chain

rewrite the current scope as the passed scope returns the previous scope ( used for function calls; they "hide" all variables from the caller stack )

func (*Chain) RestoreScope

func (s *Chain) RestoreScope(c Chain)

func (*Chain) SetFieldByName

func (s *Chain) SetFieldByName(field string, v rt.Value) (err error)

SetFieldByName writes the value of 'v' into the value at 'field'.

type Empty

type Empty struct{}

func (Empty) FieldByName

func (Empty) FieldByName(field string) (rt.Value, error)

func (Empty) SetFieldByName

func (Empty) SetFieldByName(field string, val rt.Value) error

type Pairs

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

a scope which provides a single named field.

func NewPairs

func NewPairs(ks []string, vs []rt.Value) *Pairs

func (*Pairs) FieldByName

func (w *Pairs) FieldByName(field string) (ret rt.Value, err error)

func (*Pairs) SetFieldByName

func (w *Pairs) SetFieldByName(field string, val rt.Value) (err error)

type SingleValue

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

a scope which provides a single named field.

func NewSingleValue

func NewSingleValue(name string, val rt.Value) *SingleValue

func (*SingleValue) FieldByName

func (k *SingleValue) FieldByName(field string) (ret rt.Value, err error)

func (*SingleValue) SetFieldByName

func (k *SingleValue) SetFieldByName(field string, val rt.Value) (err error)

Jump to

Keyboard shortcuts

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