Created
April 16, 2019 09:16
-
-
Save pnkfelix/dc3f0f8568ca093d9750653578bb8026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source text was created by expanding (and then contracting and | |
// culling) the following code: | |
/* | |
use salsa; | |
use std::panic; | |
mod impls; | |
#[salsa::database(SourceDatabaseStorage)] | |
#[derive(Debug)] | |
pub(crate) struct RootDatabase { runtime: salsa::Runtime<RootDatabase>, } | |
impl salsa::Database for RootDatabase { | |
fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> { loop { } } | |
} | |
pub trait CheckCanceled: panic::RefUnwindSafe{} | |
impl<T: panic::RefUnwindSafe> CheckCanceled for T {} | |
#[salsa::query_group(SourceDatabaseStorage)] | |
pub trait SourceDatabase: CheckCanceled + std::fmt::Debug { | |
fn parse(&self) -> u32; | |
} | |
fn parse(db: &impl SourceDatabase) -> u32 { | |
loop { } | |
} | |
*/ | |
#![feature(crate_in_paths, extern_prelude)] | |
use std::panic; | |
use crate::salsa::{Runtime, Database, Query, plumbing}; | |
mod salsa { | |
mod derived { | |
use crate::salsa::plumbing::QueryFunction; | |
use crate::salsa::plumbing::QueryStorageMassOps; | |
use crate::salsa::{Database, }; | |
use std::marker::PhantomData; | |
use std::panic::RefUnwindSafe; | |
pub type MemoizedStorage<DB, Q> = DerivedStorage<DB, Q, AlwaysMemoizeValue>; | |
pub struct DerivedStorage<DB, Q, MP> | |
{ | |
_map: PhantomData<fn() -> (DB, Q)>, | |
policy: PhantomData<MP>, | |
} | |
impl<DB, Q, MP> RefUnwindSafe for DerivedStorage<DB, Q, MP> | |
{ | |
} | |
pub trait MemoizationPolicy<DB, Q> | |
where | |
Q: QueryFunction<DB>, | |
DB: Database, | |
{ | |
} | |
pub enum AlwaysMemoizeValue {} | |
impl<DB, Q> MemoizationPolicy<DB, Q> for AlwaysMemoizeValue | |
where | |
Q: QueryFunction<DB>, | |
DB: Database, | |
{ | |
} | |
// pub enum NeverMemoizeValue {} | |
// pub enum VolatileValue {} | |
impl<DB, Q, MP> QueryStorageMassOps<DB> for DerivedStorage<DB, Q, MP> | |
where | |
Q: QueryFunction<DB>, | |
DB: Database, | |
MP: MemoizationPolicy<DB, Q>, | |
{ | |
} | |
} | |
mod runtime { | |
use crate::salsa::{Database}; | |
use std::panic::RefUnwindSafe; | |
pub struct Runtime<DB: Database> { | |
_shared_state: Box<SharedState<DB>>, | |
} | |
struct SharedState<DB: Database> { | |
_storage: DB::DatabaseStorage, | |
} | |
impl<DB> RefUnwindSafe for SharedState<DB> | |
where | |
DB: Database, | |
DB::DatabaseStorage: RefUnwindSafe, | |
{ | |
} | |
#[derive(Copy, Clone, PartialEq, Eq)] | |
pub struct RuntimeId { | |
counter: usize, | |
} | |
#[derive(Clone)] | |
pub(crate) struct StampedValue<V> { | |
pub(crate) value: V, | |
} | |
} | |
pub mod plumbing { | |
#![allow(missing_docs)] | |
use crate::salsa::Database; | |
use crate::salsa::Query; | |
pub use crate::salsa::derived::MemoizedStorage; | |
pub trait DatabaseStorageTypes: Sized { | |
type DatabaseKey; | |
type DatabaseStorage; | |
} | |
pub trait DatabaseOps: Sized { } | |
pub trait QueryStorageMassOps<DB: Database> { } | |
pub trait DatabaseKey<DB>: Clone + Eq + Send + Sync { } | |
pub trait QueryFunction<DB: Database>: Query<DB> { } | |
pub trait QueryGroup<DB: Database> { | |
type GroupStorage; | |
type GroupKey; | |
} | |
pub trait HasQueryGroup<G>: Database { } | |
} | |
pub use self::runtime::Runtime; | |
pub trait Database: plumbing::DatabaseStorageTypes + plumbing::DatabaseOps { } | |
pub trait ParallelDatabase: Database + Send { } | |
pub trait Query<DB: Database>: Sized + 'static { | |
type Storage; | |
} | |
} | |
pub(crate) struct RootDatabase { | |
_runtime: Runtime<RootDatabase>, | |
} | |
// #[derive(Default)] | |
pub(crate) struct __SalsaDatabaseStorage { | |
_s: SourceDatabaseGroupStorage__<RootDatabase>, | |
} | |
// #[cfg(not_now)] | |
impl Default for __SalsaDatabaseStorage { | |
fn default() -> Self { | |
loop { } | |
} | |
} | |
#[doc(hidden)] | |
#[derive(Clone, PartialEq, Eq)] | |
pub(crate) struct __SalsaDatabaseKey; | |
impl plumbing::DatabaseStorageTypes for RootDatabase { | |
type DatabaseKey = __SalsaDatabaseKey; | |
type DatabaseStorage = __SalsaDatabaseStorage; | |
} | |
impl plumbing::DatabaseOps for RootDatabase {} | |
impl plumbing::DatabaseKey<RootDatabase> for __SalsaDatabaseKey {} | |
impl plumbing::HasQueryGroup<SourceDatabaseStorage> for RootDatabase {} | |
impl Database for RootDatabase {} | |
pub trait CheckCanceled: panic::RefUnwindSafe { } | |
impl <T: panic::RefUnwindSafe> CheckCanceled for T { } | |
pub trait SourceDatabase: CheckCanceled { | |
fn parse(&self) -> u32 { loop { } } | |
} | |
pub struct SourceDatabaseStorage {} | |
impl <DB__> plumbing::QueryGroup<DB__> for SourceDatabaseStorage where | |
DB__: SourceDatabase, DB__: Database { | |
type GroupStorage = (); | |
type GroupKey = (); | |
} | |
impl <T> SourceDatabase for T | |
where T: CheckCanceled, | |
T: plumbing::HasQueryGroup<SourceDatabaseStorage> | |
{ | |
} | |
pub struct ParseQuery; | |
impl <DB> Query<DB> for ParseQuery where DB: SourceDatabase, | |
DB: Database | |
{ | |
type Storage = plumbing::MemoizedStorage<DB, Self>; | |
} | |
pub struct SourceDatabaseGroupStorage__<DB__> where DB__: SourceDatabase, | |
DB__: Database { | |
pub parse: <ParseQuery as Query<DB__>>::Storage, | |
} | |
impl <DB__> Default for SourceDatabaseGroupStorage__<DB__> where | |
DB__: SourceDatabase, DB__: Database { | |
fn default() -> Self { | |
loop { } | |
} | |
} | |
// mod impls; | |
// use ra_db::SourceDatabase; | |
// use crate::RootDatabase; | |
pub(crate) fn goto_implementation(db: &RootDatabase) -> u32 | |
{ db.parse(); loop { } } | |
fn main() { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment