Why did last checkin of VarSrcTokTable add carot-M to every line end but the whole...
[IRC.git] / Robust / src / Analysis / MLP / VarSrcTokTable.java
1 package Analysis.MLP;
2
3 import IR.*;
4 import IR.Flat.*;
5 import java.util.*;
6 import java.io.*;
7
8 // This class formerly had lazy consistency properties, but
9 // it is being changed so that the full set and the extra
10 // hash tables to access the full set efficiently by different
11 // elements will be consistent after EVERY operation.  Also,
12 // a consistent assert method allows a debugger to ask whether
13 // an operation has produced an inconsistent VarSrcTokTable.
14 public class VarSrcTokTable {
15
16   // a set of every token in the table
17   private HashSet<VariableSourceToken> trueSet;
18
19   // these hashtables provide an efficient retreival from the true set
20   private Hashtable< TempDescriptor,    Set<VariableSourceToken> >  var2vst;
21   private Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> > sese2vst;
22   private Hashtable< SVKey,             Set<VariableSourceToken> >   sv2vst;
23
24   // maximum age from aging operation
25   private Integer MAX_AGE = new Integer( 2 );
26
27
28   public VarSrcTokTable() {
29     trueSet = new HashSet<VariableSourceToken>();
30
31     sese2vst = new Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> >();
32     var2vst  = new Hashtable< TempDescriptor,    Set<VariableSourceToken> >();
33     sv2vst   = new Hashtable< SVKey,             Set<VariableSourceToken> >();
34   }
35
36   
37   public VarSrcTokTable( VarSrcTokTable in ) {
38     trueSet = (HashSet<VariableSourceToken>) in.trueSet.clone();
39
40     Iterator itr; Set s;
41
42     sese2vst = new Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> >();
43     itr = in.sese2vst.entrySet().iterator();
44     while( itr.hasNext() ) {
45       Map.Entry                    me   = (Map.Entry)                    itr.next();
46       FlatSESEEnterNode            sese = (FlatSESEEnterNode)            me.getKey();
47       HashSet<VariableSourceToken> s1   = (HashSet<VariableSourceToken>) me.getValue();      
48       assert s1 != null;
49       sese2vst.put( sese, 
50                     (HashSet<VariableSourceToken>) (s1.clone()) );
51     }
52
53     var2vst = new Hashtable< TempDescriptor, Set<VariableSourceToken> >();
54     itr = in.var2vst.entrySet().iterator();
55     while( itr.hasNext() ) {
56       Map.Entry                    me  = (Map.Entry)                    itr.next();
57       TempDescriptor               var = (TempDescriptor)               me.getKey();
58       HashSet<VariableSourceToken> s1  = (HashSet<VariableSourceToken>) me.getValue();      
59       assert s1 != null;
60       var2vst.put( var, 
61                    (HashSet<VariableSourceToken>) (s1.clone()) );
62     }
63
64     sv2vst = new Hashtable< SVKey, Set<VariableSourceToken> >();
65     itr = in.sv2vst.entrySet().iterator();
66     while( itr.hasNext() ) {
67       Map.Entry                    me  = (Map.Entry)                    itr.next();
68       SVKey                        key = (SVKey)                        me.getKey();
69       HashSet<VariableSourceToken> s1  = (HashSet<VariableSourceToken>) me.getValue();      
70       assert s1 != null;
71       sv2vst.put( key, 
72                   (HashSet<VariableSourceToken>) (s1.clone()) );
73     }
74
75     assertConsistency();
76   }
77
78
79   public void add( VariableSourceToken vst ) {
80
81     // make sure we aren't clobbering anything!
82     assert !trueSet.contains( vst );
83
84     trueSet.add( vst );
85
86     Set<VariableSourceToken> s;
87
88     s = sese2vst.get( vst.getSESE() );
89     if( s == null ) {
90       s = new HashSet<VariableSourceToken>();
91     }
92     s.add( vst );
93     sese2vst.put( vst.getSESE(), s );
94
95     Iterator<TempDescriptor> refVarItr = vst.getRefVars().iterator();
96     while( refVarItr.hasNext() ) {
97       TempDescriptor refVar = refVarItr.next();
98       s = var2vst.get( refVar );
99       if( s == null ) {
100         s = new HashSet<VariableSourceToken>();
101       }
102       s.add( vst );
103       var2vst.put( refVar, s );
104
105       SVKey key = new SVKey( vst.getSESE(), refVar );
106       s = sv2vst.get( key );
107       if( s == null ) {
108         s = new HashSet<VariableSourceToken>();
109       }
110       s.add( vst );
111       sv2vst.put( key, s );
112     }
113
114     assertConsistency();
115   }
116
117   public void addAll( Set<VariableSourceToken> s ) {
118     Iterator<VariableSourceToken> itr = s.iterator();
119     while( itr.hasNext() ) {
120       add( itr.next() );
121     }
122   }
123
124
125   public Set<VariableSourceToken> get() {
126     return trueSet;
127   }
128
129   public Set<VariableSourceToken> get( FlatSESEEnterNode sese ) {
130     Set<VariableSourceToken> s = sese2vst.get( sese );
131     if( s == null ) {
132       s = new HashSet<VariableSourceToken>();      
133       sese2vst.put( sese, s );
134     }
135     return s;
136   }
137
138   public Set<VariableSourceToken> get( TempDescriptor var ) {
139     Set<VariableSourceToken> s = var2vst.get( var );
140     if( s == null ) {
141       s = new HashSet<VariableSourceToken>();
142       var2vst.put( var, s );
143     }
144     return s;
145   }
146
147   public Set<VariableSourceToken> get( FlatSESEEnterNode sese,
148                                        TempDescriptor refVar ) {
149     SVKey key = new SVKey( sese, refVar );
150     Set<VariableSourceToken> s = sv2vst.get( key );
151     if( s == null ) {
152       s = new HashSet<VariableSourceToken>();
153       sv2vst.put( key, s );
154     }
155     return s;
156   }
157
158   public Set<VariableSourceToken> get( FlatSESEEnterNode sese,
159                                        Integer age ) {
160     Set<VariableSourceToken> s = sese2vst.get( sese );
161     if( s == null ) {
162       s = new HashSet<VariableSourceToken>();      
163       sese2vst.put( sese, s );
164     }
165     Iterator<VariableSourceToken> sItr = s.iterator();
166     while( sItr.hasNext() ) {
167       VariableSourceToken vst = sItr.next();
168       if( !vst.getAge().equals( age ) ) {
169         s.remove( vst );
170       }
171     }
172     return s;
173   }
174
175
176   public void merge( VarSrcTokTable tableIn ) {
177
178     if( tableIn == null ) {
179       return;
180     }
181
182     // make a copy for modification to use in the merge
183     VarSrcTokTable table = new VarSrcTokTable( tableIn );
184
185
186     trueSet.addAll( table.trueSet );
187
188
189     Iterator itr; 
190
191     // merge sese2vst mappings
192     itr = this.sese2vst.entrySet().iterator();
193     while( itr.hasNext() ) {
194       Map.Entry                me   = (Map.Entry)                itr.next();
195       FlatSESEEnterNode        sese = (FlatSESEEnterNode)        me.getKey();
196       Set<VariableSourceToken> s1   = (Set<VariableSourceToken>) me.getValue();
197       Set<VariableSourceToken> s2   = table.sese2vst.get( sese );     
198       assert s1 != null;
199
200       if( s2 != null ) {
201         s1.addAll( s2 );
202       }
203     }
204     itr = table.sese2vst.entrySet().iterator();
205     while( itr.hasNext() ) {
206       Map.Entry                me   = (Map.Entry)                itr.next();
207       FlatSESEEnterNode        sese = (FlatSESEEnterNode)        me.getKey();
208       Set<VariableSourceToken> s2   = (Set<VariableSourceToken>) me.getValue();
209       Set<VariableSourceToken> s1   = this.sese2vst.get( sese );
210       assert s2 != null;
211
212       if( s1 == null ) {
213         this.sese2vst.put( sese, s2 );
214       }      
215     }
216
217     // merge var2vst mappings
218     itr = this.var2vst.entrySet().iterator();
219     while( itr.hasNext() ) {
220       Map.Entry                me  = (Map.Entry)                itr.next();
221       TempDescriptor           var = (TempDescriptor)           me.getKey();
222       Set<VariableSourceToken> s1  = (Set<VariableSourceToken>) me.getValue();
223       Set<VariableSourceToken> s2  = table.var2vst.get( var );      
224       assert s1 != null;
225
226       if( s2 != null ) {
227         s1.addAll( s2 );
228       }           
229     }
230     itr = table.var2vst.entrySet().iterator();
231     while( itr.hasNext() ) {
232       Map.Entry                me   = (Map.Entry)                itr.next();
233       TempDescriptor           var  = (TempDescriptor)           me.getKey();
234       Set<VariableSourceToken> s2   = (Set<VariableSourceToken>) me.getValue();
235       Set<VariableSourceToken> s1   = this.var2vst.get( var );
236       assert s2 != null;
237
238       if( s1 == null ) {
239         this.var2vst.put( var, s2 );
240       }      
241     }
242
243     // merge sv2vst mappings
244     itr = this.sv2vst.entrySet().iterator();
245     while( itr.hasNext() ) {
246       Map.Entry                me  = (Map.Entry)                itr.next();
247       SVKey                    key = (SVKey)                    me.getKey();
248       Set<VariableSourceToken> s1  = (Set<VariableSourceToken>) me.getValue();
249       Set<VariableSourceToken> s2  = table.sv2vst.get( key );      
250       assert s1 != null;
251
252       if( s2 != null ) {
253         s1.addAll( s2 );
254       }           
255     }
256     itr = table.sv2vst.entrySet().iterator();
257     while( itr.hasNext() ) {
258       Map.Entry                me   = (Map.Entry)                itr.next();
259       SVKey                    key  = (SVKey)                    me.getKey();
260       Set<VariableSourceToken> s2   = (Set<VariableSourceToken>) me.getValue();
261       Set<VariableSourceToken> s1   = this.sv2vst.get( key );
262       assert s2 != null;
263
264       if( s1 == null ) {
265         this.sv2vst.put( key, s2 );
266       }      
267     }
268
269     assertConsistency();
270   }
271
272
273   // remove operations must leave the trueSet 
274   // and the hash maps consistent!
275   public void remove( VariableSourceToken vst ) {
276     trueSet.remove( vst );
277     
278     Set<VariableSourceToken> s;
279
280     s = get( vst.getSESE() );
281     if( s != null ) { s.remove( vst ); }
282
283     Iterator<TempDescriptor> refVarItr = vst.getRefVars().iterator();
284     while( refVarItr.hasNext() ) {
285       TempDescriptor refVar = refVarItr.next();
286
287       s = get( refVar );
288       if( s != null ) { s.remove( vst ); }
289       
290       s = get( vst.getSESE(), refVar );
291       if( s != null ) { s.remove( vst ); }
292     }
293
294     assertConsistency();
295   }
296
297   public void remove( FlatSESEEnterNode sese ) {
298     Set<VariableSourceToken> s = sese2vst.get( sese );
299     if( s == null ) {
300       return;
301     }
302
303     Iterator<VariableSourceToken> itr = s.iterator();
304     while( itr.hasNext() ) {
305       VariableSourceToken vst = itr.next();
306       remove( vst );
307     }
308
309     sese2vst.remove( sese );
310
311     assertConsistency();
312   }
313
314   public void remove( TempDescriptor refVar ) {
315     Set<VariableSourceToken> s = var2vst.get( refVar );
316     if( s == null ) {
317       return;
318     }
319     
320     Set<VariableSourceToken> forRemoval = new HashSet<VariableSourceToken>();
321
322     // iterate over tokens that this temp can reference, make a set
323     // of tokens that need this temp stripped out of them
324     Iterator<VariableSourceToken> itr = s.iterator();
325     while( itr.hasNext() ) {
326       VariableSourceToken vst = itr.next();
327       Set<TempDescriptor> refVars = vst.getRefVars();
328       assert refVars.contains( refVar );
329       forRemoval.add( vst );
330     }
331
332     itr = forRemoval.iterator();
333     while( itr.hasNext() ) {
334       // here's a token marked for removal, take it out as it is
335       // in this state
336       VariableSourceToken vst = itr.next();
337       remove( vst );
338
339       // if there are other references to the token, alter the
340       // token and then readd it to this table, because it has
341       // a new hash value now
342       Set<TempDescriptor> refVars = vst.getRefVars();
343       refVars.remove( refVar );
344       if( refVars.size() > 0 ) {
345         add( vst );
346       }
347     }
348
349     //var2vst.remove( var );
350
351     assertConsistency();
352   }
353
354   public void remove( FlatSESEEnterNode sese,
355                       TempDescriptor    var  ) {
356
357     SVKey key = new SVKey( sese, var );
358     Set<VariableSourceToken> s = sv2vst.get( key );
359     if( s == null ) {
360       return;
361     }
362     
363     Iterator<VariableSourceToken> itr = s.iterator();
364     while( itr.hasNext() ) {
365       VariableSourceToken vst = itr.next();
366       remove( vst );
367     }
368
369     sv2vst.remove( key );
370
371     assertConsistency();
372   }
373
374
375
376   // return a new table based on this one and
377   // age tokens with respect to SESE curr, where
378   // any curr tokens increase age by 1
379   public VarSrcTokTable age( FlatSESEEnterNode curr ) {
380
381     // create a table to modify as a copy of this
382     VarSrcTokTable out = new VarSrcTokTable( this );
383
384     Iterator<VariableSourceToken> itr = trueSet.iterator();
385     while( itr.hasNext() ) {
386       VariableSourceToken vst = itr.next();
387
388       if( vst.getSESE().equals( curr ) ) {
389
390         Integer newAge = vst.getAge()+1;
391         if( newAge > MAX_AGE ) {
392           newAge = MAX_AGE;
393         }
394
395         out.remove( vst );
396
397         out.add( new VariableSourceToken( vst.getRefVars(), 
398                                           curr,                                           
399                                           newAge,
400                                           vst.getAddrVar()
401                                           )
402                  );
403       } 
404     }
405
406     out.assertConsistency();
407     return out;
408   }
409
410   
411   // for the given SESE, change child tokens into this parent
412   public void remapChildTokens( FlatSESEEnterNode curr ) {
413
414     Iterator<FlatSESEEnterNode> childItr = curr.getChildren().iterator();
415     if( childItr.hasNext() ) {
416       FlatSESEEnterNode child = childItr.next();
417       
418       Iterator<VariableSourceToken> vstItr = get( child ).iterator();
419       while( vstItr.hasNext() ) {
420         VariableSourceToken vst = vstItr.next();
421
422         remove( vst );
423
424         add( new VariableSourceToken( vst.getRefVars(),
425                                       curr,
426                                       new Integer( 0 ),
427                                       vst.getAddrVar()
428                                       )
429              );
430       }
431     }
432
433     assertConsistency();
434   }   
435
436
437   // if we can get a value from the current SESE and the parent
438   // or a sibling, just getting from the current SESE suffices now
439   // return a set of temps that are virtually read
440   public Set<TempDescriptor> removeParentAndSiblingTokens( FlatSESEEnterNode curr,
441                                                            Set<TempDescriptor> liveIn ) {
442
443     HashSet<TempDescriptor> virtualLiveIn = new HashSet<TempDescriptor>();
444
445     FlatSESEEnterNode parent = curr.getParent();
446     if( parent == null ) {
447       // have no parent or siblings
448       return virtualLiveIn;
449     }      
450
451     remove_A_if_B( parent, curr, liveIn, virtualLiveIn );
452
453     Iterator<FlatSESEEnterNode> childItr = parent.getChildren().iterator();
454     if( childItr.hasNext() ) {
455       FlatSESEEnterNode child = childItr.next();
456
457       if( !child.equals( curr ) ) {
458         remove_A_if_B( child, curr, liveIn, virtualLiveIn );
459       }
460     }
461     
462     assertConsistency();
463     return virtualLiveIn;
464   }
465   
466   // if B is also a source for some variable, remove all entries
467   // of A as a source for that variable: s is virtual reads
468   protected void remove_A_if_B( FlatSESEEnterNode a, 
469                                 FlatSESEEnterNode b,
470                                 Set<TempDescriptor> liveInCurrentSESE,
471                                 Set<TempDescriptor> virtualLiveIn ) {
472
473     Set<VariableSourceToken> forRemoval = new HashSet<VariableSourceToken>();
474
475     Iterator<VariableSourceToken> vstItr = get( a ).iterator();
476     while( vstItr.hasNext() ) {
477       VariableSourceToken      vst       = vstItr.next();
478       Iterator<TempDescriptor> refVarItr = vst.getRefVars().iterator();
479       while( refVarItr.hasNext() ) {
480         TempDescriptor           refVar = refVarItr.next();
481         Set<VariableSourceToken> bSet   = get( b, refVar );
482       
483         if( !bSet.isEmpty() ) {
484           forRemoval.add( vst );
485
486           // mark this variable as a virtual read as well
487           virtualLiveIn.add( refVar );
488         }
489       }
490     }
491
492     vstItr = forRemoval.iterator();
493     while( vstItr.hasNext() ) {
494       VariableSourceToken vst = vstItr.next();
495       remove( vst );
496     }
497   }
498
499
500   public Set<VariableSourceToken> getStallSet( FlatSESEEnterNode curr ) {
501
502     Set<VariableSourceToken> out = new HashSet<VariableSourceToken>();
503
504     Iterator<FlatSESEEnterNode> cItr = curr.getChildren().iterator();
505     while( cItr.hasNext() ) {
506       FlatSESEEnterNode child = cItr.next();
507       out.addAll( get( child ) );
508     }
509
510     return out;
511   }
512
513
514   // use as an aid for debugging, where true-set is checked
515   // against the alternate mappings: assert that nothing is
516   // missing or extra in the alternates
517   public void assertConsistency() {
518
519     Iterator itr; 
520     Set s;
521
522     Set<VariableSourceToken> trueSetByAlts = new HashSet<VariableSourceToken>();
523     itr = sese2vst.entrySet().iterator();
524     while( itr.hasNext() ) {
525       Map.Entry                    me   = (Map.Entry)                    itr.next();
526       FlatSESEEnterNode            sese = (FlatSESEEnterNode)            me.getKey();
527       HashSet<VariableSourceToken> s1   = (HashSet<VariableSourceToken>) me.getValue();      
528       assert s1 != null;
529       
530       // the trueSet should have all entries in s1
531       assert trueSet.containsAll( s1 );
532
533       // s1 should not have anything that doesn't appear in trueset
534       Set<VariableSourceToken> sInt = (Set<VariableSourceToken>) s1.clone();
535       sInt.removeAll( trueSet );
536
537       assert sInt.isEmpty();
538
539       // add s1 to a running union--at the end check if trueSet has extra
540       trueSetByAlts.addAll( s1 );
541     }
542     // make sure trueSet isn't too big
543     assert trueSetByAlts.containsAll( trueSet );
544
545
546     trueSetByAlts = new HashSet<VariableSourceToken>();
547     itr = var2vst.entrySet().iterator();
548     while( itr.hasNext() ) {
549       Map.Entry                    me   = (Map.Entry)                    itr.next();
550       TempDescriptor               var  = (TempDescriptor)               me.getKey();
551       HashSet<VariableSourceToken> s1   = (HashSet<VariableSourceToken>) me.getValue();      
552       assert s1 != null;
553       
554       // the trueSet should have all entries in s1
555       assert trueSet.containsAll( s1 );
556
557       // s1 should not have anything that doesn't appear in trueset
558       Set<VariableSourceToken> sInt = (Set<VariableSourceToken>) s1.clone();
559       sInt.removeAll( trueSet );
560
561       assert sInt.isEmpty();
562
563       // add s1 to a running union--at the end check if trueSet has extra
564       trueSetByAlts.addAll( s1 );
565     }
566     // make sure trueSet isn't too big
567     assert trueSetByAlts.containsAll( trueSet );
568
569
570     trueSetByAlts = new HashSet<VariableSourceToken>();
571     itr = sv2vst.entrySet().iterator();
572     while( itr.hasNext() ) {
573       Map.Entry                    me   = (Map.Entry)                    itr.next();
574       SVKey                        key  = (SVKey)                        me.getKey();
575       HashSet<VariableSourceToken> s1   = (HashSet<VariableSourceToken>) me.getValue();      
576       assert s1 != null;
577       
578       // the trueSet should have all entries in s1
579       assert trueSet.containsAll( s1 );
580
581       // s1 should not have anything that doesn't appear in trueset
582       Set<VariableSourceToken> sInt = (Set<VariableSourceToken>) s1.clone();
583       sInt.removeAll( trueSet );
584
585       assert sInt.isEmpty();
586
587       // add s1 to a running union--at the end check if trueSet has extra
588       trueSetByAlts.addAll( s1 );
589     }
590     // make sure trueSet isn't too big
591     assert trueSetByAlts.containsAll( trueSet );
592
593
594     // also check that the reference var sets are consistent
595     Hashtable<VariableSourceToken, Set<TempDescriptor> > vst2refVars =
596       new Hashtable<VariableSourceToken, Set<TempDescriptor> >();
597     itr = var2vst.entrySet().iterator();
598     while( itr.hasNext() ) {
599       Map.Entry                     me     = (Map.Entry)                    itr.next();
600       TempDescriptor                refVar = (TempDescriptor)               me.getKey();
601       HashSet<VariableSourceToken>  s1     = (HashSet<VariableSourceToken>) me.getValue();      
602       Iterator<VariableSourceToken> vstItr = s1.iterator();
603       while( vstItr.hasNext() ) {
604         VariableSourceToken vst = vstItr.next();
605         assert vst.getRefVars().contains( refVar );
606
607         Set<TempDescriptor> refVarsPart = vst2refVars.get( vst );
608         if( refVarsPart == null ) {
609           refVarsPart = new HashSet<TempDescriptor>();
610         }
611         refVarsPart.add( refVar );
612         vst2refVars.put( vst, refVarsPart );
613       }
614     }
615     itr = vst2refVars.entrySet().iterator();
616     while( itr.hasNext() ) {
617       Map.Entry           me  = (Map.Entry)           itr.next();
618       VariableSourceToken vst = (VariableSourceToken) me.getKey();
619       Set<TempDescriptor> s1  = (Set<TempDescriptor>) me.getValue();
620       assert vst.getRefVars().equals( s1 );
621     }    
622   }
623
624
625   public boolean equals( Object o ) {
626     if( o == null ) {
627       return false;
628     }
629
630     if( !(o instanceof VarSrcTokTable) ) {
631       return false;
632     }
633
634     VarSrcTokTable table = (VarSrcTokTable) o;
635     return trueSet.equals( table.trueSet );
636   }
637
638   public int hashCode() {
639     return trueSet.hashCode();
640   }
641
642   public Iterator<VariableSourceToken> iterator() {
643     return trueSet.iterator();
644   }
645
646   public String toString() {
647     return "trueSet ="+trueSet.toString();
648   }
649
650   public String toStringVerbose() {
651     return "trueSet ="+trueSet.toString()+"\n"+
652            "sese2vst="+sese2vst.toString()+"\n"+
653            "var2vst ="+var2vst.toString()+"\n"+
654            "sv2vst  ="+sv2vst.toString();
655   }
656
657   public String toStringPretty() {
658     String tokHighlighter = "o";
659
660     String str = "VarSrcTokTable\n";
661     Iterator<VariableSourceToken> vstItr = trueSet.iterator();    
662     while( vstItr.hasNext() ) {
663       str += "   "+tokHighlighter+" "+vstItr.next()+"\n";
664     }
665     return str;
666   }
667
668   public String toStringPrettyVerbose() {
669     String tokHighlighter = "o";
670
671     String str = "VarSrcTokTable\n";
672
673     Set s;
674     Iterator itr; 
675     Iterator<VariableSourceToken> vstItr;
676
677     str += "  trueSet\n";
678     vstItr = trueSet.iterator();    
679     while( vstItr.hasNext() ) {
680       str += "     "+tokHighlighter+" "+vstItr.next()+"\n";
681     }
682
683     str += "  sese2vst\n";
684     itr = sese2vst.entrySet().iterator();
685     while( itr.hasNext() ) {
686       Map.Entry                    me   = (Map.Entry)                    itr.next();
687       FlatSESEEnterNode            sese = (FlatSESEEnterNode)            me.getKey();
688       HashSet<VariableSourceToken> s1   = (HashSet<VariableSourceToken>) me.getValue();      
689       assert s1 != null;
690
691       str += "    "+sese.getPrettyIdentifier()+" -> \n";
692
693       vstItr = s1.iterator();
694       while( vstItr.hasNext() ) {
695         str += "       "+tokHighlighter+" "+vstItr.next()+"\n";
696       }
697     }
698
699     str += "  var2vst\n";
700     itr = var2vst.entrySet().iterator();
701     while( itr.hasNext() ) {
702       Map.Entry                me  = (Map.Entry)                itr.next();
703       TempDescriptor           var = (TempDescriptor)           me.getKey();
704       Set<VariableSourceToken> s1  = (Set<VariableSourceToken>) me.getValue();
705       assert s1 != null;
706
707       str += "    "+var+" -> \n";
708
709       vstItr = s1.iterator();
710       while( vstItr.hasNext() ) {
711         str += "       "+tokHighlighter+" "+vstItr.next()+"\n";
712       }
713     }
714
715     str += "  sv2vst\n";
716     itr = sv2vst.entrySet().iterator();
717     while( itr.hasNext() ) {
718       Map.Entry                me  = (Map.Entry)                itr.next();
719       SVKey                    key = (SVKey)                    me.getKey();
720       Set<VariableSourceToken> s1  = (Set<VariableSourceToken>) me.getValue();
721       assert s1 != null;
722
723       str += "    "+key+" -> \n";
724
725       vstItr = s1.iterator();
726       while( vstItr.hasNext() ) {
727         str += "       "+tokHighlighter+" "+vstItr.next()+"\n";
728       }
729     }
730
731     return str;
732   }
733 }