@@ -599,11 +599,23 @@ impl crate::Type {
599
599
}
600
600
}
601
601
602
+ #[ derive( Clone , Copy ) ]
602
603
enum FunctionOrigin {
603
604
Handle ( Handle < crate :: Function > ) ,
604
605
EntryPoint ( proc:: EntryPointIndex ) ,
605
606
}
606
607
608
+ trait NameKeyExt {
609
+ fn local ( origin : FunctionOrigin , local_handle : Handle < crate :: LocalVariable > ) -> NameKey {
610
+ match origin {
611
+ FunctionOrigin :: Handle ( handle) => NameKey :: FunctionLocal ( handle, local_handle) ,
612
+ FunctionOrigin :: EntryPoint ( idx) => NameKey :: EntryPointLocal ( idx, local_handle) ,
613
+ }
614
+ }
615
+ }
616
+
617
+ impl NameKeyExt for NameKey { }
618
+
607
619
/// A level of detail argument.
608
620
///
609
621
/// When [`BoundsCheckPolicy::Restrict`] applies to an [`ImageLoad`] access, we
@@ -1750,14 +1762,7 @@ impl<W: Write> Writer<W> {
1750
1762
write ! ( self . out, "{name}" ) ?;
1751
1763
}
1752
1764
crate :: Expression :: LocalVariable ( handle) => {
1753
- let name_key = match context. origin {
1754
- FunctionOrigin :: Handle ( fun_handle) => {
1755
- NameKey :: FunctionLocal ( fun_handle, handle)
1756
- }
1757
- FunctionOrigin :: EntryPoint ( ep_index) => {
1758
- NameKey :: EntryPointLocal ( ep_index, handle)
1759
- }
1760
- } ;
1765
+ let name_key = NameKey :: local ( context. origin , handle) ;
1761
1766
let name = & self . names [ & name_key] ;
1762
1767
write ! ( self . out, "{name}" ) ?;
1763
1768
}
0 commit comments