Documentation
¶
Overview ¶
Package jit provides a best-effort native compilation path for CEL programs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCodegenUnsupported = errors.New("native code generation unsupported")
ErrCodegenUnsupported indicates machine-code generation is not available for translated IR.
var ErrTranslateUnsupported = errors.New("expression translation unsupported")
ErrTranslateUnsupported indicates the expression cannot be translated into JIT IR.
Functions ¶
func TryEvaluate ¶
TryEvaluate checks the dynamic type against the configured activation type, extracts the underlying struct pointer, and calls the native eval function. Returns (result, true) on success, or (false, false) if the input type does not match.
Types ¶
type BuiltinID ¶
type BuiltinID uint16
BuiltinID identifies a pre-registered builtin helper.
const ( BuiltinStrEq BuiltinID = iota BuiltinStrNe BuiltinStrContains BuiltinStrStarts BuiltinStrEnds BuiltinStrConcat BuiltinStrSize BuiltinListContainsStringSlice BuiltinListContainsStringArray BuiltinListContainsIntSlice BuiltinListContainsIntArray BuiltinListContainsUintSlice BuiltinListContainsUintArray BuiltinListContainsFloatSlice BuiltinListContainsFloatArray BuiltinListContainsBoolSlice BuiltinListContainsBoolArray )
type Instr ¶
type Instr struct {
Op Opcode
Dst VReg
Src1 VReg
Src2 VReg
Imm int64
Lbl Label
Type Type
BuiltinID BuiltinID
}
Instr is a TAC instruction.
type NativeEvalFunc ¶
type NativeProgram ¶
type NativeProgram struct {
ActivationType reflect.Type
EvalFunc NativeEvalFunc
}
type Opcode ¶
type Opcode uint16
Opcode is the operation identifier for a TAC instruction.
const ( OP_UNSPECIFIED Opcode = iota // Constants. CONST_INT CONST_UINT CONST_FLOAT CONST_BOOL CONST_STRING // Slot / type conversion. LOAD_FIELD LOAD_FIELD_SLICE LOAD_FIELD_ARRAY // Arithmetic. ADD_INT SUB_INT MUL_INT DIV_INT MOD_INT NEG_INT ADD_UINT SUB_UINT MUL_UINT DIV_UINT MOD_UINT ADD_FLOAT SUB_FLOAT MUL_FLOAT DIV_FLOAT NEG_FLOAT // Comparisons. EQ_INT NE_INT LT_INT LE_INT GT_INT GE_INT EQ_UINT NE_UINT LT_UINT LE_UINT GT_UINT GE_UINT EQ_FLOAT NE_FLOAT LT_FLOAT LE_FLOAT GT_FLOAT GE_FLOAT // Logical and misc. NOT MOVE // Control flow. LABEL BR BR_TRUE BR_FALSE // Calls and returns. CALL_BUILTIN RETURN )
type Program ¶
Program is the output of the translate pass.
func Translate ¶
Translate turns a checked AST into an IR program that loads variables directly from a concrete pointer-to-struct input.
Constraints:
- expression result type must be bool
- struct field types must exactly match CEL variable types
- supported scalar field kinds: int64/int, uint64/uint, float64, bool, string
- supported list membership field kinds for in_list: []string, [N]string