safe

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HackTillTemplatesCanEvaluatePatternTypes rt.Value

fix! ( at the very least should live in pattern but we need to remove its few -- tests and Determine -- dependencies on core

Functions

func Check

func Check(v rt.Value, want affine.Affinity) (err error)

func CheckList

func CheckList(v rt.Value) (err error)

func ConvertValue

func ConvertValue(run rt.Runtime, val rt.Value, out affine.Affinity) (ret rt.Value, err error)

func EnsureField

func EnsureField(ks rt.Kinds, rec *rt.Record, field string) (ret rt.Value, err error)

pulls a field out of this record, creating a sub-record if necessary

func FillRecord

func FillRecord(run rt.Runtime, rec *rt.Record, keys []string, vals []rt.Value) (ret *rt.Record, err error)

FillRecord fill the passed record with the arguments named by keys and values keys are optional, but if they exist must match the order of fields in the record; there doesnt have to be be a key for every field; they can be sparse. if there are more values than keys, this assumes the first few values are indexed ( keys are right justified ) returns the passed record if there's no error

func GetAssignment

func GetAssignment(run rt.Runtime, a rt.Assignment) (ret rt.Value, err error)

handles null assignments by returning "MissingEval" error ( cant live in package safe because package assign uses package safe )

func GetBool

func GetBool(run rt.Runtime, eval rt.BoolEval) (ret rt.Value, err error)

GetBool runs the specified eval, returning an error if the eval is nil.

func GetFlag

func GetFlag(run rt.Runtime, opt meta.Options) (ret bool)

safety for built in options means a panic if the option doesnt exist

func GetNumList

func GetNumList(run rt.Runtime, eval rt.NumListEval) (ret rt.Value, err error)

GetNumList returns an new iterator to walk the passed list, or an empty iterator if the value is null.

func GetNumber

func GetNumber(run rt.Runtime, eval rt.NumberEval) (ret rt.Value, err error)

GetNumber runs the specified eval, returning an error if the eval is nil.

func GetOptionalBool

func GetOptionalBool(run rt.Runtime, eval rt.BoolEval, fallback bool) (ret rt.Value, err error)

GetOptionalBool runs the optionally specified eval.

func GetOptionalNumber

func GetOptionalNumber(run rt.Runtime, eval rt.NumberEval, fallback float64) (ret rt.Value, err error)

GetOptionalNumber runs the optionally specified eval.

func GetOptionalNumbers

func GetOptionalNumbers(run rt.Runtime, eval rt.NumListEval, fallback []float64) (ret rt.Value, err error)

GetOptionalNumber runs the optionally specified eval.

func GetOptionalText

func GetOptionalText(run rt.Runtime, eval rt.TextEval, fallback string) (ret rt.Value, err error)

GetOptionalText runs the optionally specified eval.

func GetOptionalTexts

func GetOptionalTexts(run rt.Runtime, eval rt.TextListEval, fallback []string) (ret rt.Value, err error)

GetOptionalText runs the optionally specified eval.

func GetRecord

func GetRecord(run rt.Runtime, eval rt.RecordEval) (ret rt.Value, err error)

GetRecord runs the specified eval, returning an error if the eval is nil.

func GetRecordList

func GetRecordList(run rt.Runtime, eval rt.RecordListEval) (ret rt.Value, err error)

GetRecordList returns an new iterator to walk the passed list, or an empty iterator if the value is null.

func GetTemplateText

func GetTemplateText() (ret rt.Value)

func GetText

func GetText(run rt.Runtime, eval rt.TextEval) (ret rt.Value, err error)

GetText runs the specified eval, returning an error if the eval is nil.

func GetTextList

func GetTextList(run rt.Runtime, eval rt.TextListEval) (ret rt.Value, err error)

GetTextList returns an new iterator to walk the passed list, or an empty iterator if the value is null.

func IsKindOf

func IsKindOf(run rt.Runtime, obj, kind string) (ret bool, err error)

func ListIt

func ListIt(v rt.Value) (ret *sliceIt)

panics if the value isnt a list

func NewRecord

func NewRecord(ks rt.Kinds, cls string) (ret *rt.Record, err error)

helper for trying to create a record using a name from the passed typeset.

func ObjectText

func ObjectText(run rt.Runtime, eval rt.TextEval) (ret rt.Value, err error)

ObjectText - given an eval producing a name, return a string value of the object's id. can return a valid "empty" value for empty strings

func PopSeveral

func PopSeveral(run rt.Runtime, p int)

func Range

func Range(i, min, max int) (ret int, err error)

min inclusive, max exclusive

func RectifyText

func RectifyText(run rt.Runtime, val rt.Value, aff affine.Affinity, cls string) (ret rt.Value, err error)

used when converting values to fields that might require objects. if the target field (ex. a pattern local) requires text of a certain type and the incoming value is untyped, try to convert it.

func Run

func Run(run rt.Runtime, exe rt.Execute) (err error)

Run executes the passed statement using the passed runtime; does *not* error if the passed exec is nil.

func RunAll

func RunAll(run rt.Runtime, exes []rt.Execute) (err error)

Run executes the passed statement using the passed runtime; does *not* error if the passed exec is nil.

func SliceIt

func SliceIt(size int, next func(int) (rt.Value, error)) *sliceIt

func Truthy

func Truthy(v rt.Value) (ret bool)

func WriteText

func WriteText(run rt.Runtime, eval rt.TextEval) (err error)

WriteText evaluates t and outputs the results to w.

Types

type LabelFinder

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

func NewLabelFinder

func NewLabelFinder(run rt.Runtime, kind *rt.Kind) (ret *LabelFinder, err error)

func (*LabelFinder) FindNext

func (lf *LabelFinder) FindNext(k string) (ret int, err error)

returns nil on success; updates internals

type MissingEval

type MissingEval string

MissingEval error type for unknown variables while processing loops.

func (MissingEval) Error

func (e MissingEval) Error() string

Error returns the name of the unknown variable.

Jump to

Keyboard shortcuts

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