class xform_expr¶
Specifies parts of a query expression for step_xform.query() or step_xform.query_bounds().
Represents an expression of the form (ax+b)/c, where x is an attribute attached to the memory location obtained by applying a specified access path to a specified base symbol .
May also represent a constant expression b/c.
xform_expr Details¶
-
class
cs.xform_expr¶ Specifies parts of a query expression for
step_xform.query()orstep_xform.query_bounds().-
__init__(_b[, _c = 1])¶ Constructor for a constant-valued
xform_exprobject with value b/c.Parameters: - _b (int) – The numerator of the constant expression.
- _c (int) – (optional) The denominator of the constant expression.
Raises: result.ERROR_INVALID_ARGUMENTin the following cases:_bis -2147483648_cis -2147483648_cis 0
The
xform_exprobject will be created withxform_expr_mode.PRE.- For a constant-valued expression,
xform_expr_mode.PREis equivalent toxform_expr_mode.POSTandxform_expr_mode.POST_DEREFS_PRE, whilexform_expr_mode.POST_DEREFS_PRE_STRICTandxform_expr_mode.POST_STRICTare generally unsuitable since all queries will fail. - When
step_xform.query_bounds()is invoked with a constant-valuedxform_exprargument and returns anxform_query_bounds_resultobjectxqbr, the result ofxqbr.modified()(xform_query_bounds_result.modified()) is not meaningful.
>>> xform_expr(5,7) <cs.xform_expr 5 / 7>
>>> xform_expr(5) <cs.xform_expr 5>
-
__init__(_base[, _ap = (, )[, _attribute = ""[, _mode = xform_expr_mode.POST[, _a = 1[, _b = 0[, _c = 1]]]]]])¶ Constructor for an
xform_exprobject representing expression(ax + b)/c, wherexis an attribute attached to some memory location.Parameters: - _base (
symbol) – The base forx. - _ap (iterable of
access_path) – (optional) The access path for the memory location of whichxis an attribute (based at_base) - _attribute (str) –
(optional) The attribute
x. - _mode (
xform_expr_mode) – (optional) The temporal mode for evaluation ofx. - _a (int) – (optional) The coefficient a in the expression
(ax + b)/c. - _b (int) – (optional) The constant b in the expression
(ax + b)/c. - _c (int) – (optional) The denominator c in the expression
(ax + b)/c.
Raises: result.ERROR_INVALID_ARGUMENTin the following cases:
_ais -2147483648_bis -2147483648_cis -2147483648_cis 0_modeisxform_expr_mode.POST_STRICTorxform_expr_mode.POST_DEREFS_PRE_STRICTand_ais 0_apspecifies a nonsensical sequence of operators
result.ERROR_INVALID_ATTRIBUTEif_attributeis not a known attribute.result.ERROR_INVALID_OPERATORif_apspecifies an invalid sequence of operators.result.ERROR_PARAMETER_TOO_LARGEif the offset_in_bits field of an offsetaccess_pathcannot be represented as a 32-bit signed integer.
Constructs an
xform_exprobject representing expression(ax + b)/c, where:a,b, andcare constantsxis an attribute of somesymbolssis described in terms of its base (symbol) and access path (access_path).
>>> foo_fn = next(p for p in project.current().procedures() if p.name()=='foo') >>> foo_s = next(sym for sym in foo_fn.local_symbols() if sym.name()=='s') >>> xform_expr(foo_s, [access_path.star()], 'fromend', xform_expr_mode.POST, 12, 3, 7) <cs.xform_expr ( 12 * *s!fromend + 3 ) / 7>
>>> foo_fn = next(p for p in project.current().procedures() if p.name()=='foo') >>> foo_s = next(sym for sym in foo_fn.local_symbols() if sym.name()=='s') >>> xform_expr(foo_s, [access_path.star()], 'fromend', xform_expr_mode.POST, 12, 3) <cs.xform_expr 12 * *s!fromend + 3>
>>> foo_fn = next(p for p in project.current().procedures() if p.name()=='foo') >>> foo_s = next(sym for sym in foo_fn.local_symbols() if sym.name()=='s') >>> xform_expr(foo_s, [access_path.star()], 'fromend', xform_expr_mode.POST, 12) <cs.xform_expr 12 * *s!fromend>
>>> foo_fn = next(p for p in project.current().procedures() if p.name()=='foo') >>> foo_s = next(sym for sym in foo_fn.local_symbols() if sym.name()=='s') >>> xform_expr(foo_s, [access_path.star()], 'fromend', xform_expr_mode.POST_STRICT) <cs.xform_expr *s!fromend>
>>> foo_fn = next(p for p in project.current().procedures() if p.name()=='foo') >>> foo_s = next(sym for sym in foo_fn.local_symbols() if sym.name()=='s') >>> xform_expr(foo_s, [access_path.star()], 'fromend') <cs.xform_expr *s!fromend>
>>> foo_fn = next(p for p in project.current().procedures() if p.name()=='foo') >>> foo_s = next(sym for sym in foo_fn.local_symbols() if sym.name()=='s') >>> xform_expr(foo_s, [access_path.star()]) <cs.xform_expr *s>
>>> foo_fn = next(p for p in project.current().procedures() if p.name()=='foo') >>> foo_s = next(sym for sym in foo_fn.local_symbols() if sym.name()=='s') >>> xform_expr(foo_s) <cs.xform_expr s>
- _base (
-
__repr__()¶ Get a representation of a
xform_exprobject that includes information useful for debugging.Return type: str Returns: The string representation. >>> v0 = xform_expr(0) >>> repr(v0) '<cs.xform_expr 0>'
-
__str__()¶ Get a simple string representation of a
xform_exprobject.Return type: str Returns: The string representation. >>> v0 = xform_expr(0) >>> str(v0) '0'
-