@@ -837,7 +837,7 @@ impl Frame {
837837// Instruction
838838//-------------------------------------------------------------------------
839839
840- #[ derive( Debug , Clone ) ]
840+ #[ derive( Debug , Clone , PartialEq ) ]
841841pub enum Instruction {
842842 StartBlock { block : usize } ,
843843 GetIterator { iterator : usize , bail : i32 , constraint : usize } ,
@@ -2847,8 +2847,21 @@ impl Program {
28472847 }
28482848
28492849 pub fn unregister_block ( & mut self , name : String ) {
2850- println ! ( "Unregister: {}" , name) ;
2851- unimplemented ! ( ) ;
2850+ if let Some ( block_ix) = self . block_info . block_names . remove ( & name) {
2851+ let block = self . block_info . blocks . remove ( block_ix) ;
2852+ for ( pipe_ix, pipe) in block. pipes . iter ( ) . enumerate ( ) {
2853+ for shape in block. shapes [ pipe_ix] . iter ( ) {
2854+ match shape {
2855+ & PipeShape :: Scan ( e, a, v) => {
2856+ self . block_info . pipe_lookup . get_mut ( & ( e, a, v) ) . unwrap ( ) . remove_item ( pipe) ;
2857+ } ,
2858+ & PipeShape :: Intermediate ( id) => {
2859+ self . block_info . intermediate_pipe_lookup . get_mut ( & id) . unwrap ( ) . remove_item ( pipe) ;
2860+ }
2861+ }
2862+ }
2863+ }
2864+ }
28522865 }
28532866
28542867 pub fn insert_block ( & mut self , name : & str , code : & str ) {
@@ -3119,13 +3132,6 @@ impl CodeTransaction {
31193132 let ref mut frame = self . frame ;
31203133 let ref mut iter_pool = self . iter_pool ;
31213134
3122- for add in to_add {
3123- frame. reset ( ) ;
3124- frame. input = Some ( Change { e : 0 , a : 0 , v : 0 , n : 0 , transaction : 0 , round : 0 , count : 1 } ) ;
3125- program. register_block ( add) ;
3126- interpret ( & mut program. state , & program. block_info , iter_pool, frame, & program. block_info . blocks . last ( ) . unwrap ( ) . pipes [ 0 ] ) ;
3127- }
3128-
31293135 for name in to_remove {
31303136 {
31313137 let block_ix = match program. block_info . block_names . get ( & name) {
@@ -3141,6 +3147,13 @@ impl CodeTransaction {
31413147 program. unregister_block ( name) ;
31423148 }
31433149
3150+ for add in to_add {
3151+ frame. reset ( ) ;
3152+ frame. input = Some ( Change { e : 0 , a : 0 , v : 0 , n : 0 , transaction : 0 , round : 0 , count : 1 } ) ;
3153+ program. register_block ( add) ;
3154+ interpret ( & mut program. state , & program. block_info , iter_pool, frame, & program. block_info . blocks . last ( ) . unwrap ( ) . pipes [ 0 ] ) ;
3155+ }
3156+
31443157 let mut max_round = 0 ;
31453158 intermediate_flow ( frame, & mut program. state , & program. block_info , iter_pool, 0 , & mut max_round) ;
31463159
0 commit comments