@@ -719,7 +719,10 @@ pub fn new_mark_internal(m:Mrk, tail:SyntaxContext,table:&mut SCTable)
719
719
// let try_lookup = table.mark_memo.find(&key);
720
720
match table. mark_memo . contains_key ( & key) {
721
721
false => {
722
- let new_idx = idx_push ( & mut table. table , Mark ( m, tail) ) ;
722
+ let new_idx = {
723
+ let mut table = table. table . borrow_mut ( ) ;
724
+ idx_push ( table. get ( ) , Mark ( m, tail) )
725
+ } ;
723
726
table. mark_memo . insert ( key, new_idx) ;
724
727
new_idx
725
728
}
@@ -746,7 +749,10 @@ pub fn new_rename_internal(id:Ident, to:Name, tail:SyntaxContext, table: &mut SC
746
749
//let try_lookup = table.rename_memo.find(&key);
747
750
match table. rename_memo . contains_key ( & key) {
748
751
false => {
749
- let new_idx = idx_push ( & mut table. table , Rename ( id, to, tail) ) ;
752
+ let new_idx = {
753
+ let mut table = table. table . borrow_mut ( ) ;
754
+ idx_push ( table. get ( ) , Rename ( id, to, tail) )
755
+ } ;
750
756
table. rename_memo . insert ( key, new_idx) ;
751
757
new_idx
752
758
}
@@ -764,7 +770,7 @@ pub fn new_rename_internal(id:Ident, to:Name, tail:SyntaxContext, table: &mut SC
764
770
// FIXME #8215 : currently pub to allow testing
765
771
pub fn new_sctable_internal ( ) -> SCTable {
766
772
SCTable {
767
- table : ~[ EmptyCtxt , IllegalCtxt ] ,
773
+ table : RefCell :: new ( ~[ EmptyCtxt , IllegalCtxt ] ) ,
768
774
mark_memo : HashMap :: new ( ) ,
769
775
rename_memo : HashMap :: new ( )
770
776
}
@@ -786,7 +792,8 @@ pub fn get_sctable() -> @mut SCTable {
786
792
/// print out an SCTable for debugging
787
793
pub fn display_sctable ( table : & SCTable ) {
788
794
error ! ( "SC table:" ) ;
789
- for ( idx, val) in table. table . iter ( ) . enumerate ( ) {
795
+ let table = table. table . borrow ( ) ;
796
+ for ( idx, val) in table. get ( ) . iter ( ) . enumerate ( ) {
790
797
error ! ( "{:4u} : {:?}" , idx, val) ;
791
798
}
792
799
}
@@ -832,7 +839,11 @@ pub fn resolve_internal(id : Ident,
832
839
match resolve_table. contains_key ( & key) {
833
840
false => {
834
841
let resolved = {
835
- match table. table [ id. ctxt ] {
842
+ let result = {
843
+ let table = table. table . borrow ( ) ;
844
+ table. get ( ) [ id. ctxt ]
845
+ } ;
846
+ match result {
836
847
EmptyCtxt => id. name ,
837
848
// ignore marks here:
838
849
Mark ( _, subctxt) =>
@@ -877,7 +888,11 @@ pub fn marksof(ctxt: SyntaxContext, stopname: Name, table: &SCTable) -> ~[Mrk] {
877
888
let mut result = ~[ ] ;
878
889
let mut loopvar = ctxt;
879
890
loop {
880
- match table. table [ loopvar] {
891
+ let table_entry = {
892
+ let table = table. table . borrow ( ) ;
893
+ table. get ( ) [ loopvar]
894
+ } ;
895
+ match table_entry {
881
896
EmptyCtxt => { return result; } ,
882
897
Mark ( mark, tl) => {
883
898
xorPush ( & mut result, mark) ;
@@ -901,7 +916,8 @@ pub fn marksof(ctxt: SyntaxContext, stopname: Name, table: &SCTable) -> ~[Mrk] {
901
916
/// FAILS when outside is not a mark.
902
917
pub fn mtwt_outer_mark ( ctxt : SyntaxContext ) -> Mrk {
903
918
let sctable = get_sctable ( ) ;
904
- match sctable. table [ ctxt] {
919
+ let table = sctable. table . borrow ( ) ;
920
+ match table. get ( ) [ ctxt] {
905
921
ast:: Mark ( mrk, _) => mrk,
906
922
_ => fail ! ( "can't retrieve outer mark when outside is not a mark" )
907
923
}
@@ -1018,7 +1034,8 @@ mod test {
1018
1034
fn refold_test_sc ( mut sc : SyntaxContext , table : & SCTable ) -> ~[ TestSC ] {
1019
1035
let mut result = ~[ ] ;
1020
1036
loop {
1021
- match table. table [ sc] {
1037
+ let table = table. table . borrow ( ) ;
1038
+ match table. get ( ) [ sc] {
1022
1039
EmptyCtxt => { return result; } ,
1023
1040
Mark ( mrk, tail) => {
1024
1041
result. push ( M ( mrk) ) ;
@@ -1040,9 +1057,12 @@ mod test {
1040
1057
1041
1058
let test_sc = ~[ M ( 3 ) , R ( id ( 101 , 0 ) , 14 ) , M ( 9 ) ] ;
1042
1059
assert_eq ! ( unfold_test_sc( test_sc. clone( ) , EMPTY_CTXT , & mut t) , 4 ) ;
1043
- assert_eq ! ( t. table[ 2 ] , Mark ( 9 , 0 ) ) ;
1044
- assert_eq ! ( t. table[ 3 ] , Rename ( id( 101 , 0 ) , 14 , 2 ) ) ;
1045
- assert_eq ! ( t. table[ 4 ] , Mark ( 3 , 3 ) ) ;
1060
+ {
1061
+ let table = t. table . borrow ( ) ;
1062
+ assert_eq ! ( table. get( ) [ 2 ] , Mark ( 9 , 0 ) ) ;
1063
+ assert_eq ! ( table. get( ) [ 3 ] , Rename ( id( 101 , 0 ) , 14 , 2 ) ) ;
1064
+ assert_eq ! ( table. get( ) [ 4 ] , Mark ( 3 , 3 ) ) ;
1065
+ }
1046
1066
assert_eq ! ( refold_test_sc( 4 , & t) , test_sc) ;
1047
1067
}
1048
1068
@@ -1057,8 +1077,11 @@ mod test {
1057
1077
let mut t = new_sctable_internal ( ) ;
1058
1078
1059
1079
assert_eq ! ( unfold_marks( ~[ 3 , 7 ] , EMPTY_CTXT , & mut t) , 3 ) ;
1060
- assert_eq ! ( t. table[ 2 ] , Mark ( 7 , 0 ) ) ;
1061
- assert_eq ! ( t. table[ 3 ] , Mark ( 3 , 2 ) ) ;
1080
+ {
1081
+ let table = t. table . borrow ( ) ;
1082
+ assert_eq ! ( table. get( ) [ 2 ] , Mark ( 7 , 0 ) ) ;
1083
+ assert_eq ! ( table. get( ) [ 3 ] , Mark ( 3 , 2 ) ) ;
1084
+ }
1062
1085
}
1063
1086
1064
1087
#[ test] fn test_marksof ( ) {
0 commit comments