angr.analyses.decompiler.pattern_match.template¶
Bridge between pattern-DSL nodes and the tokenizer’s shape alphabet.
The fuzzy matcher aligns shapes (see tokenizer), while a user-authored
pattern is a tree of dsl nodes.
This module renders a node into the same alphabet, so a template can seed and
score against a token stream:
shape_of()gives the one shape a fully concrete node stands for, or None when the node has a wildcard anywhere and stands for many.match_shape()says how well a node fits a stream token’s shape: exactly, up to operator class, or not at all. Wildcards accept anything.
Both mirror AILCanonicalizer rule for rule under the
TEMPLATE_TOKENIZER settings, and tests/analyses/decompiler/test_pattern_match_template.py
checks the mirror against every statement of a real function.
- angr.analyses.decompiler.pattern_match.template.TEMPLATE_TOKENIZER: dict = {'const_mode': 'abstract', 'keep_sizes': True, 'keep_vvar_category': False, 'max_depth': 5, 'skip_conversions': True, 'skip_dephi': True, 'skip_labels': True, 'skip_phis': True}¶
tokenizer settings a template is rendered under; a stream to search must use them
- angr.analyses.decompiler.pattern_match.template.ShapeTree¶
a shape string parsed into
(head, children)
- class angr.analyses.decompiler.pattern_match.template.Fit¶
Bases:
IntEnumHow well a node fits a shape. Ordered so
mincombines children.- NONE = 0¶
- KLASS = 1¶
- EXACT = 2¶
- __new__(value)
- angr.analyses.decompiler.pattern_match.template.parse_shape(shape)¶
"Asn(V,Add(V,C))"->("Asn", (("V", ()), ("Add", (("V", ()), ("C", ()))))).
- angr.analyses.decompiler.pattern_match.template.shape_of(node)¶
The shape a fully concrete node renders to, or None if it has a wildcard.
- Return type:
- Parameters:
node (PatternNode)