Struct rupta::mir::analysis_context::AnalysisContext
source · pub struct AnalysisContext<'tcx, 'compilation> {Show 17 fields
pub tcx: TyCtxt<'tcx>,
pub session: &'compilation Session,
pub entry_point: DefId,
pub analysis_options: AnalysisOptions,
pub functions: IndexVec<FuncId, Rc<FunctionReference<'tcx>>>,
pub func_id_map: HashMap<Rc<FunctionReference<'tcx>>, FuncId>,
pub func_name_cache: HashMap<FuncId, Box<str>>,
pub type_cache: TypeCache<'tcx>,
pub path_ty_cache: HashMap<Rc<Path>, Ty<'tcx>>,
pub path_memory_size: HashMap<Rc<Path>, usize>,
pub path_cast_cache: PathCastCache<'tcx>,
pub ptr_projs_cache: PointerProjectionsCache<'tcx>,
pub field_byte_offset_cache: FieldByteOffsetCache<'tcx>,
pub dyn_callsite_cache: HashMap<BaseCallSite, CalleeIdentifier<'tcx>>,
pub special_functions: HashSet<FuncId>,
pub concretized_heap_objs: HashMap<Rc<Path>, Ty<'tcx>>,
pub known_names_cache: KnownNamesCache,
/* private fields */
}Expand description
Global information of the analysis
Fields§
§tcx: TyCtxt<'tcx>The central data structure of the compiler.
session: &'compilation SessionRepresents the data associated with a compilation session for a single crate.
entry_point: DefIdThe entry function of the analysis.
analysis_options: AnalysisOptionsOptions of the analysis.
functions: IndexVec<FuncId, Rc<FunctionReference<'tcx>>>§func_id_map: HashMap<Rc<FunctionReference<'tcx>>, FuncId>§func_name_cache: HashMap<FuncId, Box<str>>§type_cache: TypeCache<'tcx>Provides a way to refer to a rustc_middle::ty::Ty via a handle that does not have
a life time specifier.
path_ty_cache: HashMap<Rc<Path>, Ty<'tcx>>Record the original type for each object.
path_memory_size: HashMap<Rc<Path>, usize>Record the memory size for each stack and heap object.
path_cast_cache: PathCastCache<'tcx>Manage the cast types for each object.
ptr_projs_cache: PointerProjectionsCache<'tcx>Cache all the pointer type fields’ projections for each type.
field_byte_offset_cache: FieldByteOffsetCache<'tcx>Cache the byte offset for each field of type.
dyn_callsite_cache: HashMap<BaseCallSite, CalleeIdentifier<'tcx>>§special_functions: HashSet<FuncId>Functions specially handled in special_function_handler.
concretized_heap_objs: HashMap<Rc<Path>, Ty<'tcx>>Heap objects that have been cast to a concretized type.
known_names_cache: KnownNamesCacheImplementations§
source§impl<'tcx, 'compilation> AnalysisContext<'tcx, 'compilation>
impl<'tcx, 'compilation> AnalysisContext<'tcx, 'compilation>
pub fn new( session: &'compilation Session, tcx: TyCtxt<'tcx>, analysis_options: AnalysisOptions ) -> Option<Self>
sourcepub fn set_path_rustc_type(&mut self, path: Rc<Path>, ty: Ty<'tcx>)
pub fn set_path_rustc_type(&mut self, path: Rc<Path>, ty: Ty<'tcx>)
Records the type of path.
pub fn get_path_rustc_type(&self, path: &Rc<Path>) -> Option<Ty<'tcx>>
sourcepub fn set_path_memory_size(&mut self, path: Rc<Path>, ty: Ty<'tcx>)
pub fn set_path_memory_size(&mut self, path: Rc<Path>, ty: Ty<'tcx>)
Records the size of `path``.
pub fn get_path_memory_size(&self, path: &Rc<Path>) -> Option<usize>
pub fn get_type_index(&mut self, ty: &Ty<'tcx>) -> usize
pub fn get_type_by_index(&self, index: usize) -> Option<Ty<'tcx>>
sourcepub fn cast_to(&mut self, path: &Rc<Path>, ty: Ty<'tcx>) -> Option<Rc<Path>>
pub fn cast_to(&mut self, path: &Rc<Path>, ty: Ty<'tcx>) -> Option<Rc<Path>>
Creates a path cast from the given path.
sourcepub fn get_type_variant(
&mut self,
path: &Rc<Path>,
ty: Ty<'tcx>
) -> Option<Rc<Path>>
pub fn get_type_variant( &mut self, path: &Rc<Path>, ty: Ty<'tcx> ) -> Option<Rc<Path>>
Returns the type variant of the given path, returns None if the path has not been cast to ty.
sourcepub fn get_regularized_path(&mut self, path: Rc<Path>) -> Rc<Path>
pub fn get_regularized_path(&mut self, path: Rc<Path>) -> Rc<Path>
Different paths may refer to the same memory location, we can regularize these path to a base path
e.g. a.0.0, a.0, a.cast#T' and a will all be represented by one path.
sourcepub fn get_cast_types(&self, path: &Rc<Path>) -> Option<&HashSet<Ty<'tcx>>>
pub fn get_cast_types(&self, path: &Rc<Path>) -> Option<&HashSet<Ty<'tcx>>>
Returns the types that a path have been cast to.
sourcepub fn get_pointer_projections(
&mut self,
ty: Ty<'tcx>
) -> &Vec<(ProjectionElems, Ty<'tcx>)>
pub fn get_pointer_projections( &mut self, ty: Ty<'tcx> ) -> &Vec<(ProjectionElems, Ty<'tcx>)>
Get the pointer type fields’ projections.
sourcepub fn get_field_byte_offset(
&mut self,
base_ty: Ty<'tcx>,
proj: &ProjectionElems
) -> usize
pub fn get_field_byte_offset( &mut self, base_ty: Ty<'tcx>, proj: &ProjectionElems ) -> usize
Get the byte offset of a specific field.
pub fn get_or_add_function_reference( &mut self, func_ref: Rc<FunctionReference<'tcx>> ) -> FuncId
pub fn get_function_reference( &self, func_id: FuncId ) -> Rc<FunctionReference<'tcx>>
pub fn get_func_id( &mut self, def_id: DefId, gen_args: GenericArgsRef<'tcx> ) -> FuncId
pub fn get_promoted_id( &mut self, def_id: DefId, gen_args: Vec<GenericArgE<'tcx>>, promoted: Promoted ) -> FuncId
pub fn add_dyn_callsite( &mut self, callsite: BaseCallSite, callee_id: DefId, gen_args: GenericArgsRef<'tcx> )
pub fn get_dyn_callee_identifier( &self, callsite: &BaseCallSite ) -> Option<&CalleeIdentifier<'tcx>>
pub fn add_special_function(&mut self, func_id: FuncId)
pub fn is_std_ops_fntrait_call(&mut self, def_id: DefId) -> bool
pub fn def_in_ops_func_namespace(&mut self, def_id: DefId) -> bool
pub fn get_known_name_for(&mut self, def_id: DefId) -> KnownNames
sourcepub fn create_aux_local(&mut self, func_id: FuncId, ty: Ty<'tcx>) -> Rc<Path>
pub fn create_aux_local(&mut self, func_id: FuncId, ty: Ty<'tcx>) -> Rc<Path>
Creates an auxiliary local variable with the given type for the given func_id.
Returns the path of the auxiliary local variable.
Auxiliary local variables are introduced for breaking donw complex statements into simple assignments.