Skip to main content

InferredType

Enum InferredType 

Source
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

§class_name: ClassName

Class allocated by the new instruction.

§allocation_offset: u16

Bytecode offset of the allocation instruction.

§

UninitializedThis

The receiver of an instance constructor before its parent constructor has completed.

Fields

§class_name: ClassName

Class whose constructor owns this receiver.

§

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

Source

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?
examples/support/comparison.rs (line 35)
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}
Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InferredType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for InferredType

Source§

impl Hash for InferredType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for InferredType

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for InferredType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.