compile

package
v1.46.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodiesToUCAST

func BodiesToUCAST(bs []ast.Body, opts *Opts) *ucast.UCASTNode

func ExtractMaskRuleRefFromAnnotations

func ExtractMaskRuleRefFromAnnotations(comp *ast.Compiler, ref ast.Ref) (ast.Ref, *ast.Error)

func ExtractUnknownsFromAnnotations

func ExtractUnknownsFromAnnotations(comp *ast.Compiler, ref ast.Ref) ([]ast.Ref, []*ast.Error)

func FromASTErrors

func FromASTErrors(errs ...*ast.Error) error

Types

type Constraint

type Constraint struct {
	Target   string
	Variant  string
	Builtins Set[string]
	Features Set[string]
}

Constraint lets us limit the Set that are allowed in a translation. There are hardcoded sets of supported Set. The constraints become effective during the post-PE analysis (compile.Checks()).

func NewConstraints

func NewConstraints(typ, variant string) (*Constraint, error)

NewConstraints returns a new Constraint object based on the type requested, ucast or sql.

func (*Constraint) AssertBuiltin

func (c *Constraint) AssertBuiltin(x string) error

func (*Constraint) AssertFeature

func (c *Constraint) AssertFeature(x string) error

func (*Constraint) Builtin

func (c *Constraint) Builtin(x string) bool

Builtin returns true if the builtin is supported by the constraint.

func (*Constraint) String

func (c *Constraint) String() string

func (*Constraint) Supports

func (c *Constraint) Supports(x string) bool

Supports allows us to encode more fluent constraints, like support for "not". It returns an error if the feature is not supported by the constraint.

type ConstraintSet

type ConstraintSet struct {
	Constraints []*Constraint
}

func NewConstraintSet

func NewConstraintSet(cs ...*Constraint) *ConstraintSet

func (*ConstraintSet) AssertBuiltin

func (cs *ConstraintSet) AssertBuiltin(x string) error

func (*ConstraintSet) AssertFeature

func (cs *ConstraintSet) AssertFeature(x string) error

AssertFeature returns an error if the feature is not supported by any of the constraints. The error contains the offending target/dialect pairs.

func (*ConstraintSet) Builtin

func (cs *ConstraintSet) Builtin(x string) bool

Builtin returns true if all the constraints in the set support the builtin.

func (*ConstraintSet) String

func (cs *ConstraintSet) String() string

func (*ConstraintSet) Supports

func (cs *ConstraintSet) Supports(x string) bool

Supports returns true if the feature is supported by all constraints.

type Constraints

type Constraints interface {
	Builtin(string) bool
	AssertBuiltin(string) error
	Supports(string) bool
	AssertFeature(string) error
}

type Details

type Details struct {
	Extra string `json:"details"`
}

func (*Details) Lines

func (d *Details) Lines() []string

type Opts

type Opts struct {
	Translations map[string]any
}

type Results

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

func Check

func Check(pq *rego.PartialQueries, constraints Constraints, shorts Set[string]) *Results

Check performs a set of checks on the given partial queries and support modules. The constraints are used to determine which features are allowed in the partial queries. The shorts are used to determine which short names are allowed, e.g. `input.foo` is allowed if it's mapped to some table column.

func (*Results) ASTErrors

func (r *Results) ASTErrors() []*ast.Error

type Set

type Set[T comparable] map[T]struct{}

func NewSet

func NewSet[T comparable](strs ...T) Set[T]

func ShortsFromMappings

func ShortsFromMappings(mappings map[string]any) Set[string]

func (Set[T]) Add

func (s Set[T]) Add(strs ...T) Set[T]

func (Set[T]) Clone

func (s Set[T]) Clone() Set[T]

func (Set[T]) Contains

func (s Set[T]) Contains(str T) bool

Contains checks if a string exists in the set

func (Set[T]) Intersection

func (s Set[T]) Intersection(other Set[T]) Set[T]

Intersection returns a new set containing elements present in both sets

Jump to

Keyboard shortcuts

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