EvaluatorInstructions
EvaluatorInstructions
class EvaluatorInstructionsA structured instruction stream for evaluating an expression.
Attributes
| Name | Description |
|---|---|
constant_functions |
Registered constants and fixed-argument functions (such as pi) held in ('const', index) slots |
constants |
Exact constants referenced by ('const', index) slots. |
input_count |
The number of input parameter values expected by this instruction stream. |
instructions |
Return a structured instruction representation for efficiently evaluating the expression |
output_count |
The number of output values produced by this instruction stream. |
sub_evaluators |
Non-inlined function bodies referenced by fun instructions in this stream. |
temporary_count |
The number of temporary storage slots required by instructions. |
constant_functions
EvaluatorInstructions.constant_functions: list[EvaluatorConstantFunction]Registered constants and fixed-argument functions (such as pi) held in ('const', index) slots. Each entry exposes index, function, tags, and arguments. The exact constants hold placeholders at these indices: evaluate function with its tags at the exact arguments in the target precision before using such a slot.
constants
EvaluatorInstructions.constants: list[Expression]Exact constants referenced by ('const', index) slots.
input_count
EvaluatorInstructions.input_count: intThe number of input parameter values expected by this instruction stream.
instructions
EvaluatorInstructions.instructions: list[tuple]Return a structured instruction representation for efficiently evaluating the expression. This can be used to generate code for the expression evaluation in any programming language. Function names and tags remain Expression objects.
There are four lists that are used in the evaluation instructions:
param: the list of input parameters.temp: the list of temporary slots. Its size is available astemporary_count.const: the list of constants.out: the list of outputs.
The instructions are of the form:
('add', ('out', 0), [('const', 1), ('param', 0)], 0)which meansout[0] = const[1] + param[0]where the first0arguments are real.('mul', ('out', 0), [('temp', 0), ('param', 0)], 1)which meansout[0] = temp[0] * param[0], where the first1arguments are real.('pow', ('out', 0), ('param', 0), -1, true)which meansout[0] = param[0]^-1and the output is real (true).('powf', ('out', 0), ('param', 0), ('param', 1), false)which meansout[0] = param[0]^param[1].('fun', ('temp', 1), f, [Expression.num(0)], [('param', 0)], true)which meanstemp[1] = f(0, param[0])and the output is real (true).('if_else', ('temp', 0), 5)which meansif temp[0] == 0 goto label 5(false branch).('goto', 10)which meansgoto label 10.('label', 3)which meanslabel 3.('join', ('out', 0), ('temp', 0), 3, 7)which meansout[0] = (temp[0] != 0) ? label 3 : label 7.
output_count
EvaluatorInstructions.output_count: intThe number of output values produced by this instruction stream.
sub_evaluators
EvaluatorInstructions.sub_evaluators: list[EvaluatorFunction]Non-inlined function bodies referenced by fun instructions in this stream.
temporary_count
EvaluatorInstructions.temporary_count: intThe number of temporary storage slots required by instructions.
Methods
| Name | Description |
|---|---|
__repr__ |
__repr__
EvaluatorInstructions.__repr__() -> str