#![cfg_attr(coverage_nightly, coverage(off))]
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use wasmparser::{Operator, ValType};
pub struct IncrementalVerifier {
invariants: InvariantChecker,
stack_analyzer: StackAnalyzer,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum VerificationResult {
Safe,
OutOfBounds {
offset: usize,
size: usize,
},
TypeError {
expected: String,
found: Option<String>,
},
StackUnderflow,
StackOverflow,
InvalidIndirectCall,
IntegerOverflow,
}
#[derive(Debug, Clone)]
struct InvariantChecker {
invariants: Vec<SafetyInvariant>,
}
#[derive(Debug, Clone)]
enum SafetyInvariant {
MemoryBounds,
StackBalance,
TypeSafety,
NoIntegerOverflow,
}
#[derive(Debug, Clone)]
struct InvariantViolation {
invariant: SafetyInvariant,
location: usize,
description: String,
}
#[derive(Debug, Clone)]
struct StackAnalyzer {
type_stack: Vec<ValType>,
}
pub struct DifferentialTester {
test_cases: Vec<TestCase>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TestCase {
pub inputs: Vec<i32>,
pub expected_output: Option<Vec<i32>>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum DifferentialResult {
Consistent,
Divergence {
test_case: TestCase,
runtime1_result: Vec<i32>,
runtime2_result: Vec<i32>,
},
}
include!("verifier_core.rs");
include!("verifier_stack.rs");
include!("verifier_differential.rs");
include!("verifier_tests.rs");
include!("verifier_tests_stack.rs");