scope

package
v0.24.4-1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const MaxDepth = 25

Variables

This section is empty.

Functions

func FromRecord

func FromRecord(run rt.Runtime, rec *g.Record) rt.Scope

creates a scope from a record requires the runtime in order to create default values for empty fields

func NewReadOnlyValue

func NewReadOnlyValue(name string, val g.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 g.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 g.Value) (err error)

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

func (*Chain) SetFieldDirty

func (s *Chain) SetFieldDirty(field string) (err error)

SetFieldDirty - tell the current scope the named value has changed.

type Empty

type Empty struct{}

func (Empty) FieldByName

func (k Empty) FieldByName(field string) (g.Value, error)

func (Empty) SetFieldByName

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

func (Empty) SetFieldDirty

func (k Empty) SetFieldDirty(field string) 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 []g.Value) *Pairs

func (*Pairs) FieldByName

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

func (*Pairs) SetFieldByName

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

func (*Pairs) SetFieldDirty

func (w *Pairs) SetFieldDirty(field string) (err error)

placeholder method: for now, determines whether the field exists

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 g.Value) *SingleValue

func (*SingleValue) FieldByName

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

func (*SingleValue) SetFieldByName

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

func (*SingleValue) SetFieldDirty

func (k *SingleValue) SetFieldDirty(field string) (err error)

placeholder method: for now, determines whether the field exists

func (*SingleValue) SetValue

func (k *SingleValue) SetValue(val g.Value)

backdoor for updating the value of held by this scope. panics if the value was created read-only

Jump to

Keyboard shortcuts

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