File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -184,9 +184,22 @@ impl VM {
184184 if self . environs . len ( ) == 0 {
185185 panic ! ( "pop_environment: environs is empty" ) ;
186186 }
187- ( & mut * self . environs . last ( ) . unwrap ( ) . borrow_mut ( ) )
188- . vars
189- . clear ( ) ;
187+ // Fuck reference counted ptrs
188+ // Why do I have to count references, MANUALLY
189+ // (there is probably a better way to do this, but time's ticking)
190+ let environ = self . environs . last ( ) . unwrap ( ) ;
191+ let mut refs: usize = 0 ;
192+ for e in self . environs . iter ( ) {
193+ if Rc :: ptr_eq ( e, environ) {
194+ refs += 1 ;
195+ }
196+ }
197+
198+ // If refs != 1, the vars are prolly used somewhere else so don't clear them
199+ if refs == 1 {
200+ ( & mut * environ. borrow_mut ( ) ) . vars . clear ( ) ;
201+ }
202+
190203 self . environs . pop ( ) ;
191204 }
192205
You can’t perform that action at this time.
0 commit comments