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

Change Bool is_true and is_false implementations to avoid backends #527

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 7 additions & 8 deletions claripy/ast/bool.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from __future__ import annotations

import logging
from contextlib import suppress
from functools import lru_cache
from typing import TYPE_CHECKING, overload

import claripy
from claripy import operations
from claripy.ast.base import ASTCacheKey, Base, _make_name
from claripy.errors import BackendError, ClaripyTypeError
from claripy.errors import ClaripyTypeError

from .bits import Bits

Expand Down Expand Up @@ -163,17 +162,17 @@ def If(cond, true_value, false_value):
Bool.__ror__ = Or


def is_true(e, exact=None): # pylint:disable=unused-argument
with suppress(BackendError):
return claripy.backends.concrete.is_true(e)
def is_true(e):
if e is True or (isinstance(e, Base) and claripy.simplify(e) is true()):
return True

log.debug("Unable to tell the truth-value of this expression")
return False


def is_false(e, exact=None): # pylint:disable=unused-argument
with suppress(BackendError):
return claripy.backends.concrete.is_false(e)
def is_false(e):
if e is False or (isinstance(e, Base) and claripy.simplify(e) is false()):
return True

log.debug("Unable to tell the truth-value of this expression")
return False
Expand Down
Loading