2019-10-11 14:49:14 +00:00
|
|
|
use crate::compiler::CompilerDatabase;
|
|
|
|
use crate::interner::InternerDatabase;
|
2018-09-28 15:40:20 +00:00
|
|
|
|
2018-10-05 08:54:51 +00:00
|
|
|
/// Our "database" will be threaded through our application (though
|
|
|
|
/// 99% of the application only interacts with it through traits and
|
|
|
|
/// never knows its real name). It contains all the values for all of
|
|
|
|
/// our memoized queries and encapsulates **all mutable state that
|
|
|
|
/// persists longer than a single query execution.**
|
2018-09-29 10:10:06 +00:00
|
|
|
///
|
2018-10-05 08:54:51 +00:00
|
|
|
/// Databases can contain whatever you want them to, but salsa
|
2018-10-07 11:08:22 +00:00
|
|
|
/// requires you to add a `salsa::Runtime` member. Note
|
2018-09-29 10:44:08 +00:00
|
|
|
/// though: you should be very careful if adding shared, mutable state
|
|
|
|
/// to your context (e.g., a shared counter or some such thing). If
|
|
|
|
/// mutations to that shared state affect the results of your queries,
|
|
|
|
/// that's going to mess up the incremental results.
|
2019-10-11 14:49:14 +00:00
|
|
|
#[salsa::database(InternerDatabase, CompilerDatabase)]
|
2018-09-28 15:40:20 +00:00
|
|
|
#[derive(Default)]
|
2018-10-05 08:54:51 +00:00
|
|
|
pub struct DatabaseImpl {
|
2020-07-02 10:31:02 +00:00
|
|
|
storage: salsa::Storage<DatabaseImpl>,
|
2018-09-28 15:40:20 +00:00
|
|
|
}
|
|
|
|
|
2018-09-29 10:44:08 +00:00
|
|
|
/// This impl tells salsa where to find the salsa runtime.
|
2020-07-02 10:31:02 +00:00
|
|
|
impl salsa::Database for DatabaseImpl {}
|