@@ -26,9 +26,24 @@ pub(crate) trait Scoper {
2626pub ( crate ) struct NoScoper ;
2727impl Scoper for NoScoper { }
2828
29- pub type VisitorScopeMap = ScopeMap < VarIdent , bool > ;
29+ pub enum BndKind {
30+ Let ,
31+ Quant ,
32+ Lambda ,
33+ Choose ,
34+ /// Used by a pass in triggers.rs to distinguish trigger variables of interest
35+ /// that are bound outside the walked expression.
36+ OuterTrigger ,
37+ }
38+
39+ pub ( crate ) struct ScopeEntry {
40+ /// Is this a Quant, Choose, or Let?
41+ pub bnd_kind : BndKind ,
42+ }
43+
44+ pub type VisitorScopeMap = ScopeMap < VarIdent , ScopeEntry > ;
3045
31- impl Scoper for ScopeMap < VarIdent , bool > {
46+ impl Scoper for ScopeMap < VarIdent , ScopeEntry > {
3247 fn push_scope ( & mut self ) {
3348 self . push_scope ( true ) ;
3449 }
@@ -38,17 +53,20 @@ impl Scoper for ScopeMap<VarIdent, bool> {
3853 }
3954
4055 fn insert_binding_typ ( & mut self , binder : & VarBinder < Typ > , bnd_source : & Bnd ) {
41- let is_triggered = match bnd_source. x {
42- BndX :: Quant ( ..) | BndX :: Choose ( ..) => true ,
43- BndX :: Lambda ( ..) => false ,
56+ let bnd_kind = match bnd_source. x {
57+ BndX :: Quant ( ..) => BndKind :: Quant ,
58+ BndX :: Choose ( ..) => BndKind :: Choose ,
59+ BndX :: Lambda ( ..) => BndKind :: Lambda ,
4460 BndX :: Let ( ..) => unreachable ! ( ) ,
4561 } ;
46- let _ = self . insert ( binder. name . clone ( ) , is_triggered) ;
62+ let entry = ScopeEntry { bnd_kind : bnd_kind } ;
63+ let _ = self . insert ( binder. name . clone ( ) , entry) ;
4764 }
4865
4966 fn insert_binding_exp ( & mut self , binder : & VarBinder < Exp > , bnd_source : & Bnd ) {
5067 assert ! ( matches!( bnd_source. x, BndX :: Let ( ..) ) ) ;
51- let _ = self . insert ( binder. name . clone ( ) , true ) ;
68+ let entry = ScopeEntry { bnd_kind : BndKind :: Let } ;
69+ let _ = self . insert ( binder. name . clone ( ) , entry) ;
5270 }
5371}
5472
0 commit comments