Documentation ¶
Overview ¶
Package ir defines an intermediate representation (IR) for Rego.
The IR specifies an imperative execution model for Rego policies similar to a query plan in traditional databases.
Index ¶
- Constants
- func Pretty(w io.Writer, x interface{})
- func Walk(vis Visitor, x interface{}) error
- type AssignStmt
- type Block
- type BooleanConst
- type DotStmt
- type EqualStmt
- type FloatConst
- type GreaterThanEqualStmt
- type GreaterThanStmt
- type IntConst
- type LessThanEqualStmt
- type LessThanStmt
- type Local
- type LoopStmt
- type MakeBooleanStmt
- type MakeNumberIntStmt
- type MakeStringStmt
- type NotEqualStmt
- type NullConst
- type Plan
- type Policy
- type ReturnStmt
- type Static
- type Stmt
- type StringConst
- type Visitor
Constants ¶
const ( // Undefined represents an undefined return value. An undefined return value // indicates the policy did not return a definitive answer. Undefined int32 = iota // Defined represents a defined return value. Defined // Error indicates a runtime error occurred during evaluation. Error )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssignStmt ¶
type AssignStmt struct { Value interface{} Target Local }
AssignStmt represents an assignment of a local variable.
type Block ¶
type Block struct {
Stmts []Stmt
}
Block represents an ordered sequence of statements to execute. Blocks are executed until a return statement is encountered, a statement is undefined, or there are no more statements. If all statements are defined but no return statement is encountered, the block is undefined.
type BooleanConst ¶
type BooleanConst struct {
Value bool
}
BooleanConst represents a boolean value.
type DotStmt ¶
DotStmt represents a lookup operation on a value (e.g., array, object, etc.) The source of a DotStmt may be a scalar value in which case the statement will be undefined.
type FloatConst ¶
type FloatConst struct {
Value float64
}
FloatConst represents a floating-point constant.
type GreaterThanEqualStmt ¶
GreaterThanEqualStmt represents a >= check of two local variables.
type GreaterThanStmt ¶
GreaterThanStmt represents a > check of two local variables.
type LessThanEqualStmt ¶
LessThanEqualStmt represents a <= check of two local variables.
type LessThanStmt ¶
LessThanStmt represents a < check of two local variables.
type Local ¶
type Local int
Local represents a plan-scoped variable.
const ( // InputRaw refers to the local variable containing the address of the raw // (serialized) input data. InputRaw Local = 0 // InputLen refers to the local variable containing the length of the raw input. InputLen Local = 1 // Input refers to the local variable containing the address of the deserialized // input value. Input Local = 2 )
type LoopStmt ¶
LoopStmt represents a loop operation on a composite value. The source of a LoopStmt may be a scalar in which case the statement will be undefined.
type MakeBooleanStmt ¶
MakeBooleanStmt constructs a local variable that refers to a boolean value.
type MakeNumberIntStmt ¶
MakeNumberIntStmt constructs a local variable that refers to an integer value.
type MakeStringStmt ¶
MakeStringStmt constructs a local variable that refers to a string constant.
type NotEqualStmt ¶
NotEqualStmt represents a != check of two local variables.
type Plan ¶
type Plan struct {
Blocks []Block
}
Plan represents an ordered series of blocks to execute. All plans contain a final block that returns indicating the plan result was undefined. Plan execution stops when a block returns a value. Blocks are executed in-order.
type ReturnStmt ¶
type ReturnStmt struct {
Code int32 // 32-bit integer for compatibility with languages like JavaScript.
}
ReturnStmt represents a return statement. Return statements halt execution of a plan with the given code.
type Static ¶
type Static struct {
Strings []StringConst
}
Static represents a static data segment that is indexed into by the policy.