use std::collections::HashSet;
#[allow(clippy::wildcard_imports)]
use crate::*;
mod coverage;
pub use coverage::{CallStackCoverage, HitmapFilter};
macro_rules! rust_filter_function_declaration {
(pub fn expression_unreachable(expressions: *mut RSymExpr, num_elements: usize), $c_name:ident;) => {
};
(pub fn push_path_constraint($( $arg:ident : $type:ty ),*$(,)?), $c_name:ident;) => {
#[allow(unused_variables)]
fn push_path_constraint(&mut self, $($arg : $type),*) -> bool {
true
}
};
(pub fn $name:ident($( $arg:ident : $type:ty ),*$(,)?) -> $ret:ty, $c_name:ident;) => {
#[allow(unused_variables)]
fn $name(&mut self, $( $arg : $type),*) -> bool {true}
};
(pub fn $name:ident($( $arg:ident : $type:ty ),*$(,)?), $c_name:ident;) => {
#[allow(unused_variables)]
fn $name(&mut self, $( $arg : $type),*) {}
};
}
pub trait Filter {
invoke_macro_with_rust_runtime_exports!(rust_filter_function_declaration;);
}
#[allow(clippy::module_name_repetitions)]
pub struct FilterRuntime<F, RT> {
filter: F,
runtime: RT,
}
impl<F, RT> FilterRuntime<F, RT> {
pub fn new(filter: F, runtime: RT) -> Self {
Self { filter, runtime }
}
}
macro_rules! rust_filter_function_implementation {
(pub fn expression_unreachable(expressions: *mut RSymExpr, num_elements: usize), $c_name:ident;) => {
fn expression_unreachable(&mut self, exprs: &[RSymExpr]) {
self.runtime.expression_unreachable(exprs)
}
};
(pub fn push_path_constraint($( $arg:ident : $type:ty ),*$(,)?), $c_name:ident;) => {
fn push_path_constraint(&mut self, $($arg : $type),*) {
if self.filter.push_path_constraint($($arg),*) {
self.runtime.push_path_constraint($($arg),*)
}
}
};
(pub fn $name:ident($( $arg:ident : $type:ty ),*$(,)?) -> $ret:ty, $c_name:ident;) => {
fn $name(&mut self, $($arg : $type),*) -> Option<$ret> {
if self.filter.$name($($arg),*) {
self.runtime.$name($($arg),*)
} else {
None
}
}
};
(pub fn $name:ident($( $arg:ident : $type:ty ),*$(,)?), $c_name:ident;) => {
fn $name(&mut self, $( $arg : $type),*) {
self.filter.$name($($arg),*);
self.runtime.$name($($arg),*);
}
};
}
impl<F, RT> Runtime for FilterRuntime<F, RT>
where
F: Filter,
RT: Runtime,
{
invoke_macro_with_rust_runtime_exports!(rust_filter_function_implementation;);
}
pub struct SelectiveSymbolication {
bytes_to_symbolize: HashSet<usize>,
}
impl SelectiveSymbolication {
#[must_use]
pub fn new(offset: HashSet<usize>) -> Self {
Self {
bytes_to_symbolize: offset,
}
}
}
impl Filter for SelectiveSymbolication {
fn get_input_byte(&mut self, offset: usize, _value: u8) -> bool {
self.bytes_to_symbolize.contains(&offset)
}
}
pub struct NoFloat;
impl Filter for NoFloat {
fn build_float(&mut self, _value: f64, _is_double: bool) -> bool {
false
}
fn build_float_ordered(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_ordered_equal(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_ordered_greater_equal(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_ordered_greater_than(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_ordered_less_equal(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_ordered_less_than(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_ordered_not_equal(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_to_bits(&mut self, _expr: RSymExpr) -> bool {
false
}
fn build_float_to_float(&mut self, _expr: RSymExpr, _to_double: bool) -> bool {
false
}
fn build_float_to_signed_integer(&mut self, _expr: RSymExpr, _bits: u8) -> bool {
false
}
fn build_float_to_unsigned_integer(&mut self, _expr: RSymExpr, _bits: u8) -> bool {
false
}
fn build_float_unordered(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_unordered_equal(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_unordered_greater_equal(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_unordered_greater_than(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_unordered_less_equal(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_unordered_less_than(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_float_unordered_not_equal(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_int_to_float(&mut self, _value: RSymExpr, _is_double: bool, _is_signed: bool) -> bool {
false
}
fn build_bits_to_float(&mut self, _expr: RSymExpr, _to_double: bool) -> bool {
false
}
fn build_fp_abs(&mut self, _a: RSymExpr) -> bool {
false
}
fn build_fp_add(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_fp_sub(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_fp_mul(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_fp_div(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
fn build_fp_rem(&mut self, _a: RSymExpr, _b: RSymExpr) -> bool {
false
}
}