pub enum InferredType {
Bottom,
Int,
Integral(IntegralTypeSet),
Float,
Long,
Double,
Reference(ReferenceType),
Uninitialized {
class_name: ClassName,
allocation_offset: u16,
},
UninitializedThis {
class_name: ClassName,
},
ReturnAddress,
Alternatives(Vec<InferredType>),
Conflict,
}Expand description
Abstract JVM type inferred for a local variable or operand-stack value.
boolean, byte, char, short, and int share the integral JVM
verification category. Self::Integral retains source-level candidates
when bytecode supplies evidence more precise than that category.
Variants§
Bottom
No control-flow path has supplied a value for this position yet.
Int
A JVM integral value with exact int evidence.
Integral(IntegralTypeSet)
A JVM integral value with one or more compatible source-level candidates.
Float
A category-one JVM floating-point value.
Long
A category-two JVM integral value.
Double
A category-two JVM floating-point value.
Reference(ReferenceType)
A JVM reference value.
Uninitialized
An object produced by new before its constructor has completed.
Fields
UninitializedThis
The receiver of an instance constructor before its parent constructor has completed.
ReturnAddress
A return address used by legacy jsr and ret bytecode.
Alternatives(Vec<InferredType>)
Distinct possible types observed for one value.
Reference alternatives preserve known candidates at a control-flow merge when no supplied hierarchy proves a common supertype. Alternatives may also describe a reused local-variable slot.
Conflict
Incompatible values reached the same control-flow position.
Implementations§
Source§impl InferredType
impl InferredType
Sourcepub const fn integral_types(&self) -> Option<IntegralTypeSet>
pub const fn integral_types(&self) -> Option<IntegralTypeSet>
Returns source-level candidates for an integral JVM value.
None means this value is not in the integral JVM verification
category. IntegralTypeSet::ALL means the bytecode did not preserve a
unique source-level type.
Examples found in repository?
5pub fn report(label: &str, result: &ClassInferences) {
6 let mut methods = 0;
7 let mut instructions = 0;
8 let mut diagnostics = 0;
9 let mut unknown = 0;
10 let mut conflict = 0;
11 let mut bottom = 0;
12 let mut alternatives = 0;
13 let mut integral_all = 0;
14 let mut expectations = 0;
15 for class in result.classes() {
16 diagnostics += class.diagnostics().len();
17 for method in class.methods() {
18 methods += 1;
19 for instruction in method.instructions() {
20 instructions += 1;
21 expectations += instruction.operand_expectations().len();
22 for value in instruction
23 .stack_before()
24 .iter()
25 .chain(instruction.stack_after())
26 {
27 unknown += usize::from(contains(
28 value,
29 &InferredType::Reference(ReferenceType::Unknown),
30 ));
31 conflict += usize::from(contains(value, &InferredType::Conflict));
32 bottom += usize::from(contains(value, &InferredType::Bottom));
33 alternatives += usize::from(matches!(value, InferredType::Alternatives(_)));
34 integral_all +=
35 usize::from(value.integral_types() == Some(IntegralTypeSet::ALL));
36 }
37 }
38 }
39 }
40 println!(
41 "{label}: classes={}, methods={methods}, instructions={instructions}, complete={}, diagnostics={diagnostics}, stack unknown={unknown}, conflict={conflict}, bottom={bottom}, alternatives={alternatives}",
42 result.len(),
43 result.analysis_complete()
44 );
45 println!(
46 " operand constraints={expectations}, stack values with all integral candidates={integral_all}"
47 );
48}Sourcepub fn join(&self, other: &Self) -> Self
pub fn join(&self, other: &Self) -> Self
Conservatively joins two types at a control-flow merge point.
Compatible values preserve their type. Incompatible primitive or
uninitialized values become Self::Conflict. Incompatible known
references become Self::Alternatives unless a supplied hierarchy
proves their common supertype.
Trait Implementations§
Source§impl Clone for InferredType
impl Clone for InferredType
Source§impl Debug for InferredType
impl Debug for InferredType
impl Eq for InferredType
Source§impl Hash for InferredType
impl Hash for InferredType
Source§impl PartialEq for InferredType
impl PartialEq for InferredType
impl StructuralPartialEq for InferredType
Auto Trait Implementations§
impl Forget for InferredType
impl Freeze for InferredType
impl Move for InferredType
impl RefUnwindSafe for InferredType
impl Send for InferredType
impl Sync for InferredType
impl Unpin for InferredType
impl UnsafeUnpin for InferredType
impl UnwindSafe for InferredType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.