class xform_query_result¶
Enumeration class: the possible outcomes of a transform query with step_xform.query().
This class is used when implementing step visitors. When you implement step_state.transition() as part of the overall task of subclassing step_state , you will use step_xform.query() invocations to inspect its step_xform arguments; these query invocations return xform_query_result .
xform_query_result Members¶
| Constructors | none |
| Static Method | from_integer() |
| Methods | __cmp__(), __eq__(), __ge__(), __gt__(), __hash__(), __le__(), __lt__(), __ne__(), __repr__(), __str__(), as_integer(), name() |
| Attributes | IMPOSSIBLE, LHS_UNMODIFIED, OK, REDUNDANT, REDUNDANT_SUSPECT, RHS_UNMODIFIED |
xform_query_result Details¶
-
class
cs.xform_query_result¶ Enumeration class: the possible outcomes of a transform query with
step_xform.query().-
static
from_integer(_inner)¶ Construct an instance from an integer representation.
Parameters: _inner (int) – The integer representation, as returned by xform_query_result.as_integer().Return type: xform_query_resultRaises: result.ERROR_INVALID_ARGUMENTif_inneris not a valid integer representation for axform_query_resultinstance.Invariant: For
xform_query_resultx, xform_query_result.from_integer(x.as_integer()) == x>>> xqr = xform_query_result.IMPOSSIBLE.as_integer() >>> xqr 0 >>> xform_query_result.from_integer(xqr) <cs.xform_query_result impossible>
-
__cmp__(other)¶ Comparison function for
xform_query_result, with respect to a stable overall ordering.Parameters: other ( xform_query_result) – Thexform_query_resultobject to compare against.Return type: int Returns: An integer N such that: - N==0 if the two objects compare equal
- N<0 if
self< other - N>0 if
self> other
>>> xform_query_result.OK.__cmp__(xform_query_result.LHS_UNMODIFIED) -1
-
__eq__(b)¶ Equality operator for
xform_query_result.Parameters: b ( xform_query_result) – Thexform_query_resultobject to compare against.Return type: bool Returns: Trueifselfandbcompare equal,Falseotherwise.>>> xform_query_result.REDUNDANT_SUSPECT == xform_query_result.REDUNDANT False
-
__ge__(b)¶ Greater-than-or-equal operator for
xform_query_result.Parameters: b ( xform_query_result) – Thexform_query_resultobject to compare against.Return type: bool Returns: Trueifself>=b,Falseotherwise.>>> xform_query_result.IMPOSSIBLE >= xform_query_result.RHS_UNMODIFIED False
-
__gt__(b)¶ Greater-than operator for
xform_query_result.Parameters: b ( xform_query_result) – Thexform_query_resultobject to compare against.Return type: bool Returns: Trueifself>b,Falseotherwise.>>> xform_query_result.REDUNDANT_SUSPECT > xform_query_result.LHS_UNMODIFIED False
-
__hash__()¶ Hash function for
xform_query_result.Return type: int >>> hash(xform_query_result.IMPOSSIBLE) 0
-
__le__(b)¶ Less-than-or-equal operator for
xform_query_result.Parameters: b ( xform_query_result) – Thexform_query_resultobject to compare against.Return type: bool Returns: Trueifself<=b,Falseotherwise.>>> xform_query_result.OK <= xform_query_result.REDUNDANT False
-
__lt__(b)¶ Less-than operator for
xform_query_result.Parameters: b ( xform_query_result) – Thexform_query_resultobject to compare against.Return type: bool Returns: Trueifself<b,Falseotherwise.>>> xform_query_result.REDUNDANT_SUSPECT < xform_query_result.RHS_UNMODIFIED True
-
__ne__(b)¶ Inequality operator for
xform_query_result.Parameters: b ( xform_query_result) – Thexform_query_resultobject to compare against.Return type: bool Returns: Falseifselfandbcompare equal,Trueotherwise.>>> xform_query_result.REDUNDANT != xform_query_result.LHS_UNMODIFIED True
-
__repr__()¶ Get a representation of a
xform_query_resultobject that includes information useful for debugging.Return type: str Returns: The string representation. >>> repr(xform_query_result.IMPOSSIBLE) '<cs.xform_query_result impossible>'
-
__str__()¶ Get a simple string representation of a
xform_query_resultobject.Return type: str Returns: The string representation. >>> str(xform_query_result.OK) 'ok'
-
as_integer()¶ Get an integer representation of
self.Return type: int Returns: An integer suitable for use with xform_query_result.from_integer().Invariant: For
xform_query_resultx, xform_query_result.from_integer(x.as_integer()) == x>>> xqr = xform_query_result.IMPOSSIBLE.as_integer() >>> xqr 0 >>> xform_query_result.from_integer(xqr) <cs.xform_query_result impossible>
-
name()¶ Get the name of a
xform_query_resultobject.Return type: str Returns: The name. >>> xform_query_result.REDUNDANT_SUSPECT.name() 'redundant_suspect'
-
IMPOSSIBLE¶ The query evaluates to FALSE.
There are two possible cases:
- Case 1: the query evaluates to FALSE because of preconditions that arise from:
- macros,
- called functions (unless they hold on all paths through the function),
- normalizations,
- equality tests when REPORT_IMPLIED_EQUALITY =No, or
- inequality tests when REPORT_IMPLIED_INEQUALITY =No.
- Case 2: the query evaluates to FALSE for any other reason.
We use the term “suspect” to describe case 1.
If some query Q has outcome
xform_query_result.IMPOSSIBLEand you need to distinguish between the two cases, proceed as follows.- Create a new query R that is the inverse of Q.
- Execute query R and look at the outcome.
- If it is
xform_query_result.REDUNDANT_SUSPECT, then query Q was impossible and suspect (case 1). - If it is
xform_query_result.REDUNDANT, then query Q was impossible and not suspect (case 2).
>>> xform_query_result.IMPOSSIBLE <cs.xform_query_result impossible>
-
LHS_UNMODIFIED¶ The query’s lhs
xform_exprhad modexform_expr_mode.POST_STRICTorxform_expr_mode.POST_DEREFS_PRE_STRICT, but the value of lhs was the same at the beginning and end of the transformation described by thestep_xform.>>> xform_query_result.LHS_UNMODIFIED <cs.xform_query_result lhs_unmodified>
-
OK¶ The query could evaluate to either TRUE or FALSE: there is no reason to believe definitely one or the other.
>>> xform_query_result.OK <cs.xform_query_result ok>
-
REDUNDANT¶ The query definitely evaluates to TRUE.
>>> xform_query_result.REDUNDANT <cs.xform_query_result redundant>
-
REDUNDANT_SUSPECT¶ The query evaluates to TRUE, but is implied by preconditions that arise from:
- macros,
- called functions (unless they hold on all paths through the function),
- normalizations,
- equality tests when REPORT_IMPLIED_EQUALITY =No, or
- inequality tests when REPORT_IMPLIED_INEQUALITY =No.
>>> xform_query_result.REDUNDANT_SUSPECT <cs.xform_query_result redundant_suspect>
-
RHS_UNMODIFIED¶ The query’s rhs
xform_exprhad modexform_expr_mode.POST_STRICTorxform_expr_mode.POST_DEREFS_PRE_STRICT, but the value of rhs was the same at the beginning and end of the transformation described by thestep_xform.>>> xform_query_result.RHS_UNMODIFIED <cs.xform_query_result rhs_unmodified>
-
static