aa
Bits.java
Go to the documentation of this file.
1 package com.cliffc.aa.type;
2 
3 import com.cliffc.aa.util.SB;
4 import com.cliffc.aa.util.IBitSet;
5 import com.cliffc.aa.util.VBitSet;
6 import org.jetbrains.annotations.NotNull;
7 
8 import java.util.Arrays;
9 import java.util.Iterator;
10 
11 // Bits supporting a lattice; immutable; hash-cons'd. Bits can be *split* in
12 // twain, basically a single Bit is really set of all possible future splits.
13 //
14 // Splitting is useful during inlining, where a single Call is duplicated and
15 // RPCs to the original one might return to either of of the inlines. Same for
16 // internal functions and allocation sites - after the inline, pointers and
17 // references to the original might now refer to either copy. Each copy only
18 // refers to itself, so after some optimizations the ambiguious bits can be
19 // optimized away. i.e., its useful to make the distinction between the cloned
20 // instances, just might be some confusion at first.
21 //
22 // Splitting induces a tree-structure to the bits; there is a parent / child
23 // relationship defined in the inner Tree class, and used in meet calls.
24 //
25 // Bit 0 - is always the 'null' or 'empty' instance.
26 // Bit 1 - is the first "real" bit, and represents all-of-a-class.
27 // Other bits always split from bit 1, and can split in any pattern.
28 //
29 // Individual bits are never constants (due to possible future splits), and
30 // instead are a class of things that are either meet'd or join'd (above or
31 // below the centerline). Aliases are usually classes because a single NewNode
32 // can be executed in a loop, producing many objects with the same alias#.
33 // FIDXs and RPCs would be constants, as there is a single instance of a
34 // function or a return-point, except for code-cloning (i.e. inlining).
35 //
36 // The tree-structure really defines a basic set-inclusion property which is
37 // trivially a lattice; see https://en.wikipedia.org/wiki/Lattice_(order)
38 // pic#1. However to get a lattice AND a dual we MUST have the empty element
39 // in the middle. The meet of -2 and -5 is... [], the empty set, and NOT
40 // [2&5]. See TestLattice#10 for a failure test case. Adding a dual lattice
41 // without the empty-set also fails, see TestLattice#11.
42 
43 // TODO: Ponder a Plan B: No sets-of-siblings allowed. Instead meet of
44 // siblings goes straight to the tree LCA. This means we only ever have 1 bit
45 // set and Bits become a simple number (not an array of bits). This means
46 // the meet of two high siblings is the low parent, and not the empty set.
47 
48 // TODO: Ponder a Plan B: Meet of 2 unrelated FIDXS goes immediately to the
49 // Most General FIDX, which defeats the Call-Graph discovery. Related FIDXS
50 // from e.g. FunNode split work great. But a "map" style call taking any
51 // generic function will immediately get several top-level FIDXS which will
52 // immediately force the Most General FIDX for the map's function argument.
53 //
54 // TODO: FIDXS which can be Unresolved probably need to be under the same
55 // parent (as opposed to the meet of 2 unrelated FIDXS going immediately to the
56 // Most General FIDX).
57 //
58 // TODO: Ponder a Plan C: Bits are independent, always 'MEET', always all-up or
59 // all-down. Meet of [-2] and [-5] is [-2,-5]???
60 
61 public abstract class Bits<B extends Bits<B>> implements Iterable<Integer> {
62  // Holds a set of bits meet'd together, or join'd together, along
63  // with a single bit choice.
64  // If _bits is NULL and _con is 0, this is the EMPTY state.
65  // If _bits is NULL, then _con is a single bit and is +/- for meet/join.
66  // If _bits is not-null, then _con is +1 for meet, and -1 for join.
67  // The NIL bit has both meet & join flavors, required for a lattice.
68  long[] _bits; // Bits set or null for a single bit
69  int _con; // value of single bit
70  int _hash; // Pre-computed hashcode
71  // Intern: lookup and return an existing Bits or install in hashmap and
72  // return a new Bits. Overridden in subclasses to make type-specific Bits.
73  abstract B make_impl(int con, long[] bits );
74  abstract Tree<B> tree();
75  public abstract B ALL();
76  public abstract B ANY();
77  public abstract B EMPTY();
78 
79  // Common init
80  void init(int con, long[] bits ) {
81  _con = con;
82  _bits=bits;
83  long sum=_con;
84  if( _bits != null ) for( long l : _bits ) sum += l;
85  _hash = (int)((sum>>32)+sum);
86  if( _hash==0 ) _hash=1;
87  assert check();
88  }
89  private boolean check() {
90  if( _bits==null ) return true; // Must be a single bit#
91  if( _con != 1 && _con != -1 ) return false;
92  if( _bits.length==0 ) return false; // Empty bits replaced by a con
93  if( _bits.length==1 && _bits[0]== 0 ) return false; // NO bits is bad, use EMPTY instead
94  if( _bits[_bits.length-1]==0 ) return false; // Array is "tight"
95  if( _bits.length==1 && _bits[0]==1 ) return true; // NIL
96  // No set bit has a parent bit set, because the parent overrides
97  Tree<B> tree = tree();
98  for( int i : this )
99  while( (i = tree.parent(i)) != 0 )
100  if( test(i) )
101  return false;
102  // For efficiency, 1 bit set uses 'con' instead of 'bits'
103  return check_multi_bits(_bits); // Found multiple bits
104  }
105  private static boolean check_multi_bits( long[] bits) {
106  int len = bits.length;
107  long b = bits[len-1]; // Last word
108  if( (b & (b-1))!=0 ) return true; // Last word has multiple bits
109  // Check multiple bits spread over multiple words
110  for( int i=0; i<len-1; i++ ) if( bits[i] != 0 ) return true;
111  return false; // Found a single bit in last word
112  }
113  public int bitCount() {
114  if( _bits==null ) return _con==0 ? 0 : 1;
115  int sum=0;
116  for( long b : _bits )
117  sum += Long.bitCount(b);
118  return sum;
119  }
120  @Override public int hashCode( ) { return _hash; }
121  @Override public boolean equals( Object o ) {
122  if( this==o ) return true;
123  if( !(o instanceof Bits) ) return false;
124  Bits bs = (Bits)o;
125  if( _con != bs._con || _hash != bs._hash ) return false;
126  if( _bits == bs._bits ) return true;
127  if( _bits ==null || bs._bits==null ) return false;
128  if( _bits.length != bs._bits.length ) return false;
129  for( int i=0; i<_bits.length; i++ )
130  if( _bits[i]!=bs._bits[i] ) return false;
131  return true;
132  }
133  @Override public String toString() { return str(new SB()).toString(); }
134  public SB str(SB sb) {
135  if( _bits==null ) {
136  if( _con== 0 ) return sb.p("[]"); // EMPTY
137  if( _con== 1 ) return sb.p("[ALL]");
138  if( _con==-1 ) return sb.p("[ANY]");
139  return sb.p('[').p(_con).p(']');
140  }
141  sb.p('[');
142  if( above_center() ) sb.p('~');
143  char sep = above_center()?'+':',';
144  if( test(_bits,1) ) {
145  if( test(_bits,0) ) sb.p('0').p(sep);
146  return sb.p(above_center() ? "ANY]" : "ALL]");
147  }
148  for( Integer idx : this ) sb.p(idx).p(sep);
149  return sb.unchar().p(']');
150  }
151 
152  // Constructor taking an array of bits, and allowing join/meet selection.
153  // Canonicalizes the bits. The 'this' pointer is only used to clone the class.
154  private B make( boolean any, long[] bits ) {
155  // If a 'parent' bit is set, then no need to have any child bits set.
156  Tree<B> tree = tree();
157  // TODO: Run this loop backwards, avoids most tree-walks; lowers O(n log n) to O(n).
158  for( int i=0; i<bits.length; i++ ) { // For all words
159  long l = bits[i];
160  if( l!=0 ) {
161  for( int j=0; j<64; j++ ) // For all bits in word
162  if( (mask(j)&l) != 0 ) {
163  int par = (i<<6)+j; // Kid index
164  while( (par = tree.parent(par)) != 0 ) // Walk parent chain
165  if( test(bits,par) ) // If parent set
166  { bits[i]&=~mask(j); break; } // then clear kid
167  }
168  }
169  }
170 
171  // Remove any trailing empty words
172  int len = bits.length;
173  while( len > 1 && bits[len-1]==0 ) len--;
174  if( bits.length != len ) bits = Arrays.copyOf(bits,len);
175 
176  // Check for a single bit or NO bits
177  if( check_multi_bits(bits) ) return make_impl(any ? -1 : 1,bits);
178  // Special check for +/-0
179  if( len==1 && bits[0]==1 ) return make_impl(any ? -1 : 1,bits);
180  // Empty is self-dual, ignores 'any'
181  if( len==1 && bits[0]==0 ) return make_impl(0,null);
182  // Single bit
183  int bnum0 = 63 - Long.numberOfLeadingZeros(bits[len-1]);
184  int bnum = bnum0 + ((len-1)<<6);
185  if( any ) bnum = -bnum;
186  return make_impl(bnum,null);
187  }
188  // Constructor taking a single bit
189  final B make( int bit ) { return bit==0 ? make_impl(1,new long[]{1}) : make_impl(bit,null); }
190  // Constructor taking an array of bits
191  public final B make( int... bits ) {
192  int max= 0; // Find max bit
193  for( int bit : bits ) max=Math.max(max,bit);
194  long[] ls = bits(max); // Big enuf bits
195  for( int bit : bits ) or(ls,bit);
196  return make(false,ls);
197  }
198 
199  private static int idx (long i) { return (int)(i>>6); }
200  private static long mask(long i) { return 1L<<(i&63); }
201 
202  public int getbit() { assert _bits==null && _con!=0; return _con; }
203  public int abit() { return _bits==null&&_con!=0 ? _con : -1; }
204  public boolean above_center() { return _con<0; }
205  // Only empty and nil. Other bits represent sets (possibly unsplit).
206  public boolean is_con() { return is_nil() || is_empty(); }
207  public boolean is_empty() { return _bits==null && _con==0; }
208  public boolean is_nil() { return _bits!=null && _bits.length==1 && _bits[0]==1; }
209  boolean may_nil() { return _con==-1 && _bits != null && ((_bits[0]&1) == 1); }
210  // Add a low nil.
211  @SuppressWarnings("unchecked")
212  public B meet_nil() {
213  if( above_center() ) return make(0); // Crossing centerline, drop all above bits, just [0]
214  if( test(0) ) return (B)this;// Already has nil
215  long[] bs = _bits;
216  if( bs==null ) // Is a single compressed bit
217  or(bs = bits(Math.abs(_con)),Math.abs(_con)); // Decompress single bit into array
218  else bs = _bits.clone(); // Make a private set
219  bs[0] |= 1; // Set nil
220  return make(false,bs); // Its below center now, even if the original was above
221  }
222 
223  // Test a specific bit is set or clear on a given bits
224  private static boolean test(long[] bits, int i) { return idx(i) < bits.length && (bits[idx(i)]&mask(i))!=0; }
225  // Test a specific bit is set or clear on this Bits
226  public boolean test(int i) {
227  if( _bits==null ) return i!=0 && i==Math.abs(_con);
228  int idx = idx(i);
229  return idx < _bits.length && test(_bits, i);
230  }
231  // Test if this bit, or any parent of this bit, is set
232  public boolean test_recur( int i ) {
233  if( test(i) ) return true;
234  Tree<B> tree = tree();
235  while( (i = tree.parent(i)) != 0 )
236  if( test(i) )
237  return true;
238  return false;
239  }
240 
241  // Return the type without a nil-choice. Only applies to above_center types,
242  // as these are the only types with a nil-choice. Only called during meets
243  // with above-center types. If called with below-center, there is no
244  // nil-choice (might be a must-nil but not a choice-nil), so can return this.
245  @SuppressWarnings("unchecked")
246  B not_nil() {
247  if( !above_center() || _bits == null ) return (B)this; // Some constant not-nil
248  if( !test(_bits,0) ) return (B)this; // No nil choice
249  long[] bs = _bits.clone(); // Keep all other bits
250  and(bs,0); // remove nil choice
251  return make(true,bs); // Choices without nil
252  }
253  // Remove the named bit, but otherwise preserve the type
254  @SuppressWarnings("unchecked")
255  public B clear(int bit) {
256  if( !test(bit) ) return (B)this;
257  if( _bits == null ) return EMPTY();
258  long[] bs = _bits.clone();
259  and(bs,bit);
260  return make(_con==-1,bs);
261  }
262  // Add the named bit, but otherwise preserve the type
263  @SuppressWarnings("unchecked")
264  public B set(int bit) {
265  if( test(bit) ) return (B)this;
266  B b = make(bit);
267  if( this == EMPTY() ) return b;
268  return meet(b);
269  }
270 
271  // Remove the nil bit, but otherwise preserve the type
272  @SuppressWarnings("unchecked")
273  public B strip_nil() {
274  if( _bits == null ) return (B)this; // Should not be a nil to remove
275  if( (_bits[0] &1)==0 ) return (B) this; // No nil
276  long[] bs = _bits.clone();
277  bs[0] &= ~1; // Strip nil
278  return make(_con==-1,bs);
279  }
280 
281  private static void or ( long[] bits, long con ) { bits[idx(con)] |= mask(con); }
282  private static void and( long[] bits, long con ) { bits[idx(con)] &= ~mask(con); }
283  private static long[] bits( int b ) { return new long[idx(b)+1]; }
284  public int max( ) {
285  return _bits==null ? Math.abs(_con) : (63 - Long.numberOfLeadingZeros(_bits[_bits.length-1]))+((_bits.length-1)<<6);
286  }
287 
288  // Meet is more complex than the obvious AND/OR over bits. There's a bit of
289  // prefix logic to remove common cases (meet with ANY/ALL/NIL), and a final
290  // expanding into a large bit array. After that we need to honor the tree
291  // semantics; any set bits automatically include all their children as well.
292  //
293  // AS-IF: For any given set-bit, we "unpack" it setting every child bit. We
294  // then do the proper AND/OR operation on the bits, followed by a repack.
295  //
296 
297  @SuppressWarnings("unchecked")
298  public B meet( final B bs ) {
299  if( this==bs ) return (B)this;
300  B full = ALL(); // Subclass-specific version of full
301  if( this==full || bs==full ) return full;
302  B any = ANY(); // Subclass-specific version of any
303  if( this==any ) return bs;
304  if( bs ==any ) return (B)this;
305  // Empty is a little odd; similar to meeting two JOIN sets with nothing in
306  // common - it is on the center, and forces above values to fall, and
307  // itself falls to below values.
308  if( is_empty() ) return bs.above_center() ? (B)this : bs;
309  if( bs.is_empty() ) return above_center() ? bs : (B)this;
310 
311  long[] bits0 = _bits, bits1 = bs._bits;
312  int con0 = Math.abs(_con), con1 = Math.abs(bs._con);
313 
314  // Expand any single bits
315  if( bits0==null ) or(bits0=bits(con0), con0);
316  if( bits1==null ) or(bits1=bits(con1), con1);
317  con0 = _con < 0 ? -1 : 1;
318  con1 = bs._con < 0 ? -1 : 1;
319 
320  // Bigger in bits0
321  if( bits0.length < bits1.length ) { long[] tmp=bits0; bits0=bits1; bits1=tmp; int t=con0; con0=con1; con1=t; }
322  // Both meets? Set-union
323  if( con0 == 1 && con1 == 1 ) {
324  long[] bits = bits0.clone(); // Clone larger
325  for( int i=0; i<bits1.length; i++ ) // OR in smaller bits
326  bits[i] |= bits1[i];
327  return make(false,bits); // This will remove parent/child dups
328  }
329 
330  // Both joins? Set-intersection
331  Tree<B> tree = tree();
332  if( con0 == -1 && con1 == -1 ) {
333  long[] bits = new long[bits0.length];// Result array
334  join(tree,bits0,bits1,bits); // Merge left into right
335  join(tree,bits1,bits0,bits); // Merge right into left
336  // Nil is not part of the parent tree, so needs to be set explicitly
337  if( (bits0[0]&1)==1 && (bits1[0]&1)==1 ) bits[0]|=1;
338  // Just the intersection, which may be empty.
339  return make(true,bits);
340  }
341 
342  // Mixed meet/join. Toss away the join, keep only the meet bits.
343  return above_center() ? bs : (B)this;
344  }
345 
346  // Virtually expand all bits in both arrays to cover all children,
347  // then AND the bits, then re-pack. However, we do it tree-by-tree
348  // to keep from doing the full expansion costs.
349  private static void join( Tree tree, long[] bits0, long[] bits1, long[] bits2 ) {
350  // If a 'parent' bit is set, then no need to have any child bits set.
351  for( int i=0; i<bits0.length; i++ ) { // For all words
352  long l = bits0[i];
353  if( l!=0 ) {
354  // TODO: Use Long.numberOfTrailingZeros (or LeadingZeros probably) to
355  // do this only once-per-set-bit.
356  for( int j=0; j<64; j++ ) // For all bits in word
357  if( (mask(j)&l) != 0 ) {
358  for( int par = (i<<6)+j; par!=0; par = tree.parent(par) ) // Walk parent chain
359  if( test(bits1,par) ) // If parent set
360  { bits2[i]|=mask(j); break; } // then set kid
361  }
362  }
363  }
364  }
365 
366  // Constants are self-dual; classes just flip the meet/join bit.
367  @SuppressWarnings("unchecked")
368  public B dual() { return make_impl(-_con,_bits); }
369  // join is defined in terms of meet and dual
370  public Bits<B> join(Bits<B> bs) { return dual().meet(bs.dual()).dual(); }
371  // Note no special nil handling; both sides need to either handle nil or not
372  public boolean isa(B bs) { return meet(bs) == bs; }
373 
374  public Bits<B> subtract(Bits<B> bs) {
375  Bits<B> bs0 = this;
376  for( int alias : this )
377  for( int kid=alias; kid!=0; kid = tree().next_kid(alias,kid) )
378  if( bs.test_recur(kid) )
379  bs0 = bs0.clear(kid);
380  return bs0;
381  }
382  public boolean overlaps(Bits<B> bs) {
383  for( int alias : this )
384  for( int kid=alias; kid!=0; kid = tree().next_kid(alias,kid) )
385  if( bs.test_recur(kid) )
386  return true;
387  return false;
388  }
389 
390  // No kids
391  public IBitSet bitset() {
392  IBitSet bs = new IBitSet();
393  for( int alias : this )
394  bs.set(alias);
395  return bs;
396  }
397  public TypeObj oob(TypeObj t) { return above_center() ? (TypeObj)t.dual() : t; }
398 
399  // Bits are split in a tree like pattern, recorded here. To avoid rehashing,
400  // the exact same tree-split is handed out between tests. Basically there is
401  // only 1 tree shape, lazily discovered, for all tests.
402  public static class Tree<B extends Bits<B>> {
403  int _cnt = 1; // Next available bit number
404  // Invariants: _pars[kid]==parent && _kids[parent].contains(kid)
405  int[] _pars = new int[2]; // Parent bit from child bit; _cnt is the in-use part
406  int[][] _kids = new int[2][];// List of kids from a parent; 1st element is in-use length
407  int[] _init; // Used to reset _kids[X][0] for all X
408 
409  int parent( int kid ) { return _pars[kid]; }
410  public boolean is_parent( int idx ) { return idx<_kids.length && _kids[idx]!=null &&_kids[idx][0]>1; }
411  // Return two kids at slots ary[1] and ary[2].
412  public int[] get_kids( int par ) { assert _kids[par][0]==3; return _kids[par]; }
413  // True if kid is a child or equal to parent
414  boolean is_parent( int par, int kid ) {
415  for( ; par <= kid; kid = parent(kid) )
416  if( par==kid ) return true;
417  return false; // Kid will be a larger number
418  }
419 
420  @Override public String toString() { return toString(new SB(),1).toString(); }
421  private SB toString(SB sb,int i) {
422  sb.i().p(i).nl();
423  if( is_parent(i) ) {
424  sb.ii(1);
425  for( int j=1; j<_kids[i][0]; j++ )
426  toString(sb,_kids[i][j]);
427  sb.di(1);
428  }
429  return sb;
430  }
431 
432  // Split out a bit to form a new constant, from a prior a bit
433  int split(int par) {
434  // See if we have an existing bit
435  if( par < _kids.length ) { // This parent has kids already
436  int[] kids = _kids[par]; //
437  if( kids != null ) {
438  int klen = kids[0]; // Number of kids already, 1-based
439  if( klen < kids.length ) { // Room for more in array?
440  int bit = kids[klen];
441  if( bit != 0 ) { // Pre-allocated kid from prior test?
442  assert _pars[bit] == par; // Then parent must already be preallocated
443  kids[0] = klen+1;
444  return bit;
445  }
446  }
447  }
448  }
449  // Need a new bit
450  int bit = _cnt++; // Next available bit number
451 
452  // Make space in the parents array to hold the parent of 'bit'
453  while( bit >= _pars.length ) _pars = Arrays.copyOf(_pars,_pars.length<<1);
454  assert _pars[bit]==0;
455  _pars[bit] = par;
456  // Make space in the kids array to hold the children of 'par'
457  while( par >= _kids.length ) _kids = Arrays.copyOf(_kids,_kids.length<<1);
458  int[] kids = _kids[par]; // All the children of 'par'
459  if( kids==null ) _kids[par] = kids = new int[]{1};
460  int klen = kids[0]; // 1-based number of children. '1' means 'no children'
461  if( klen == kids.length ) // Make space as needed
462  _kids[par] = kids = Arrays.copyOf(kids,klen<<1);
463  kids[klen] = bit; // Insert new child of parent
464  kids[0] = klen+1; // Bump count of children
465  return bit;
466  }
467 
468  // Record all starting types tree relationships.
469  void init0() {
470  _init = new int[_kids.length];
471  for( int i=0; i<_kids.length; i++ )
472  _init[i] = _kids[i]==null ? 1 : _kids[i][0];
473  }
474  // Chop back alias tree to only those types recorded during 'init0'
475  void reset_to_init0() {
476  for( int i=0; i<_kids.length; i++ )
477  if( _kids[i] != null )
478  _kids[i][0] = i<_init.length ? _init[i] : 1;
479  }
480  int peek() { return _kids[1][_kids[1][0]]; } // for testing
481  // Smear out the kids in a non-canonical representation, to allow the caller
482  // to iterate more easily.
484  VBitSet bs = new VBitSet();
485  for( int i : bits )
486  if( i != 0 )
487  _plus_kids(bs,i);
488  return bs;
489  }
490  void _plus_kids(VBitSet bs, int i) {
491  bs.set(i);
492  int nkids = i >= _kids.length || _kids[i]==null ? 0 : _kids[i][0];
493  for( int kid=1; kid<nkids; kid++ )
494  _plus_kids(bs,_kids[i][kid]);
495  }
496 
497  // Return next child of alias; repeated calls iterate over all the children
498  // of alias including itself. When out of children returns 0. Usage:
499  // for( int kid=alias; kid!=0; kid=BitsAlias.next_kid(alias,kid) ) {...kid... }
500  public int next_kid( int alias, int kid ) {
501  if( kid==0 ) return 0;
502  boolean is_par = is_parent(kid);
503  if( kid==alias && !is_par ) return 0; // Singleton bit
504  // Find kid in the alias-tree
505  if( is_par ) { // Go deeper
506  return _kids[kid][1]; // First child one layer deeper
507  } else { // Leaf, unwind & find sibling
508  while(kid!=alias) {
509  int par = _pars[kid]; // Parent
510  int[] kids = _kids[par]; // All the parents' children
511  for( int i=1; i<kids[0]-1; i++ )
512  if( kids[i]==kid )
513  return kids[i+1]; // Return sibling
514  kid=par; // Up-parent & go again
515  }
516  return 0; // Last child visited
517  }
518  }
519 
520  }
521 
523  @NotNull @Override public Iterator<Integer> iterator() { return new Iter(); }
524  private class Iter implements Iterator<Integer> {
525  int _i=-1;
526  @Override public boolean hasNext() {
527  if( _bits==null )
528  if( _i==-1 ) { _i=0; return true; } else return false;
529  int idx;
530  while( (idx=idx(++_i)) < _bits.length )
531  if( (_bits[idx]&mask(_i)) != 0 )
532  return true;
533  return false;
534  }
535  @Override public Integer next() {
536  if( _bits==null ) return Math.abs(_con);
537  if( idx(_i) < _bits.length ) return _i;
538  throw new java.util.NoSuchElementException();
539  }
540  }
541 }
com.cliffc.aa.type.Bits.bits
static long[] bits(int b)
Definition: Bits.java:283
com.cliffc.aa.type.Bits.dual
B dual()
Definition: Bits.java:368
com.cliffc.aa.type.Bits.ANY
abstract B ANY()
com.cliffc.aa.type.Bits.str
SB str(SB sb)
Definition: Bits.java:134
com.cliffc.aa.type.Bits.Tree.peek
int peek()
Definition: Bits.java:480
com.cliffc.aa.type.Bits.join
Bits< B > join(Bits< B > bs)
Definition: Bits.java:370
com.cliffc.aa.type.Bits.equals
boolean equals(Object o)
Definition: Bits.java:121
com.cliffc.aa.type.Bits.clear
B clear(int bit)
Definition: Bits.java:255
com.cliffc.aa.util.SB.ii
SB ii(int i)
Definition: SB.java:44
com.cliffc.aa.type.Bits.check
boolean check()
Definition: Bits.java:89
com.cliffc
com.cliffc.aa.util.SB.di
SB di(int i)
Definition: SB.java:46
com.cliffc.aa.type.Bits.make
B make(boolean any, long[] bits)
Definition: Bits.java:154
com.cliffc.aa.util
Definition: AbstractEntry.java:1
com.cliffc.aa.type.Bits.Tree.toString
SB toString(SB sb, int i)
Definition: Bits.java:421
com.cliffc.aa.type.Bits.mask
static long mask(long i)
Definition: Bits.java:200
com.cliffc.aa.type.Bits.Tree.toString
String toString()
Definition: Bits.java:420
com.cliffc.aa.type.Bits.Tree.is_parent
boolean is_parent(int par, int kid)
Definition: Bits.java:414
com.cliffc.aa.type.Bits.Tree.is_parent
boolean is_parent(int idx)
Definition: Bits.java:410
com.cliffc.aa.util.IBitSet
Definition: IBitSet.java:10
com.cliffc.aa.type.Bits.Tree
Definition: Bits.java:402
com.cliffc.aa.type.Bits.test_recur
boolean test_recur(int i)
Definition: Bits.java:232
com.cliffc.aa.type.Bits.test
static boolean test(long[] bits, int i)
Definition: Bits.java:224
com.cliffc.aa.type.Bits.Tree.parent
int parent(int kid)
Definition: Bits.java:409
com.cliffc.aa.util.SB.unchar
SB unchar()
Definition: SB.java:58
Iterable
com.cliffc.aa.type.Bits.may_nil
boolean may_nil()
Definition: Bits.java:209
com.cliffc.aa.type.Bits.check_multi_bits
static boolean check_multi_bits(long[] bits)
Definition: Bits.java:105
com.cliffc.aa.type.Bits.above_center
boolean above_center()
Definition: Bits.java:204
com.cliffc.aa.type.Bits._bits
long[] _bits
Definition: Bits.java:68
com.cliffc.aa.type.TypeObj
Definition: TypeObj.java:15
com.cliffc.aa.type.Bits.Tree._init
int[] _init
Definition: Bits.java:407
com.cliffc.aa.type.Bits.overlaps
boolean overlaps(Bits< B > bs)
Definition: Bits.java:382
com.cliffc.aa.type.Bits.join
static void join(Tree tree, long[] bits0, long[] bits1, long[] bits2)
Definition: Bits.java:349
com.cliffc.aa.type.Bits.Tree.plus_kids
VBitSet plus_kids(Bits< B > bits)
Definition: Bits.java:483
com.cliffc.aa.type.Bits.init
void init(int con, long[] bits)
Definition: Bits.java:80
com.cliffc.aa.type.Bits._hash
int _hash
Definition: Bits.java:70
com.cliffc.aa.type.Bits.Tree._cnt
int _cnt
Definition: Bits.java:403
com.cliffc.aa.type.Bits.hashCode
int hashCode()
Definition: Bits.java:120
com.cliffc.aa.type.Bits._con
int _con
Definition: Bits.java:69
com.cliffc.aa.type.Bits.idx
static int idx(long i)
Definition: Bits.java:199
com.cliffc.aa.type.Bits.Iter.hasNext
boolean hasNext()
Definition: Bits.java:526
com.cliffc.aa.type.Bits.meet_nil
B meet_nil()
Definition: Bits.java:212
com.cliffc.aa.type.Bits.test
boolean test(int i)
Definition: Bits.java:226
com.cliffc.aa.type.Bits
Definition: Bits.java:61
com.cliffc.aa.type.Bits.Tree.get_kids
int[] get_kids(int par)
Definition: Bits.java:412
com.cliffc.aa.type.Bits.getbit
int getbit()
Definition: Bits.java:202
com.cliffc.aa.type.Bits.Tree._kids
int[][] _kids
Definition: Bits.java:406
com.cliffc.aa.util.VBitSet
Definition: VBitSet.java:5
com.cliffc.aa.type.Bits.iterator
Iterator< Integer > iterator()
Definition: Bits.java:523
com.cliffc.aa.type.Bits.bitset
IBitSet bitset()
Definition: Bits.java:391
com.cliffc.aa.util.SB
Tight/tiny StringBuilder wrapper.
Definition: SB.java:8
com.cliffc.aa.type.Bits.Tree.next_kid
int next_kid(int alias, int kid)
Definition: Bits.java:500
com.cliffc.aa.type.Bits.max
int max()
Definition: Bits.java:284
com.cliffc.aa.type.Bits.bitCount
int bitCount()
Definition: Bits.java:113
com.cliffc.aa.type.Bits.subtract
Bits< B > subtract(Bits< B > bs)
Definition: Bits.java:374
com.cliffc.aa.type.Bits.isa
boolean isa(B bs)
Definition: Bits.java:372
com.cliffc.aa.type.Bits.Tree._pars
int[] _pars
Definition: Bits.java:405
com.cliffc.aa
Definition: AA.java:1
com.cliffc.aa.util.SB.nl
SB nl()
Definition: SB.java:48
com.cliffc.aa.type.Bits.Iter
Definition: Bits.java:524
com.cliffc.aa.type.Bits.is_con
boolean is_con()
Definition: Bits.java:206
com.cliffc.aa.type.Bits.oob
TypeObj oob(TypeObj t)
Definition: Bits.java:397
com.cliffc.aa.type.Bits.Tree._plus_kids
void _plus_kids(VBitSet bs, int i)
Definition: Bits.java:490
com.cliffc.aa.type.Bits.and
static void and(long[] bits, long con)
Definition: Bits.java:282
com.cliffc.aa.type.Bits.make
final B make(int... bits)
Definition: Bits.java:191
com.cliffc.aa.type.Bits.abit
int abit()
Definition: Bits.java:203
com.cliffc.aa.util.SB.p
SB p(String s)
Definition: SB.java:13
com.cliffc.aa.type.Bits.strip_nil
B strip_nil()
Definition: Bits.java:273
com.cliffc.aa.type.Bits.make_impl
abstract B make_impl(int con, long[] bits)
com.cliffc.aa.type.Bits.EMPTY
abstract B EMPTY()
com.cliffc.aa.type.Type.dual
final T dual()
Definition: Type.java:361
com.cliffc.aa.type.Bits.tree
abstract Tree< B > tree()
com.cliffc.aa.type.Bits.Tree.split
int split(int par)
Definition: Bits.java:433
com.cliffc.aa.type.Bits.ALL
abstract B ALL()
com.cliffc.aa.type.Bits.or
static void or(long[] bits, long con)
Definition: Bits.java:281
com.cliffc.aa.type.Bits.Iter.next
Integer next()
Definition: Bits.java:535
com.cliffc.aa.util.SB.i
SB i(int d)
Definition: SB.java:38
com.cliffc.aa.type.Bits.make
final B make(int bit)
Definition: Bits.java:189
com.cliffc.aa.type.Bits.toString
String toString()
Definition: Bits.java:133
com.cliffc.aa.type.Bits.Iter._i
int _i
Definition: Bits.java:525
com.cliffc.aa.type.Bits.Tree.init0
void init0()
Definition: Bits.java:469
com.cliffc.aa.type.Bits.not_nil
B not_nil()
Definition: Bits.java:246
com.cliffc.aa.type.Bits.meet
B meet(final B bs)
Definition: Bits.java:298
com.cliffc.aa.util.IBitSet.set
boolean set(int idx)
Definition: IBitSet.java:26
com.cliffc.aa.type.Bits.is_nil
boolean is_nil()
Definition: Bits.java:208
com
com.cliffc.aa.type.Bits.set
B set(int bit)
Definition: Bits.java:264
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62
com.cliffc.aa.type.Bits.Tree.reset_to_init0
void reset_to_init0()
Definition: Bits.java:475
com.cliffc.aa.type.Bits.is_empty
boolean is_empty()
Definition: Bits.java:207