Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer Base.is_leaf() over checking operations.leaf_operations #493

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions claripy/ast/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ def __bool__(self) -> NoReturn:
"testing Expressions for truthiness does not do what you want, as these expressions can be symbolic"
)

def structurally_match(self, o: Self) -> bool:
def structurally_match(self, o: Base) -> bool:
"""
Structurally compares two A objects, and check if their corresponding leaves are definitely the same A object
(name-wise or hash-identity wise).
Expand All @@ -959,7 +959,7 @@ def structurally_match(self, o: Self) -> bool:
return False
continue

if arg_a.op in operations.leaf_operations:
if arg_a.is_leaf():
if arg_a is not arg_b:
return False

Expand Down Expand Up @@ -1002,7 +1002,7 @@ def replace_dict(
repl = replacements[ast.cache_key]

elif ast.variables >= variable_set:
if ast.op in operations.leaf_operations:
if ast.is_leaf():
repl = leaf_operation(ast)
if repl is not ast:
replacements[ast.cache_key] = repl
Expand Down Expand Up @@ -1087,7 +1087,7 @@ def _burrow_ite(self):
# let's no go into this right now
return self

if any(a.op in operations.leaf_operations for a in self.args):
if any(a.is_leaf() for a in self.args):
# burrowing through these is pretty funny
return self

Expand Down Expand Up @@ -1117,7 +1117,7 @@ def _excavate_ite(self):
arg_queue.append(ast)
continue

if ast.op in operations.leaf_operations:
if ast.is_leaf():
arg_queue.append(ast)
continue

Expand Down Expand Up @@ -1274,7 +1274,7 @@ def uninitialized(self) -> bool:


def simplify(e: T) -> T:
if isinstance(e, Base) and e.op in operations.leaf_operations:
if isinstance(e, Base) and e.is_leaf():
return e

s = e._first_backend("simplify")
Expand Down
Loading