def normalize_flags(
node: astx.AST,
*,
lhs_type: astx.DataType | None = None,
rhs_type: astx.DataType | None = None,
) -> SemanticFlags:
"""
title: Normalize semantic flags from the raw AST node.
parameters:
node:
type: astx.AST
lhs_type:
type: astx.DataType | None
rhs_type:
type: astx.DataType | None
returns:
type: SemanticFlags
"""
explicit_unsigned = getattr(node, "unsigned", None)
unsigned = (
bool(explicit_unsigned)
if explicit_unsigned is not None
else is_unsigned_type(lhs_type) or is_unsigned_type(rhs_type)
)
return SemanticFlags(
unsigned=unsigned,
fast_math=bool(getattr(node, "fast_math", False)),
fma=bool(getattr(node, "fma", False)),
fma_rhs=getattr(node, "fma_rhs", None),
)