33use core:: cmp;
44use std:: collections:: { BTreeMap , BTreeSet , HashMap } ;
55
6- use indexmap:: IndexMap ;
6+ use indexmap:: { IndexMap , IndexSet } ;
77use quote:: format_ident;
88use syn:: { Ident , Type } ;
99
@@ -178,15 +178,15 @@ pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
178178 }
179179
180180 // e. Location of resources
181- let mut shared_resource_locations = IndexMap :: new ( ) ;
181+ let mut used_shared_resource = IndexSet :: new ( ) ;
182182 let mut ownerships = Ownerships :: new ( ) ;
183183 let mut sync_types = SyncTypes :: new ( ) ;
184184 for ( prio, name, access) in app. shared_resource_accesses ( ) {
185185 let res = app. shared_resources . get ( name) . expect ( "UNREACHABLE" ) ;
186186
187187 // (e)
188- // Add each resource to shared_resource_locations
189- shared_resource_locations . insert ( name. clone ( ) , Location :: Owned ) ;
188+ // This shared resource is used
189+ used_shared_resource . insert ( name. clone ( ) ) ;
190190
191191 // (c)
192192 if let Some ( priority) = prio {
@@ -219,11 +219,11 @@ pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
219219 }
220220
221221 // Create the list of used local resource Idents
222- let mut local_resource_locations = IndexMap :: new ( ) ;
222+ let mut used_local_resource = IndexSet :: new ( ) ;
223223
224224 for ( _, _, locals, _) in task_resources_list {
225225 for ( local, _) in locals {
226- local_resource_locations . insert ( local. clone ( ) , Location :: Owned ) ;
226+ used_local_resource . insert ( local. clone ( ) ) ;
227227 }
228228 }
229229
@@ -281,8 +281,8 @@ pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
281281
282282 Ok ( Analysis {
283283 channels,
284- shared_resource_locations ,
285- local_resource_locations ,
284+ shared_resources : used_shared_resource ,
285+ local_resources : used_local_resource ,
286286 tasks,
287287 ownerships,
288288 send_types,
@@ -310,17 +310,17 @@ pub struct Analysis {
310310 /// SPSC message channels
311311 pub channels : Channels ,
312312
313- /// Location of all *used* shared resources
313+ /// Shared resources
314314 ///
315- /// If a resource is not listed here it means that's a "dead" (never accessed) resource and the
316- /// backend should not generate code for it
317- pub shared_resource_locations : SharedResourceLocations ,
315+ /// If a resource is not listed here it means that's a "dead" (never
316+ /// accessed) resource and the backend should not generate code for it
317+ pub shared_resources : UsedSharedResource ,
318318
319- /// Location of all *used* local resources
319+ /// Local resources
320320 ///
321- /// If a resource is not listed here it means that's a "dead" (never accessed) resource and the
322- /// backend should not generate code for it
323- pub local_resource_locations : LocalResourceLocations ,
321+ /// If a resource is not listed here it means that's a "dead" (never
322+ /// accessed) resource and the backend should not generate code for it
323+ pub local_resources : UsedLocalResource ,
324324
325325 /// A vector containing all task names
326326 pub tasks : Tasks ,
@@ -339,10 +339,10 @@ pub struct Analysis {
339339pub type Channels = BTreeMap < Priority , Channel > ;
340340
341341/// Location of all *used* shared resources
342- pub type SharedResourceLocations = IndexMap < Resource , Location > ;
342+ pub type UsedSharedResource = IndexSet < Resource > ;
343343
344344/// Location of all *used* local resources
345- pub type LocalResourceLocations = IndexMap < Resource , Location > ;
345+ pub type UsedLocalResource = IndexSet < Resource > ;
346346
347347/// Resource ownership
348348pub type Ownerships = IndexMap < Resource , Ownership > ;
@@ -404,10 +404,3 @@ impl Ownership {
404404 matches ! ( self , Ownership :: Owned { .. } )
405405 }
406406}
407-
408- /// Resource location
409- #[ derive( Clone , Debug , PartialEq ) ]
410- pub enum Location {
411- /// resource that is owned
412- Owned ,
413- }
0 commit comments