2018-09-28 15:26:53 +00:00
|
|
|
use crate::compiler;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
2018-10-05 14:35:50 +00:00
|
|
|
salsa::query_group! {
|
2018-10-05 08:54:51 +00:00
|
|
|
pub trait ClassTableDatabase: compiler::CompilerDatabase {
|
2018-09-28 15:26:53 +00:00
|
|
|
/// Get the fields.
|
2018-10-05 09:28:51 +00:00
|
|
|
fn fields(class: DefId) -> Arc<Vec<DefId>> {
|
|
|
|
type Fields;
|
|
|
|
}
|
2018-09-28 15:26:53 +00:00
|
|
|
|
|
|
|
/// Get the list of all classes
|
2018-10-19 01:26:48 +00:00
|
|
|
fn all_classes() -> Arc<Vec<DefId>> {
|
2018-10-05 09:28:51 +00:00
|
|
|
type AllClasses;
|
|
|
|
}
|
2018-09-28 15:26:53 +00:00
|
|
|
|
|
|
|
/// Get the list of all fields
|
2018-10-19 01:26:48 +00:00
|
|
|
fn all_fields() -> Arc<Vec<DefId>> {
|
2018-10-05 09:28:51 +00:00
|
|
|
type AllFields;
|
|
|
|
}
|
2018-09-29 08:32:41 +00:00
|
|
|
}
|
2018-09-28 15:26:53 +00:00
|
|
|
}
|
|
|
|
|
2018-09-28 15:40:20 +00:00
|
|
|
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
|
|
|
|
pub struct DefId(usize);
|
2018-09-28 15:26:53 +00:00
|
|
|
|
2018-10-19 01:26:48 +00:00
|
|
|
fn all_classes(_: &impl ClassTableDatabase) -> Arc<Vec<DefId>> {
|
2018-10-05 14:30:17 +00:00
|
|
|
Arc::new(vec![DefId(0), DefId(10)]) // dummy impl
|
2018-09-28 15:26:53 +00:00
|
|
|
}
|
|
|
|
|
2018-10-05 14:30:17 +00:00
|
|
|
fn fields(_: &impl ClassTableDatabase, class: DefId) -> Arc<Vec<DefId>> {
|
|
|
|
Arc::new(vec![DefId(class.0 + 1), DefId(class.0 + 2)]) // dummy impl
|
2018-09-28 15:26:53 +00:00
|
|
|
}
|
|
|
|
|
2018-10-19 01:26:48 +00:00
|
|
|
fn all_fields(db: &impl ClassTableDatabase) -> Arc<Vec<DefId>> {
|
2018-10-05 14:30:17 +00:00
|
|
|
Arc::new(
|
2018-10-19 01:26:48 +00:00
|
|
|
db.all_classes()
|
2018-10-05 14:30:17 +00:00
|
|
|
.iter()
|
|
|
|
.cloned()
|
|
|
|
.flat_map(|def_id| {
|
|
|
|
let fields = db.fields(def_id);
|
|
|
|
(0..fields.len()).map(move |i| fields[i])
|
2018-10-19 01:26:48 +00:00
|
|
|
})
|
|
|
|
.collect(),
|
2018-10-05 14:30:17 +00:00
|
|
|
)
|
2018-09-28 15:26:53 +00:00
|
|
|
}
|