@@ -16,6 +16,7 @@ pub struct HIRGlobalScopeStorage {
1616 pub scope : TypedGlobalScope ,
1717 pub descriptors : Vec < HIRFunction > ,
1818 pub implementations : Vec < HIRFunctionImpl > ,
19+ pub contexts : Vec < HIRBranchedContext > ,
1920}
2021
2122impl HIRGlobalScopeStorage {
@@ -24,6 +25,7 @@ impl HIRGlobalScopeStorage {
2425 scope : TypedGlobalScope :: new ( ) ,
2526 descriptors : vec ! [ ] ,
2627 implementations : vec ! [ ] ,
28+ contexts : vec ! [ ] ,
2729 }
2830 }
2931
@@ -46,7 +48,8 @@ impl HIRGlobalScopeStorage {
4648 origin : & K ,
4749 ) -> DiagnosticResult < usize > {
4850 self . descriptors . push ( descriptor) ;
49- self . implementations . push ( ( brctx, implementation) ) ;
51+ self . implementations . push ( implementation) ;
52+ self . contexts . push ( brctx) ;
5053
5154 self . scope . append (
5255 name,
@@ -83,7 +86,8 @@ impl HIRGlobalScopeStorage {
8386 origin : & K ,
8487 ) -> DiagnosticResult < usize > {
8588 self . descriptors . push ( descriptor) ;
86- self . implementations . push ( ( brctx, implementation) ) ;
89+ self . implementations . push ( implementation) ;
90+ self . contexts . push ( brctx) ;
8791
8892 let ind = self . scope . value_to_ind [ & TypedGlobalScopeEntry :: Type ( struct_type) ] ;
8993
@@ -164,14 +168,27 @@ impl HIRGlobalScopeStorage {
164168 return Ok ( self . descriptors [ ind] . clone ( ) ) ;
165169 }
166170
171+ pub fn get_function_ctx < K : DiagnosticSpanOrigin > (
172+ & self ,
173+ name : EntryKey ,
174+ origin : & K ,
175+ ) -> DiagnosticResult < HIRBranchedContext > {
176+ let ind = self . scope . get_function_ctx ( name, origin) ?;
177+
178+ return Ok ( self . contexts [ ind] . clone ( ) ) ;
179+ }
180+
167181 pub fn get_function_impl < K : DiagnosticSpanOrigin > (
168182 & self ,
169183 name : EntryKey ,
170184 origin : & K ,
171- ) -> DiagnosticResult < HIRFunctionImpl > {
185+ ) -> DiagnosticResult < ( HIRFunctionImpl , HIRBranchedContext ) > {
172186 let ind = self . scope . get_function_impl ( name, origin) ?;
173187
174- return Ok ( self . implementations [ ind] . clone ( ) ) ;
188+ return Ok ( (
189+ self . implementations [ ind] . clone ( ) ,
190+ self . contexts [ ind] . clone ( ) ,
191+ ) ) ;
175192 }
176193
177194 pub fn get_implless_function < K : DiagnosticSpanOrigin > (
@@ -201,12 +218,13 @@ impl HIRGlobalScopeStorage {
201218 & self ,
202219 name : EntryKey ,
203220 origin : & K ,
204- ) -> DiagnosticResult < ( HIRFunction , HIRFunctionImpl , RawType ) > {
221+ ) -> DiagnosticResult < ( HIRFunction , HIRFunctionImpl , HIRBranchedContext , RawType ) > {
205222 let res = self . scope . get_exact_struct_function ( name, origin) ?;
206223
207224 return Ok ( (
208225 self . descriptors [ res. 0 ] . clone ( ) ,
209226 self . implementations [ res. 1 ] . clone ( ) ,
227+ self . contexts [ res. 1 ] . clone ( ) ,
210228 res. 2 ,
211229 ) ) ;
212230 }
0 commit comments