istio: istio.io/istio/mixer/pkg/lang/ast Index | Files

package ast

import "istio.io/istio/mixer/pkg/lang/ast"

Index

Package Files

expr.go func.go

func ExtractEQMatches Uses

func ExtractEQMatches(src string) (map[string]interface{}, error)

ExtractEQMatches extracts equality sub expressions from the match expression. It only extracts `attribute == literal` type equality matches. It returns a list of <attribute name, value> such that if **any** of these comparisons is false, the expression will evaluate to false. These sub expressions can be hoisted out of the match clause and evaluated separately. For example destination.service == "abc" -- Used to index rules by destination service. context.protocol == "tcp" -- Used to filter rules by context

func FuncMap Uses

func FuncMap(functions []FunctionMetadata) map[string]FunctionMetadata

FuncMap generates a full function map, combining the intrinsic functions needed for type-checking, along with external functions that are supplied as the functions parameter.

type Constant Uses

type Constant struct {
    StrValue string
    Value    interface{}
    Type     dpb.ValueType
}

Constant models a typed constant.

func (*Constant) String Uses

func (c *Constant) String() string

type Expression Uses

type Expression struct {
    // Oneof the following
    Const *Constant
    Var   *Variable
    Fn    *Function
}

Expression is a simplified expression AST

func Parse Uses

func Parse(src string) (ex *Expression, err error)

Parse parses a given expression to ast.Expression.

func (*Expression) EvalType Uses

func (e *Expression) EvalType(attrs attribute.AttributeDescriptorFinder, fMap map[string]FunctionMetadata) (valueType dpb.ValueType, err error)

EvalType Function an expression using fMap and attribute vocabulary. Returns the type that this expression evaluates to.

func (*Expression) String Uses

func (e *Expression) String() string

String produces postfix version with all operators converted to function names

type Function Uses

type Function struct {
    Name   string
    Target *Expression
    Args   []*Expression
}

Function models a function with multiple parameters 1st arg can be thought of as the receiver.

func (*Function) EvalType Uses

func (f *Function) EvalType(attrs attribute.AttributeDescriptorFinder, fMap map[string]FunctionMetadata) (valueType dpb.ValueType, err error)

EvalType Function using fMap and attribute vocabulary. Return static or computed return type if all args have correct type.

func (*Function) String Uses

func (f *Function) String() string

type FunctionMetadata Uses

type FunctionMetadata struct {
    // Name is the name of the function.
    Name string

    // Instance indicates that this is an instance method.
    Instance bool

    // TargetType is the type of the instance method target, if this function is an instance method.
    TargetType config.ValueType

    // ReturnType is the return type of the function.
    ReturnType config.ValueType

    // ArgumentTypes is the types of the arguments in the order that is expected by the function.
    ArgumentTypes []config.ValueType
}

FunctionMetadata contains type metadata for functions.

type Variable Uses

type Variable struct {
    Name string
}

Variable models a variable.

func (*Variable) String Uses

func (v *Variable) String() string

Package ast imports 11 packages (graph) and is imported by 10 packages. Updated 2019-06-12. Refresh now. Tools for package owners.