internal

package
v0.3.0-alpha5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package internal exposes some cue internals to other packages.

A better name for this package would be technicaldebt.

Index

Constants

View Source
const MaxDepth = 20

MaxDepth indicates the maximum evaluation depth. This is there to break cycles in the absence of cycle detection.

It is registered in a central place to make it easy to find all spots where cycles are broken in this brute-force manner.

TODO(eval): have cycle detection.

Variables

View Source
var BaseContext = apd.BaseContext.WithPrecision(24)

BaseContext is used as CUEs default context for arbitrary-precision decimals

View Source
var CheckAndForkRuntime func(runtime, value interface{}) interface{}

CheckAndForkRuntime checks that value is created using runtime, panicking if it does not, and returns a forked runtime that will discard additional keys.

View Source
var CoreValue func(value interface{}) (runtime, vertex interface{})

CoreValue returns an *runtime.Index and *adt.Vertex for a cue.Value. It returns nil if value is not a cue.Value.

View Source
var DebugStr func(x interface{}) string

DebugStr prints a syntax node.

View Source
var ErrIncomplete = errors.New("incomplete value")

ErrIncomplete can be used by builtins to signal the evaluation was incomplete.

View Source
var ErrInexact = errors.New("inexact subsumption")
View Source
var EvalExpr func(value, expr interface{}) (result interface{})

EvalExpr evaluates an expression within an existing struct value. Identifiers only resolve to values defined within the struct.

Expressions may refer to builtin packages if they can be uniquely identified

Both value and result are of type cue.Value, but are an interface to prevent cyclic dependencies.

TODO: extract interface

View Source
var FromGoType func(instance, x interface{}) interface{}

FromGoType converts an arbitrary Go type to the corresponding CUE value. instance must be of type *cue.Instance. The returned value is a cue.Value, which the caller must cast to.

View Source
var FromGoValue func(instance, x interface{}, allowDefault bool) interface{}

FromGoValue converts an arbitrary Go value to the corresponding CUE value. instance must be of type *cue.Instance. The returned value is a cue.Value, which the caller must cast to.

View Source
var GetRuntime func(instance interface{}) interface{}

GetRuntime reports the runtime for an Instance or Value.

View Source
var MakeInstance func(value interface{}) (instance interface{})

MakeInstance makes a new instance from a value.

View Source
var UnifyBuiltin func(v interface{}, kind string) interface{}

UnifyBuiltin returns the given Value unified with the given builtin template.

Functions

func DecorateError added in v0.1.0

func DecorateError(info error, err errors.Error) errors.Error

func EmbedStruct added in v0.2.0

func EmbedStruct(s *ast.StructLit) *ast.EmbedDecl

func FileComment added in v0.2.0

func FileComment(f *ast.File) *ast.CommentGroup

func GenPath added in v0.1.0

func GenPath(root string) string

GenPath reports the directory in which to store generated files.

func IsBulkField added in v0.2.0

func IsBulkField(d ast.Decl) bool

func IsDef added in v0.2.0

func IsDef(s string) bool

func IsDefOrHidden added in v0.2.0

func IsDefOrHidden(s string) bool

func IsDefinition added in v0.2.0

func IsDefinition(label ast.Label) bool

func IsEllipsis added in v0.1.0

func IsEllipsis(x ast.Decl) bool

IsEllipsis reports whether the declaration can be represented as an ellipsis.

func IsHidden added in v0.2.0

func IsHidden(s string) bool

func IsRegularField added in v0.2.0

func IsRegularField(f *ast.Field) bool

func ListEllipsis added in v0.0.6

func ListEllipsis(n *ast.ListLit) (elts []ast.Expr, e *ast.Ellipsis)

ListEllipsis reports the list type and remaining elements of a list. If we ever relax the usage of ellipsis, this function will likely change. Using this function will ensure keeping correct behavior or causing a compiler failure.

func NewAttr added in v0.1.0

func NewAttr(name, str string) *ast.Attribute

func NewComment added in v0.1.0

func NewComment(isDoc bool, s string) *ast.CommentGroup

NewComment creates a new CommentGroup from the given text. Each line is prefixed with "//" and the last newline is removed. Useful for ASTs generated by code other than the CUE parser.

func PackageInfo added in v0.0.6

func PackageInfo(f *ast.File) (p *ast.Package, name string, tok token.Pos)

func SetPackage added in v0.2.0

func SetPackage(f *ast.File, name string, overwrite bool)

func ToExpr added in v0.1.0

func ToExpr(n ast.Node) ast.Expr

ToExpr converts a node to an expression. If it is a file, it will return it as a struct. If is an expression, it will return it as is. Otherwise it panics.

func ToFile added in v0.1.0

func ToFile(n ast.Node) *ast.File

ToFile converts an expression to a file.

Adjusts the spacing of x when needed.

func ToStruct added in v0.2.2

func ToStruct(f *ast.File) *ast.StructLit

ToStruct gets the non-preamble declarations of a file and puts them in a struct.

Types

type Attr added in v0.1.0

type Attr struct {
	Fields []keyValue
	Err    error
}

Attr holds positional information for a single Attr.

func NewNonExisting added in v0.1.0

func NewNonExisting(key string) Attr

NewNonExisting creates a non-existing attribute.

func ParseAttrBody added in v0.1.0

func ParseAttrBody(pos token.Pos, s string) (a Attr)

func (*Attr) Flag added in v0.1.0

func (a *Attr) Flag(pos int, key string) (bool, error)

Flag reports whether an entry with the given name exists at position pos or onwards or an error if the attribute is invalid or if the first pos-1 entries are not defined.

func (*Attr) Int added in v0.1.0

func (a *Attr) Int(pos int) (int64, error)

Int reports the integer at the given position or an error if the attribute is invalid, the position does not exist, or the value at the given position is not an integer.

func (*Attr) Lookup added in v0.1.0

func (a *Attr) Lookup(pos int, key string) (val string, found bool, err error)

Lookup searches for an entry of the form key=value from position pos onwards and reports the value if found. It reports an error if the attribute is invalid or if the first pos-1 entries are not defined.

func (*Attr) String added in v0.1.0

func (a *Attr) String(pos int) (string, error)

String reports the possibly empty string value at the given position or an error the attribute is invalid or if the position does not exist.

type Decimal added in v0.0.5

type Decimal = apd.Decimal

A Decimal is an arbitrary-precision binary-coded decimal number.

Right now Decimal is aliased to apd.Decimal. This may change in the future.

Directories

Path Synopsis
cmd
qgo
qgo builds CUE builtin packages from Go packages.
qgo builds CUE builtin packages from Go packages.
Package copy provides utilities to copy files and directories.
Package copy provides utilities to copy files and directories.
core
adt
Package adt represents partially and fully evaluated CUE types.
Package adt represents partially and fully evaluated CUE types.
convert
Package convert allows converting to and from Go values and Types.
Package convert allows converting to and from Go values and Types.
debug
Package debug prints a given ADT node.
Package debug prints a given ADT node.
dep
Package dep analyzes dependencies between values.
Package dep analyzes dependencies between values.
eval
Package eval contains the high level CUE evaluation strategy.
Package eval contains the high level CUE evaluation strategy.
subsume
Package subsume defines various subsumption relations.
Package subsume defines various subsumption relations.
validate
Package validate collects errors from an evaluated Vertex.
Package validate collects errors from an evaluated Vertex.
walk
walk provides functions for visiting the nodes of an ADT tree.
walk provides functions for visiting the nodes of an ADT tree.
Package source contains utility functions that standardize reading source bytes across cue packages.
Package source contains utility functions that standardize reading source bytes across cue packages.
Package str provides string manipulation utilities.
Package str provides string manipulation utilities.
Package task provides a registry for tasks to be used by commands.
Package task provides a registry for tasks to be used by commands.
third_party
yaml
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.

Jump to

Keyboard shortcuts

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