pyfcstm.diagnostics.analyzers.const_fold

Constant-folding diagnostics for literal-only expressions.

Numeric diagnostic refs are limited to JSON-stable values so Python and jsfcstm agree on values that cross the JSON boundary.

ConstValue

pyfcstm.diagnostics.analyzers.const_fold.ConstValue = typing.Any

Special type indicating an unconstrained type.

  • Any is compatible with every type.

  • Any assumed to have all methods.

  • All values assumed to be instances of Any.

Note that all the above statements are true from the point of view of static type checkers. At runtime, Any should not be used with instance or class checks.

fold_numeric_expression

pyfcstm.diagnostics.analyzers.const_fold.fold_numeric_expression(expr: Expr) Any | None[source]

Fold one numeric expression when it contains only supported constants.

fold_condition_expression

pyfcstm.diagnostics.analyzers.const_fold.fold_condition_expression(expr: Expr) bool | None[source]

Fold one condition expression when it contains only supported constants.

collect_const_fold_warnings

pyfcstm.diagnostics.analyzers.const_fold.collect_const_fold_warnings(machine: StateMachine | None) List[ModelDiagnostic][source]

Collect diagnostics that depend on constant folding.