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
.