11use std:: rc:: Rc ;
22
33use fe_analyzer:: {
4+ db:: AnalyzerDbStorage ,
45 namespace:: { items as analyzer_items, types as analyzer_types} ,
56 AnalyzerDb ,
67} ;
7- use fe_common:: db:: Upcast ;
8+ use fe_common:: db:: { SourceDb , SourceDbStorage , Upcast , UpcastMut } ;
89
910use crate :: ir:: { self , ConstantId , TypeId } ;
1011
1112mod queries;
1213
1314#[ salsa:: query_group( MirDbStorage ) ]
14- pub trait MirDb : AnalyzerDb + Upcast < dyn AnalyzerDb > {
15+ pub trait MirDb : AnalyzerDb + Upcast < dyn AnalyzerDb > + UpcastMut < dyn AnalyzerDb > {
1516 #[ salsa:: interned]
1617 fn mir_intern_const ( & self , data : Rc < ir:: Constant > ) -> ir:: ConstantId ;
1718 #[ salsa:: interned]
1819 fn mir_intern_type ( & self , data : Rc < ir:: Type > ) -> ir:: TypeId ;
1920 #[ salsa:: interned]
2021 fn mir_intern_function ( & self , data : Rc < ir:: FunctionSignature > ) -> ir:: FunctionId ;
2122
23+ #[ salsa:: invoke( queries:: module:: mir_lower_module_all_functions) ]
24+ fn mir_lower_module_all_functions (
25+ & self ,
26+ module : analyzer_items:: ModuleId ,
27+ ) -> Rc < Vec < ir:: FunctionId > > ;
28+
29+ #[ salsa:: invoke( queries:: contract:: mir_lower_contract_all_functions) ]
30+ fn mir_lower_contract_all_functions (
31+ & self ,
32+ contract : analyzer_items:: ContractId ,
33+ ) -> Rc < Vec < ir:: FunctionId > > ;
34+
35+ #[ salsa:: invoke( queries:: structs:: mir_lower_struct_all_functions) ]
36+ fn mir_lower_struct_all_functions (
37+ & self ,
38+ struct_ : analyzer_items:: StructId ,
39+ ) -> Rc < Vec < ir:: FunctionId > > ;
40+
2241 #[ salsa:: invoke( queries:: types:: mir_lowered_type) ]
2342 fn mir_lowered_type ( & self , analyzer_type : analyzer_types:: Type ) -> TypeId ;
2443 #[ salsa:: invoke( queries:: types:: mir_lowered_event_type) ]
@@ -35,3 +54,34 @@ pub trait MirDb: AnalyzerDb + Upcast<dyn AnalyzerDb> {
3554 #[ salsa:: invoke( queries:: function:: mir_lowered_func_body) ]
3655 fn mir_lowered_func_body ( & self , func : ir:: FunctionId ) -> Rc < ir:: FunctionBody > ;
3756}
57+
58+ #[ salsa:: database( SourceDbStorage , AnalyzerDbStorage , MirDbStorage ) ]
59+ #[ derive( Default ) ]
60+ pub struct NewDb {
61+ storage : salsa:: Storage < NewDb > ,
62+ }
63+ impl salsa:: Database for NewDb { }
64+
65+ impl Upcast < dyn SourceDb > for NewDb {
66+ fn upcast ( & self ) -> & ( dyn SourceDb + ' static ) {
67+ & * self
68+ }
69+ }
70+
71+ impl UpcastMut < dyn SourceDb > for NewDb {
72+ fn upcast_mut ( & mut self ) -> & mut ( dyn SourceDb + ' static ) {
73+ & mut * self
74+ }
75+ }
76+
77+ impl Upcast < dyn AnalyzerDb > for NewDb {
78+ fn upcast ( & self ) -> & ( dyn AnalyzerDb + ' static ) {
79+ & * self
80+ }
81+ }
82+
83+ impl UpcastMut < dyn AnalyzerDb > for NewDb {
84+ fn upcast_mut ( & mut self ) -> & mut ( dyn AnalyzerDb + ' static ) {
85+ & mut * self
86+ }
87+ }
0 commit comments