Compiler
- class Compiler
-
Members defined in
Compiler(4 members)
RWMaximum number of steps an expression evaluation may take. When this is reached, evaluation stops with an error. Actual steps are an implementation detail.
Evaluate expression. Note that custom functions and expressions, and most except a few standard library functions are not evaluatable. Constructor expressions evaluate as themselves because the constructor expressions conform to the constructed object implicitly. This primarily evaluates operator, metadata access, and feature reference expressions. If provided,
stdlibis used to accelerate some common evaluations, e.g. checking forselfexpressions.
Evaluate
featureinscope, taking into account redefinitions. Iffeatureis anExpression, this effectively performsevaluate. Attributes
- property max_steps: int
Maximum number of steps an expression evaluation may take. When this is reached, evaluation stops with an error. Actual steps are an implementation detail.
Methods
- __init__(max_steps: int = 100000) None
- evaluate(expr: syside.Expression, stdlib: syside.Stdlib | None = None, scope: syside.Type | None | None = None, experimental_quantities: bool = False) tuple[syside.Value | None, syside.CompilationReport]
Evaluate expression. Note that custom functions and expressions, and most except a few standard library functions are not evaluatable. Constructor expressions evaluate as themselves because the constructor expressions conform to the constructed object implicitly. This primarily evaluates operator, metadata access, and feature reference expressions. If provided,
stdlibis used to accelerate some common evaluations, e.g. checking forselfexpressions.If
experimental_quantitiesis enabled, compiler will additionally attempt to evaluate scalar quantity expressions in SI units, other systems of quantities are not supported. The results will be returned in scalarfloatand no type-checking will be performed. In the future, when typed quantities are implemented, this may be changed.Note that quantity evaluation requires
Stdlibto have found elements fromMeasurementReferenceslibrary. Additionally, evaluation is tested to work with standard library quantities and prefixes. Custom package-level prefixes and quantities are also expected to work, however any nested feature chaining may or may not work.
- evaluate_feature(feature: syside.Feature, scope: syside.Type, stdlib: syside.Stdlib | None = None, experimental_quantities: bool = False) tuple[syside.Value | None, syside.CompilationReport]
Evaluate
featureinscope, taking into account redefinitions. Iffeatureis anExpression, this effectively performsevaluate.