1 package net.obsearch.example.ted;
2
3 import java.util.BitSet;
4
5 import net.obsearch.index.utils.IntegerHolder;
6
7 import antlr.collections.AST;
8
9
10
11
12
13
14 public class SliceASTIds extends SliceAST {
15
16 private int id = -1;
17 private BitSet contains;
18
19
20 public BitSet containedNodes(){
21 assert contains != null;
22 return contains;
23 }
24
25 public void updateContains(){
26 if (contains == null){
27 this.updateIdInfo();
28 updateContainsAux(null);
29 }
30 }
31
32 public boolean containsNode(int i){
33 assert contains != null;
34 return this.contains.get(i);
35 }
36
37 protected void updateContainsAux(BitSet parent){
38 SliceASTIds n = (SliceASTIds)this.getLeftmostChild();
39 BitSet me = new BitSet();
40 while(n != null){
41 me.set(n.getId());
42 n.updateContainsAux(me);
43 n = (SliceASTIds)n.getNextSibling();
44 }
45 this.contains = me;
46 if(parent != null){
47 parent.or(me);
48 }
49 }
50
51
52
53 public int getId(){
54 assert id != -1;
55 return id;
56 }
57
58 public void updateIdInfo(){
59 updateIdInfoAux(new IntegerHolder(0));
60 }
61
62 public void updateIdInfoAux(IntegerHolder i){
63 this.id = i.getValue();
64 SliceASTIds n = (SliceASTIds)this.getLeftmostChild();
65 while(n != null){
66 i.inc();
67 n.updateIdInfoAux(i);
68 n = (SliceASTIds)n.getNextSibling();
69 }
70 }
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 }