pub struct FactContext<'a> { /* private fields */ }
Expand description
A “context” in which we can evaluate and derive facts. This context carries environment/global properties, such as the machine pointer width.
Implementations§
Source§impl<'a> FactContext<'a>
impl<'a> FactContext<'a>
Sourcepub fn new(function: &'a Function, pointer_width: u16) -> Self
pub fn new(function: &'a Function, pointer_width: u16) -> Self
Create a new “fact context” in which to evaluate facts.
Sourcepub fn subsumes(&self, lhs: &Fact, rhs: &Fact) -> bool
pub fn subsumes(&self, lhs: &Fact, rhs: &Fact) -> bool
Computes whether lhs
“subsumes” (implies) rhs
.
Sourcepub fn subsumes_fact_optionals(
&self,
lhs: Option<&Fact>,
rhs: Option<&Fact>,
) -> bool
pub fn subsumes_fact_optionals( &self, lhs: Option<&Fact>, rhs: Option<&Fact>, ) -> bool
Computes whether the optional fact lhs
subsumes (implies)
the optional fact lhs
. A None
never subsumes any fact, and
is always subsumed by any fact at all (or no fact).
Sourcepub fn add(&self, lhs: &Fact, rhs: &Fact, add_width: u16) -> Option<Fact>
pub fn add(&self, lhs: &Fact, rhs: &Fact, add_width: u16) -> Option<Fact>
Computes whatever fact can be known about the sum of two values with attached facts. The add is performed to the given bit-width. Note that this is distinct from the machine or pointer width: e.g., many 64-bit machines can still do 32-bit adds that wrap at 2^32.
Sourcepub fn uextend(
&self,
fact: &Fact,
from_width: u16,
to_width: u16,
) -> Option<Fact>
pub fn uextend( &self, fact: &Fact, from_width: u16, to_width: u16, ) -> Option<Fact>
Computes the uextend
of a value with the given facts.
Sourcepub fn sextend(
&self,
fact: &Fact,
from_width: u16,
to_width: u16,
) -> Option<Fact>
pub fn sextend( &self, fact: &Fact, from_width: u16, to_width: u16, ) -> Option<Fact>
Computes the sextend
of a value with the given facts.
Sourcepub fn truncate(
&self,
fact: &Fact,
from_width: u16,
to_width: u16,
) -> Option<Fact>
pub fn truncate( &self, fact: &Fact, from_width: u16, to_width: u16, ) -> Option<Fact>
Computes the bit-truncation of a value with the given fact.
Sourcepub fn scale(&self, fact: &Fact, width: u16, factor: u32) -> Option<Fact>
pub fn scale(&self, fact: &Fact, width: u16, factor: u32) -> Option<Fact>
Scales a value with a fact by a known constant.
Sourcepub fn shl(&self, fact: &Fact, width: u16, amount: u16) -> Option<Fact>
pub fn shl(&self, fact: &Fact, width: u16, amount: u16) -> Option<Fact>
Left-shifts a value with a fact by a known constant.
Sourcepub fn offset(&self, fact: &Fact, width: u16, offset: i64) -> Option<Fact>
pub fn offset(&self, fact: &Fact, width: u16, offset: i64) -> Option<Fact>
Offsets a value with a fact by a known amount.
Sourcepub fn struct_field<'b>(
&'b self,
fact: &Fact,
access_ty: Type,
) -> PccResult<Option<&'b MemoryTypeField>>
pub fn struct_field<'b>( &'b self, fact: &Fact, access_ty: Type, ) -> PccResult<Option<&'b MemoryTypeField>>
Get the access struct field, if any, by a pointer with the given fact and an access of the given type.
Sourcepub fn load<'b>(
&'b self,
fact: &Fact,
access_ty: Type,
) -> PccResult<Option<&'b Fact>>
pub fn load<'b>( &'b self, fact: &Fact, access_ty: Type, ) -> PccResult<Option<&'b Fact>>
Check a load, and determine what fact, if any, the result of the load might have.
Sourcepub fn store(
&self,
fact: &Fact,
access_ty: Type,
data_fact: Option<&Fact>,
) -> PccResult<()>
pub fn store( &self, fact: &Fact, access_ty: Type, data_fact: Option<&Fact>, ) -> PccResult<()>
Check a store.
Sourcepub fn apply_inequality(
&self,
fact: &Fact,
lhs: &Fact,
rhs: &Fact,
kind: InequalityKind,
) -> Fact
pub fn apply_inequality( &self, fact: &Fact, lhs: &Fact, rhs: &Fact, kind: InequalityKind, ) -> Fact
Apply a known inequality to rewrite dynamic bounds using transitivity, if possible.
Given that lhs >= rhs
(if not strict
) or lhs > rhs
(if
strict
), update fact
.