提交 94697ba4 编写于 作者: N Niko Matsakis

rename `LocalWithRegion` to `LiveVar`

上级 43748552
......@@ -10,9 +10,9 @@
//! For the NLL computation, we need to compute liveness, but only for those
//! local variables whose types contain regions. The others are not of interest
//! to us. This file defines a new index type (LocalWithRegion) that indexes into
//! to us. This file defines a new index type (LiveVar) that indexes into
//! a list of "variables whose type contain regions". It also defines a map from
//! Local to LocalWithRegion and vice versa -- this map can be given to the
//! Local to LiveVar and vice versa -- this map can be given to the
//! liveness code so that it only operates over variables with regions in their
//! types, instead of all variables.
......@@ -23,7 +23,7 @@
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use util::liveness::LiveVariableMap;
/// Map between Local and LocalWithRegion indices: the purpose of this
/// Map between Local and LiveVar indices: the purpose of this
/// map is to define the subset of local variables for which we need
/// to do a liveness computation. We only need to compute whether a
/// variable `X` is live if that variable contains some region `R` in
......@@ -32,10 +32,10 @@
crate struct NllLivenessMap {
/// For each local variable, contains `Some(i)` if liveness is
/// needed for this variable.
pub from_local: IndexVec<Local, Option<LocalWithRegion>>,
pub from_local: IndexVec<Local, Option<LiveVar>>,
/// For each `LocalWithRegion`, maps back to the original `Local` index.
pub to_local: IndexVec<LocalWithRegion, Local>,
/// For each `LiveVar`, maps back to the original `Local` index.
pub to_local: IndexVec<LiveVar, Local>,
}
impl LiveVariableMap for NllLivenessMap {
......@@ -43,7 +43,7 @@ fn from_local(&self, local: Local) -> Option<Self::LiveVar> {
self.from_local[local]
}
type LiveVar = LocalWithRegion;
type LiveVar = LiveVar;
fn from_live_var(&self, local: Self::LiveVar) -> Local {
self.to_local[local]
......@@ -94,4 +94,4 @@ impl NllLivenessMap {
}
/// Index given to each local variable whose type contains a region.
newtype_index!(LocalWithRegion);
newtype_index!(LiveVar);
......@@ -9,7 +9,7 @@
// except according to those terms.
use borrow_check::nll::region_infer::values::{PointIndex, RegionValueElements};
use borrow_check::nll::type_check::liveness::liveness_map::{LocalWithRegion, NllLivenessMap};
use borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap};
use rustc::mir::visit::{PlaceContext, Visitor};
use rustc::mir::{Local, Location, Mir};
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
......@@ -27,18 +27,18 @@
/// defined in `x = y` but not `y`; that first def is the head of
/// a linked list that lets you enumerate all places the variable
/// is assigned.
first_def_at: IndexVec<LocalWithRegion, Option<AppearanceIndex>>,
first_def_at: IndexVec<LiveVar, Option<AppearanceIndex>>,
/// Head of a linked list of **uses** of each variable -- use in
/// this context means that the existing value of the variable is
/// read or modified. e.g., `y` is used in `x = y` but not `x`.
/// Note that `DROP(x)` terminators are excluded from this list.
first_use_at: IndexVec<LocalWithRegion, Option<AppearanceIndex>>,
first_use_at: IndexVec<LiveVar, Option<AppearanceIndex>>,
/// Head of a linked list of **drops** of each variable -- these
/// are a special category of uses corresponding to the drop that
/// we add for each local variable.
first_drop_at: IndexVec<LocalWithRegion, Option<AppearanceIndex>>,
first_drop_at: IndexVec<LiveVar, Option<AppearanceIndex>>,
appearances: IndexVec<AppearanceIndex, Appearance>,
}
......@@ -81,17 +81,17 @@ impl LocalUseMap<'me> {
local_use_map
}
crate fn defs(&self, local: LocalWithRegion) -> impl Iterator<Item = PointIndex> + '_ {
crate fn defs(&self, local: LiveVar) -> impl Iterator<Item = PointIndex> + '_ {
vll::iter(self.first_def_at[local], &self.appearances)
.map(move |aa| self.appearances[aa].point_index)
}
crate fn uses(&self, local: LocalWithRegion) -> impl Iterator<Item = PointIndex> + '_ {
crate fn uses(&self, local: LiveVar) -> impl Iterator<Item = PointIndex> + '_ {
vll::iter(self.first_use_at[local], &self.appearances)
.map(move |aa| self.appearances[aa].point_index)
}
crate fn drops(&self, local: LocalWithRegion) -> impl Iterator<Item = PointIndex> + '_ {
crate fn drops(&self, local: LiveVar) -> impl Iterator<Item = PointIndex> + '_ {
vll::iter(self.first_drop_at[local], &self.appearances)
.map(move |aa| self.appearances[aa].point_index)
}
......@@ -103,7 +103,7 @@ struct LocalUseMapBuild<'me, 'map> {
}
impl LocalUseMapBuild<'_, '_> {
fn insert_def(&mut self, local: LocalWithRegion, location: Location) {
fn insert_def(&mut self, local: LiveVar, location: Location) {
Self::insert(
self.elements,
&mut self.local_use_map.first_def_at[local],
......@@ -112,7 +112,7 @@ fn insert_def(&mut self, local: LocalWithRegion, location: Location) {
);
}
fn insert_use(&mut self, local: LocalWithRegion, location: Location) {
fn insert_use(&mut self, local: LiveVar, location: Location) {
Self::insert(
self.elements,
&mut self.local_use_map.first_use_at[local],
......@@ -121,7 +121,7 @@ fn insert_use(&mut self, local: LocalWithRegion, location: Location) {
);
}
fn insert_drop(&mut self, local: LocalWithRegion, location: Location) {
fn insert_drop(&mut self, local: LiveVar, location: Location) {
Self::insert(
self.elements,
&mut self.local_use_map.first_drop_at[local],
......
......@@ -9,7 +9,7 @@
// except according to those terms.
use borrow_check::nll::region_infer::values::{self, PointIndex, RegionValueElements};
use borrow_check::nll::type_check::liveness::liveness_map::{LocalWithRegion, NllLivenessMap};
use borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap};
use borrow_check::nll::type_check::liveness::local_use_map::LocalUseMap;
use borrow_check::nll::type_check::liveness::point_index_map::PointIndexMap;
use borrow_check::nll::type_check::AtLocation;
......@@ -194,7 +194,7 @@ fn reset_local_state(&mut self) {
}
/// Adds the definitions of `local` into `self.defs`.
fn add_defs_for(&mut self, live_local: LocalWithRegion) {
fn add_defs_for(&mut self, live_local: LiveVar) {
for def in self.cx.local_use_map.defs(live_local) {
debug!("- defined at {:?}", def);
self.defs.insert(def);
......@@ -207,7 +207,7 @@ fn add_defs_for(&mut self, live_local: LocalWithRegion) {
/// find a `def` of local.
///
/// Requires `add_defs_for(live_local)` to have been executed.
fn compute_use_live_points_for(&mut self, live_local: LocalWithRegion) {
fn compute_use_live_points_for(&mut self, live_local: LiveVar) {
debug!("compute_use_live_points_for(live_local={:?})", live_local);
self.stack.extend(self.cx.local_use_map.uses(live_local));
......@@ -233,7 +233,7 @@ fn compute_use_live_points_for(&mut self, live_local: LocalWithRegion) {
///
/// Requires `compute_use_live_points_for` and `add_defs_for` to
/// have been executed.
fn compute_drop_live_points_for(&mut self, live_local: LocalWithRegion) {
fn compute_drop_live_points_for(&mut self, live_local: LiveVar) {
debug!("compute_drop_live_points_for(live_local={:?})", live_local);
let local = self.cx.liveness_map.from_live_var(live_local);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册