internal

package
v0.0.0-...-e936fb3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 10 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 (
	MinorCurrent   = 5
	MinorSupported = 4
	PatchSupported = 0
)
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 APIVersionSupported = Version(MinorSupported, PatchSupported)

APIVersionSupported is the back version until which deprecated features are still supported.

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

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

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 MakeInstance func(value interface{}) (instance interface{})

MakeInstance makes a new instance from a value.

Functions

func DecorateError

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

func EmbedStruct

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

func FileComment

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

func GenPath

func GenPath(root string) string

GenPath reports the directory in which to store generated files.

func IsBulkField

func IsBulkField(d ast.Decl) bool

func IsDef

func IsDef(s string) bool

func IsDefOrHidden

func IsDefOrHidden(s string) bool

func IsDefinition

func IsDefinition(label ast.Label) bool

func IsEllipsis

func IsEllipsis(x ast.Decl) bool

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

func IsHidden

func IsHidden(s string) bool

func IsRegularField

func IsRegularField(f *ast.Field) bool

func ListEllipsis

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

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

func NewComment

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 deprecated

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

Deprecated: use GetPackageInfo

func SetPackage

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

func ToExpr

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

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

ToFile converts an expression to a file.

Adjusts the spacing of x when needed.

func ToStruct

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

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

func Version

func Version(minor, patch int) int

Types

type Decimal

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.

type PkgInfo

type PkgInfo struct {
	Package *ast.Package
	Index   int // position in File.Decls
	Name    string
}

func GetPackageInfo

func GetPackageInfo(f *ast.File) PkgInfo

func (*PkgInfo) IsAnonymous

func (p *PkgInfo) IsAnonymous() bool

IsAnonymous reports whether the package is anonymous.

Jump to

Keyboard shortcuts

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