rename BaseQueryContext to just QueryContext

And use it like `salsa::QueryContext` elsewhere.
This commit is contained in:
Niko Matsakis 2018-09-29 05:34:29 -04:00
parent 288fe5b25f
commit 2e40e9d1e5
9 changed files with 21 additions and 22 deletions

View file

@ -1,4 +1,4 @@
pub trait CompilerQueryContext: salsa::BaseQueryContext {
pub trait CompilerQueryContext: salsa::QueryContext {
fn interner(&self) -> &Interner;
}

View file

@ -1,7 +1,6 @@
use crate::class_table;
use crate::compiler::{CompilerQueryContext, Interner};
use salsa::query_context_storage;
use salsa::BaseQueryContext;
#[derive(Default)]
pub struct QueryContextImpl {
@ -37,7 +36,7 @@ impl CompilerQueryContext for QueryContextImpl {
// Seems like a classic case where specialization could be useful to
// permit behavior refinement.
impl BaseQueryContext for QueryContextImpl {
impl salsa::QueryContext for QueryContextImpl {
type QueryDescriptor = salsa::dyn_descriptor::DynDescriptor;
fn salsa_runtime(&self) -> &salsa::runtime::Runtime<QueryContextImpl> {

View file

@ -25,7 +25,7 @@ impl queries::CounterContext for QueryContextImpl {
}
}
impl salsa::BaseQueryContext for QueryContextImpl {
impl salsa::QueryContext for QueryContextImpl {
type QueryDescriptor = salsa::dyn_descriptor::DynDescriptor;
fn salsa_runtime(&self) -> &salsa::runtime::Runtime<QueryContextImpl> {

View file

@ -1,4 +1,4 @@
crate trait CounterContext: salsa::BaseQueryContext {
crate trait CounterContext: salsa::QueryContext {
fn increment(&self) -> usize;
}

View file

@ -1,5 +1,5 @@
use crate::BaseQueryContext;
use crate::Query;
use crate::QueryContext;
use crate::QueryTable;
use rustc_hash::FxHashMap;
use std::any::{Any, TypeId};
@ -26,7 +26,7 @@ pub struct DynDescriptor {
impl DynDescriptor {
pub fn from_key<QC, Q>(_query: &QC, key: &Q::Key) -> DynDescriptor
where
QC: BaseQueryContext,
QC: QueryContext,
Q: Query<QC>,
{
let type_id = TypeId::of::<Q>();

View file

@ -26,7 +26,7 @@ pub mod transparent;
pub use self::runtime::Runtime;
pub trait BaseQueryContext: Sized {
pub trait QueryContext: Sized {
/// A "query descriptor" packages up all the possible queries and a key.
/// It is used to store information about (e.g.) the stack.
///
@ -39,7 +39,7 @@ pub trait BaseQueryContext: Sized {
fn salsa_runtime(&self) -> &runtime::Runtime<Self>;
}
pub trait Query<QC: BaseQueryContext>: Debug + Default + Sized + 'static {
pub trait Query<QC: QueryContext>: Debug + Default + Sized + 'static {
type Key: Clone + Debug + Hash + Eq + Send;
type Value: Clone + Debug + Hash + Eq + Send;
type Storage: QueryStorageOps<QC, Self> + Send + Sync;
@ -49,7 +49,7 @@ pub trait Query<QC: BaseQueryContext>: Debug + Default + Sized + 'static {
pub trait QueryStorageOps<QC, Q>: Default
where
QC: BaseQueryContext,
QC: QueryContext,
Q: Query<QC>,
{
fn try_fetch<'q>(
@ -63,7 +63,7 @@ where
#[derive(new)]
pub struct QueryTable<'me, QC, Q>
where
QC: BaseQueryContext,
QC: QueryContext,
Q: Query<QC>,
{
pub query: &'me QC,
@ -75,7 +75,7 @@ pub struct CycleDetected;
impl<QC, Q> QueryTable<'me, QC, Q>
where
QC: BaseQueryContext,
QC: QueryContext,
Q: Query<QC>,
{
pub fn of(&self, key: Q::Key) -> Q::Value {

View file

@ -1,6 +1,6 @@
use crate::BaseQueryContext;
use crate::CycleDetected;
use crate::Query;
use crate::QueryContext;
use crate::QueryStorageOps;
use crate::QueryTable;
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
@ -20,7 +20,7 @@ use std::hash::Hash;
pub struct MemoizedStorage<QC, Q>
where
Q: Query<QC>,
QC: BaseQueryContext,
QC: QueryContext,
{
map: RwLock<FxHashMap<Q::Key, QueryState<Q::Value>>>,
}
@ -39,7 +39,7 @@ enum QueryState<V> {
impl<QC, Q> Default for MemoizedStorage<QC, Q>
where
Q: Query<QC>,
QC: BaseQueryContext,
QC: QueryContext,
{
fn default() -> Self {
MemoizedStorage {
@ -51,7 +51,7 @@ where
impl<QC, Q> QueryStorageOps<QC, Q> for MemoizedStorage<QC, Q>
where
Q: Query<QC>,
QC: BaseQueryContext,
QC: QueryContext,
{
fn try_fetch<'q>(
&self,

View file

@ -1,18 +1,18 @@
use crate::BaseQueryContext;
use crate::Query;
use crate::QueryContext;
use std::cell::RefCell;
use std::fmt::Write;
pub struct Runtime<QC>
where
QC: BaseQueryContext,
QC: QueryContext,
{
execution_stack: RefCell<Vec<QC::QueryDescriptor>>,
}
impl<QC> Default for Runtime<QC>
where
QC: BaseQueryContext,
QC: QueryContext,
{
fn default() -> Self {
Runtime {
@ -23,7 +23,7 @@ where
impl<QC> Runtime<QC>
where
QC: BaseQueryContext,
QC: QueryContext,
{
crate fn execute_query_implementation<Q>(
&self,

View file

@ -1,6 +1,6 @@
use crate::BaseQueryContext;
use crate::CycleDetected;
use crate::Query;
use crate::QueryContext;
use crate::QueryStorageOps;
use crate::QueryTable;
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
@ -23,7 +23,7 @@ pub struct TransparentStorage;
impl<QC, Q> QueryStorageOps<QC, Q> for TransparentStorage
where
Q: Query<QC>,
QC: BaseQueryContext,
QC: QueryContext,
{
fn try_fetch<'q>(
&self,