Documentation ¶
Overview ¶
Package exp contains expression types and the logic to evaluate them
Index ¶
- func EnvLookup(e *types.Env, id string) (types.Expression, bool, error)
- func RuleClose(rule *types.Rule)
- func RuleEval(rule *types.Rule, env *types.Env) (bool, error)
- func RuleVisitExpressions(rule *types.Rule, v visitor)
- func ScopeExtract(s *types.Scope) map[string]interface{}
- func Simplify(e types.Expression) types.Expression
- type ExtractExpression
- type ExtractFormat
- type FunctionExpression
- type OperationExpression
- type SliceExpression
- type ValueExpression
- func NewBooleanExpression(val bool) *ValueExpression
- func NewNumberExpression(val uint64, size int, signed bool) *ValueExpression
- func NewStringExpression(s string) *ValueExpression
- func NewStringExpressionRaw(data []byte) *ValueExpression
- func NewValueExpression(val prim.Primitive) *ValueExpression
- type VariableExpression
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RuleVisitExpressions ¶
RuleVisitExpressions walks all expressions in a rule
func ScopeExtract ¶
ScopeExtract extracts value from a scope
func Simplify ¶
func Simplify(e types.Expression) types.Expression
Types ¶
type ExtractExpression ¶
type ExtractExpression struct { Offset types.Expression Size types.Expression Format ExtractFormat Metadata *util.Register }
func NewExtractExpression ¶
func NewExtractExpression(o, s types.Expression, m *util.Register, f ExtractFormat) *ExtractExpression
func (*ExtractExpression) Eval ¶
func (ee *ExtractExpression) Eval(env *types.Env) (types.Expression, error)
func (*ExtractExpression) Simplify ¶
func (ee *ExtractExpression) Simplify() (types.Expression, error)
func (ExtractExpression) String ¶
func (ue ExtractExpression) String() string
type ExtractFormat ¶
type ExtractFormat int
extract types.Expression
const ( Number ExtractFormat = iota String StringZ )
type FunctionExpression ¶
type FunctionExpression struct { Name string Func *util.Function Params []types.Expression Metadata *util.Register }
func NewFunctionExpression ¶
func NewFunctionExpression(name string, m *util.Register, params ...types.Expression) (*FunctionExpression, error)
func (*FunctionExpression) Eval ¶
func (fe *FunctionExpression) Eval(env *types.Env) (types.Expression, error)
func (*FunctionExpression) Simplify ¶
func (fe *FunctionExpression) Simplify() (types.Expression, error)
func (FunctionExpression) String ¶
func (fe FunctionExpression) String() string
type OperationExpression ¶
type OperationExpression struct { Left types.Expression Right types.Expression Operation prim.Operation }
operation types.Expression
func NewBinaryExpression ¶
func NewBinaryExpression(left, right types.Expression, op prim.Operation) *OperationExpression
func NewUnaryExpression ¶
func NewUnaryExpression(expr types.Expression, op prim.Operation) *OperationExpression
func (*OperationExpression) Eval ¶
func (oe *OperationExpression) Eval(env *types.Env) (types.Expression, error)
func (*OperationExpression) Simplify ¶
func (oe *OperationExpression) Simplify() (types.Expression, error)
func (OperationExpression) String ¶
func (oe OperationExpression) String() string
type SliceExpression ¶
type SliceExpression struct { Expr types.Expression Start types.Expression End types.Expression }
SliceExpression contains an index/slice expresion
func NewSliceExpression ¶
func NewSliceExpression(expr, start, end types.Expression) *SliceExpression
func (*SliceExpression) Eval ¶
func (se *SliceExpression) Eval(env *types.Env) (types.Expression, error)
func (*SliceExpression) Simplify ¶
func (se *SliceExpression) Simplify() (types.Expression, error)
func (SliceExpression) String ¶
func (se SliceExpression) String() string
type ValueExpression ¶
func NewBooleanExpression ¶
func NewBooleanExpression(val bool) *ValueExpression
func NewNumberExpression ¶
func NewNumberExpression(val uint64, size int, signed bool) *ValueExpression
func NewStringExpression ¶
func NewStringExpression(s string) *ValueExpression
func NewStringExpressionRaw ¶
func NewStringExpressionRaw(data []byte) *ValueExpression
func NewValueExpression ¶
func NewValueExpression(val prim.Primitive) *ValueExpression
func (*ValueExpression) Eval ¶
func (ve *ValueExpression) Eval(env *types.Env) (types.Expression, error)
func (*ValueExpression) Simplify ¶
func (ve *ValueExpression) Simplify() (types.Expression, error)
func (ValueExpression) String ¶
func (ve ValueExpression) String() string
type VariableExpression ¶
type VariableExpression struct {
Id string
}
variable types.Expression
func (*VariableExpression) Eval ¶
func (ve *VariableExpression) Eval(env *types.Env) (types.Expression, error)
func (*VariableExpression) Simplify ¶
func (ve *VariableExpression) Simplify() (types.Expression, error)
func (*VariableExpression) String ¶
func (ve *VariableExpression) String() string
Click to show internal directories.
Click to hide internal directories.