class xform_expr_mode¶
Enumeration class: the evaluation mode for an xform_expr .
Note that constants a, b, and c cannot be modified by a tranformation, so the value of an xform_expr representing an expression of the form (ax+b)/c can only change if x changes. There are two possible cases:
- The memory location for which attribute
xis extracted has changed. This can occur if the contents of locations along the access path (including the basesymbol) have changed. - The memory location is the same, but the value of attribute
xis modified by the transformation.
Example:
int *p;
void f(){
if( *p == 1 ){
int i = 2;
int j = 3;
j = 4;
*p = 5;
*p = 6;
p = &i;
p = &j;
return;
}
}
If you were to query the value of *p using the step_xform covering the path from the start of the function to the return statement in these various modes, the results would be as follows.
xform_expr_mode.PRE: 1xform_expr_mode.POST: 4xform_expr_mode.POST_DEREFS_PRE: 5xform_expr_mode.POST_STRICT: 4xform_expr_mode.POST_DEREFS_PRE_STRICT: 5
xform_expr_mode Members¶
| Constructors | none |
| Static Method | from_integer() |
| Methods | __cmp__(), __eq__(), __ge__(), __gt__(), __hash__(), __le__(), __lt__(), __ne__(), __repr__(), __str__(), as_integer(), name() |
| Attributes | POST, POST_DEREFS_PRE, POST_DEREFS_PRE_STRICT, POST_STRICT, PRE |
xform_expr_mode Details¶
-
class
cs.xform_expr_mode¶ Enumeration class: the evaluation mode for an
xform_expr.-
static
from_integer(_inner)¶ Construct an instance from an integer representation.
Parameters: _inner (int) – The integer representation, as returned by xform_expr_mode.as_integer().Return type: xform_expr_modeRaises: result.ERROR_INVALID_ARGUMENTif_inneris not a valid integer representation for axform_expr_modeinstance.Invariant: For
xform_expr_modex, xform_expr_mode.from_integer(x.as_integer()) == x>>> xem = xform_expr_mode.POST_DEREFS_PRE_STRICT.as_integer() >>> xem 4 >>> xform_expr_mode.from_integer(xem) <cs.xform_expr_mode post_derefs_pre_strict>
-
__cmp__(other)¶ Comparison function for
xform_expr_mode, with respect to a stable overall ordering.Parameters: other ( xform_expr_mode) – Thexform_expr_modeobject 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_expr_mode.POST.__cmp__(xform_expr_mode.POST_DEREFS_PRE) -1
-
__eq__(b)¶ Equality operator for
xform_expr_mode.Parameters: b ( xform_expr_mode) – Thexform_expr_modeobject to compare against.Return type: bool Returns: Trueifselfandbcompare equal,Falseotherwise.>>> xform_expr_mode.POST_DEREFS_PRE_STRICT == xform_expr_mode.PRE False
-
__ge__(b)¶ Greater-than-or-equal operator for
xform_expr_mode.Parameters: b ( xform_expr_mode) – Thexform_expr_modeobject to compare against.Return type: bool Returns: Trueifself>=b,Falseotherwise.>>> xform_expr_mode.POST_STRICT >= xform_expr_mode.POST_DEREFS_PRE True
-
__gt__(b)¶ Greater-than operator for
xform_expr_mode.Parameters: b ( xform_expr_mode) – Thexform_expr_modeobject to compare against.Return type: bool Returns: Trueifself>b,Falseotherwise.>>> xform_expr_mode.POST_DEREFS_PRE_STRICT > xform_expr_mode.POST True
-
__hash__()¶ Hash function for
xform_expr_mode.Return type: int >>> hash(xform_expr_mode.PRE) 0
-
__le__(b)¶ Less-than-or-equal operator for
xform_expr_mode.Parameters: b ( xform_expr_mode) – Thexform_expr_modeobject to compare against.Return type: bool Returns: Trueifself<=b,Falseotherwise.>>> xform_expr_mode.POST_STRICT <= xform_expr_mode.POST_DEREFS_PRE False
-
__lt__(b)¶ Less-than operator for
xform_expr_mode.Parameters: b ( xform_expr_mode) – Thexform_expr_modeobject to compare against.Return type: bool Returns: Trueifself<b,Falseotherwise.>>> xform_expr_mode.PRE < xform_expr_mode.POST True
-
__ne__(b)¶ Inequality operator for
xform_expr_mode.Parameters: b ( xform_expr_mode) – Thexform_expr_modeobject to compare against.Return type: bool Returns: Falseifselfandbcompare equal,Trueotherwise.>>> xform_expr_mode.POST_DEREFS_PRE_STRICT != xform_expr_mode.POST True
-
__repr__()¶ Get a representation of a
xform_expr_modeobject that includes information useful for debugging.Return type: str Returns: The string representation. >>> repr(xform_expr_mode.PRE) '<cs.xform_expr_mode pre>'
-
__str__()¶ Get a simple string representation of a
xform_expr_modeobject.Return type: str Returns: The string representation. >>> str(xform_expr_mode.POST_STRICT) 'post_strict'
-
as_integer()¶ Get an integer representation of
self.Return type: int Returns: An integer suitable for use with xform_expr_mode.from_integer().Invariant: For
xform_expr_modex, xform_expr_mode.from_integer(x.as_integer()) == x>>> xem = xform_expr_mode.POST_DEREFS_PRE_STRICT.as_integer() >>> xem 4 >>> xform_expr_mode.from_integer(xem) <cs.xform_expr_mode post_derefs_pre_strict>
-
name()¶ Get the name of a
xform_expr_modeobject.Return type: str Returns: The name. >>> xform_expr_mode.POST_DEREFS_PRE.name() 'post_derefs_pre'
-
POST¶ The expression should be evaluated using values of variables at the end of the transformation.
If the value of the expression is not modified in the transformation, the evaluated expression will be the same as it would have been with
xform_expr_mode.PRE.>>> xform_expr_mode.POST <cs.xform_expr_mode post>
-
POST_DEREFS_PRE¶ The expression is evaluated as follows.
Let A be the memory location whose attribute
xis used in the expression.- Address A is computed using the values of variables at the beginning of the transformation.
- The expression is evaluated by taking the value of attribute
xat address A at the end of the transformation.
If the value of the expression is not modified in the transformation, the evaluated expression will be the same as it would have been with
xform_expr_mode.PRE.>>> xform_expr_mode.POST_DEREFS_PRE <cs.xform_expr_mode post_derefs_pre>
-
POST_DEREFS_PRE_STRICT¶ The expression is evaluated as specified for
xform_expr_mode.POST_DEREFS_PRE.If the value of the expression is not modified in the transformation, the query fails (as distinct from
xform_expr_mode.POST_DEREFS_PRE, where the query proceeds).>>> xform_expr_mode.POST_DEREFS_PRE_STRICT <cs.xform_expr_mode post_derefs_pre_strict>
-
POST_STRICT¶ The expression should be evaluated using values of variables at the end of the transformation.
If the value of the expression is not modified in the transformation, the query fails (as distinct from
xform_expr_mode.POST, where the query proceeds).>>> xform_expr_mode.POST_STRICT <cs.xform_expr_mode post_strict>
-
PRE¶ The expression should be evaluated using values of variables at the beginning of the transformation.
This can be useful for reasoning about constraints imposed on the original values later in the path (implied by ‘if’ statements for example).
(C API only: This is the recommended setting for constant-valued
xform_expr(ax+b)/c with a==0.)>>> xform_expr_mode.PRE <cs.xform_expr_mode pre>
-
static