aa
com.cliffc.aa.type.BitsFun Class Reference
Inheritance diagram for com.cliffc.aa.type.BitsFun:
[legend]
Collaboration diagram for com.cliffc.aa.type.BitsFun:
[legend]

Public Member Functions

int abit ()
 
boolean above_center ()
 
BitsFun ALL ()
 
BitsFun ANY ()
 
int bitCount ()
 
IBitSet bitset ()
 
clear (int bit)
 
dual ()
 
BitsFun EMPTY ()
 
boolean equals (Object o)
 
int getbit ()
 
int hashCode ()
 
boolean is_con ()
 
boolean is_empty ()
 
boolean is_nil ()
 
boolean isa (B bs)
 
Iterator< Integer > iterator ()
 
Bits< B > join (Bits< B > bs)
 
final B make (int... bits)
 
int max ()
 
meet (final B bs)
 
meet_nil ()
 
TypeObj oob (TypeObj t)
 
boolean overlaps (Bits< B > bs)
 
set (int bit)
 
SB str (SB sb)
 
strip_nil ()
 
Bits< B > subtract (Bits< B > bs)
 
boolean test (int i)
 
boolean test_recur (int i)
 
String toString ()
 
Tree< BitsFuntree ()
 

Static Public Member Functions

static void init0 ()
 
static boolean is_parent (int idx)
 
static BitsFun make0 (int bit)
 
static BitsFun make0 (int... bits)
 
static int new_fidx ()
 
static int new_fidx (int par)
 
static int next_kid (int alias, int kid)
 
static int parent (int kid)
 
static int peek ()
 
static void reset_to_init0 ()
 

Static Public Attributes

static final int ALL = new_fidx(0)
 
static final BitsFun ANY = FULL.dual()
 
static final BitsFun EMPTY = make0()
 
static final BitsFun FULL = new BitsFun().make_impl(1,new long[]{1L | (1L<<ALL)})
 
static final BitsFun NIL = make0(0)
 
static final BitsFun XNIL = NIL.dual()
 

Package Functions

void init (int con, long[] bits)
 
final B make (int bit)
 
BitsFun make_impl (int con, long[] bits)
 
boolean may_nil ()
 
not_nil ()
 

Static Package Functions

static BitsFun make_new_fidx (int parent_fidx)
 

Package Attributes

long[] _bits
 
int _con
 
int _hash
 

Private Member Functions

boolean check ()
 
make (boolean any, long[] bits)
 

Static Private Member Functions

static void and (long[] bits, long con)
 
static long[] bits (int b)
 
static boolean check_multi_bits (long[] bits)
 
static int idx (long i)
 
static void join (Tree tree, long[] bits0, long[] bits1, long[] bits2)
 
static long mask (long i)
 
static void or (long[] bits, long con)
 
static boolean test (long[] bits, int i)
 

Static Private Attributes

static BitsFun FREE =null
 
static final HashMap< BitsFun, BitsFunINTERN = new HashMap<>()
 
static final Bits.Tree< BitsFunTREE = new Bits.Tree<>()
 

Detailed Description

Definition at line 7 of file BitsFun.java.

Member Function Documentation

◆ abit()

int com.cliffc.aa.type.Bits< B extends Bits< B >.abit
inherited

Definition at line 203 of file Bits.java.

203 { return _bits==null&&_con!=0 ? _con : -1; }

◆ above_center()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.above_center
inherited

Definition at line 204 of file Bits.java.

204 { return _con<0; }

◆ ALL()

BitsFun com.cliffc.aa.type.BitsFun.ALL ( )

Definition at line 38 of file BitsFun.java.

38 { return FULL; }

References com.cliffc.aa.type.BitsFun.FULL.

◆ and()

static void com.cliffc.aa.type.Bits< B extends Bits< B >.and ( long[]  bits,
long  con 
)
staticprivateinherited

Definition at line 282 of file Bits.java.

282 { bits[idx(con)] &= ~mask(con); }

◆ ANY()

BitsFun com.cliffc.aa.type.BitsFun.ANY ( )

Definition at line 39 of file BitsFun.java.

39 { return ANY ; }

References com.cliffc.aa.type.BitsFun.ANY().

Referenced by com.cliffc.aa.type.BitsFun.ANY().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bitCount()

int com.cliffc.aa.type.Bits< B extends Bits< B >.bitCount
inherited

Definition at line 113 of file Bits.java.

113  {
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  }

◆ bits()

static long [] com.cliffc.aa.type.Bits< B extends Bits< B >.bits ( int  b)
staticprivateinherited

Definition at line 283 of file Bits.java.

283 { return new long[idx(b)+1]; }

◆ bitset()

IBitSet com.cliffc.aa.type.Bits< B extends Bits< B >.bitset
inherited

Definition at line 391 of file Bits.java.

391  {
392  IBitSet bs = new IBitSet();
393  for( int alias : this )
394  bs.set(alias);
395  return bs;
396  }

◆ check()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.check
privateinherited

Definition at line 89 of file Bits.java.

89  {
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  }

◆ check_multi_bits()

static boolean com.cliffc.aa.type.Bits< B extends Bits< B >.check_multi_bits ( long[]  bits)
staticprivateinherited

Definition at line 105 of file Bits.java.

105  {
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  }

◆ clear()

B com.cliffc.aa.type.Bits< B extends Bits< B >.clear ( int  bit)
inherited

Definition at line 255 of file Bits.java.

255  {
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  }

◆ dual()

B com.cliffc.aa.type.Bits< B extends Bits< B >.dual
inherited

Definition at line 368 of file Bits.java.

368 { return make_impl(-_con,_bits); }

◆ EMPTY()

BitsFun com.cliffc.aa.type.BitsFun.EMPTY ( )

Definition at line 40 of file BitsFun.java.

40 { return EMPTY ; }

References com.cliffc.aa.type.BitsFun.EMPTY().

Referenced by com.cliffc.aa.type.BitsFun.EMPTY().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equals()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.equals ( Object  o)
inherited

Definition at line 121 of file Bits.java.

121  {
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  }

◆ getbit()

int com.cliffc.aa.type.Bits< B extends Bits< B >.getbit
inherited

Definition at line 202 of file Bits.java.

202 { assert _bits==null && _con!=0; return _con; }

◆ hashCode()

int com.cliffc.aa.type.Bits< B extends Bits< B >.hashCode
inherited

Definition at line 120 of file Bits.java.

120 { return _hash; }

◆ idx()

static int com.cliffc.aa.type.Bits< B extends Bits< B >.idx ( long  i)
staticprivateinherited

Definition at line 199 of file Bits.java.

199 { return (int)(i>>6); }

◆ init()

void com.cliffc.aa.type.Bits< B extends Bits< B >.init ( int  con,
long[]  bits 
)
packageinherited

Definition at line 80 of file Bits.java.

80  {
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  }

◆ init0()

static void com.cliffc.aa.type.BitsFun.init0 ( )
static

Definition at line 28 of file BitsFun.java.

28 { TREE.init0(); }

References com.cliffc.aa.type.BitsFun.TREE.

Referenced by com.cliffc.aa.Env.record_for_top_reset1().

Here is the caller graph for this function:

◆ is_con()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.is_con
inherited

Definition at line 206 of file Bits.java.

206 { return is_nil() || is_empty(); }

◆ is_empty()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.is_empty
inherited

Definition at line 207 of file Bits.java.

207 { return _bits==null && _con==0; }

◆ is_nil()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.is_nil
inherited

Definition at line 208 of file Bits.java.

208 { return _bits!=null && _bits.length==1 && _bits[0]==1; }

◆ is_parent()

static boolean com.cliffc.aa.type.BitsFun.is_parent ( int  idx)
static

Definition at line 48 of file BitsFun.java.

48 { return TREE.is_parent(idx); }

References com.cliffc.aa.type.Bits< BitsFun >.idx(), and com.cliffc.aa.type.BitsFun.TREE.

Referenced by com.cliffc.aa.node.CallEpiNode.check_and_wire(), com.cliffc.aa.node.CallEpiNode.ideal_reduce(), com.cliffc.aa.node.CallNode.least_cost(), com.cliffc.aa.node.FunNode.split_size(), and com.cliffc.aa.node.CallEpiNode.value().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isa()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.isa ( bs)
inherited

Definition at line 372 of file Bits.java.

372 { return meet(bs) == bs; }

◆ iterator()

Iterator<Integer> com.cliffc.aa.type.Bits< B extends Bits< B >.iterator
inherited
Returns
an iterator

Definition at line 523 of file Bits.java.

523 { return new Iter(); }

◆ join() [1/2]

Bits<B> com.cliffc.aa.type.Bits< B extends Bits< B >.join ( Bits< B >  bs)
inherited

Definition at line 370 of file Bits.java.

370 { return dual().meet(bs.dual()).dual(); }

◆ join() [2/2]

static void com.cliffc.aa.type.Bits< B extends Bits< B >.join ( Tree  tree,
long[]  bits0,
long[]  bits1,
long[]  bits2 
)
staticprivateinherited

Definition at line 349 of file Bits.java.

349  {
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  }

◆ make() [1/3]

B com.cliffc.aa.type.Bits< B extends Bits< B >.make ( boolean  any,
long[]  bits 
)
privateinherited

Definition at line 154 of file Bits.java.

154  {
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  }

◆ make() [2/3]

final B com.cliffc.aa.type.Bits< B extends Bits< B >.make ( int  bit)
packageinherited

Definition at line 189 of file Bits.java.

189 { return bit==0 ? make_impl(1,new long[]{1}) : make_impl(bit,null); }

◆ make() [3/3]

final B com.cliffc.aa.type.Bits< B extends Bits< B >.make ( int...  bits)
inherited

Definition at line 191 of file Bits.java.

191  {
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  }

◆ make0() [1/2]

static BitsFun com.cliffc.aa.type.BitsFun.make0 ( int  bit)
static

◆ make0() [2/2]

static BitsFun com.cliffc.aa.type.BitsFun.make0 ( int...  bits)
static

Definition at line 45 of file BitsFun.java.

45 { return FULL.make(bits); }

References com.cliffc.aa.type.Bits< BitsFun >.bits(), com.cliffc.aa.type.BitsFun.FULL, and com.cliffc.aa.type.Bits< B extends Bits< B >.make().

Here is the call graph for this function:

◆ make_impl()

BitsFun com.cliffc.aa.type.BitsFun.make_impl ( int  con,
long[]  bits 
)
package

Definition at line 12 of file BitsFun.java.

12  {
13  BitsFun b1 = FREE;
14  if( b1 == null ) b1 = new BitsFun();
15  else FREE = null;
16  b1.init(con,bits);
17  BitsFun b2 = INTERN.get(b1);
18  if( b2 != null ) { FREE = b1; return b2; }
19  else { INTERN.put(b1,b1); return b1; }
20  }

References com.cliffc.aa.type.Bits< BitsFun >.bits(), com.cliffc.aa.type.BitsFun.FREE, com.cliffc.aa.type.Bits< B extends Bits< B >.init(), and com.cliffc.aa.type.BitsFun.INTERN.

Here is the call graph for this function:

◆ make_new_fidx()

static BitsFun com.cliffc.aa.type.BitsFun.make_new_fidx ( int  parent_fidx)
staticpackage

Definition at line 43 of file BitsFun.java.

43 { return make0(new_fidx(parent_fidx)); }

References com.cliffc.aa.type.BitsFun.make0(), and com.cliffc.aa.type.BitsFun.new_fidx().

Referenced by com.cliffc.aa.type.TypeFunPtr.make_new_fidx().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mask()

static long com.cliffc.aa.type.Bits< B extends Bits< B >.mask ( long  i)
staticprivateinherited

Definition at line 200 of file Bits.java.

200 { return 1L<<(i&63); }

◆ max()

int com.cliffc.aa.type.Bits< B extends Bits< B >.max
inherited

Definition at line 284 of file Bits.java.

284  {
285  return _bits==null ? Math.abs(_con) : (63 - Long.numberOfLeadingZeros(_bits[_bits.length-1]))+((_bits.length-1)<<6);
286  }

◆ may_nil()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.may_nil
packageinherited

Definition at line 209 of file Bits.java.

209 { return _con==-1 && _bits != null && ((_bits[0]&1) == 1); }

◆ meet()

B com.cliffc.aa.type.Bits< B extends Bits< B >.meet ( final B  bs)
inherited

Definition at line 298 of file Bits.java.

298  {
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  }

◆ meet_nil()

B com.cliffc.aa.type.Bits< B extends Bits< B >.meet_nil
inherited

Definition at line 212 of file Bits.java.

212  {
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  }

◆ new_fidx() [1/2]

static int com.cliffc.aa.type.BitsFun.new_fidx ( )
static

Definition at line 26 of file BitsFun.java.

26 { return TREE.split(ALL); }

References com.cliffc.aa.type.BitsFun.ALL, and com.cliffc.aa.type.BitsFun.TREE.

Referenced by com.cliffc.aa.type.BitsFun.make_new_fidx().

Here is the caller graph for this function:

◆ new_fidx() [2/2]

static int com.cliffc.aa.type.BitsFun.new_fidx ( int  par)
static

Definition at line 25 of file BitsFun.java.

25 { return TREE.split(par); }

References com.cliffc.aa.type.BitsFun.TREE.

Referenced by com.cliffc.aa.node.FunNode.FunNode(), com.cliffc.aa.HM.HM9.Lambda.Lambda(), com.cliffc.aa.HM.HM.Lambda.Lambda(), com.cliffc.aa.node.FunNode.make_new_fun(), and com.cliffc.aa.type.TestApprox.testApprox8().

Here is the caller graph for this function:

◆ next_kid()

static int com.cliffc.aa.type.BitsFun.next_kid ( int  alias,
int  kid 
)
static

Definition at line 52 of file BitsFun.java.

52 { return TREE.next_kid(alias,kid); }

References com.cliffc.aa.type.BitsFun.TREE.

Referenced by com.cliffc.aa.node.CallNode.err(), and com.cliffc.aa.node.CallNode.least_cost().

Here is the caller graph for this function:

◆ not_nil()

B com.cliffc.aa.type.Bits< B extends Bits< B >.not_nil
packageinherited

Definition at line 246 of file Bits.java.

246  {
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  }

◆ oob()

TypeObj com.cliffc.aa.type.Bits< B extends Bits< B >.oob ( TypeObj  t)
inherited

Definition at line 397 of file Bits.java.

397 { return above_center() ? (TypeObj)t.dual() : t; }

◆ or()

static void com.cliffc.aa.type.Bits< B extends Bits< B >.or ( long[]  bits,
long  con 
)
staticprivateinherited

Definition at line 281 of file Bits.java.

281 { bits[idx(con)] |= mask(con); }

◆ overlaps()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.overlaps ( Bits< B >  bs)
inherited

Definition at line 382 of file Bits.java.

382  {
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  }

◆ parent()

static int com.cliffc.aa.type.BitsFun.parent ( int  kid)
static

Definition at line 50 of file BitsFun.java.

50 { return TREE.parent(kid); }

References com.cliffc.aa.type.BitsFun.TREE.

Referenced by com.cliffc.aa.node.CallEpiNode.value().

Here is the caller graph for this function:

◆ peek()

static int com.cliffc.aa.type.BitsFun.peek ( )
static

Definition at line 46 of file BitsFun.java.

46 { return TREE.peek(); }

References com.cliffc.aa.type.BitsFun.TREE.

◆ reset_to_init0()

static void com.cliffc.aa.type.BitsFun.reset_to_init0 ( )
static

Definition at line 29 of file BitsFun.java.

29 { TREE.reset_to_init0(); }

References com.cliffc.aa.type.BitsFun.TREE.

Referenced by com.cliffc.aa.HM.HM9.reset(), com.cliffc.aa.HM.HM.reset(), and com.cliffc.aa.Env.top_reset().

Here is the caller graph for this function:

◆ set()

B com.cliffc.aa.type.Bits< B extends Bits< B >.set ( int  bit)
inherited

Definition at line 264 of file Bits.java.

264  {
265  if( test(bit) ) return (B)this;
266  B b = make(bit);
267  if( this == EMPTY() ) return b;
268  return meet(b);
269  }

◆ str()

SB com.cliffc.aa.type.Bits< B extends Bits< B >.str ( SB  sb)
inherited

Definition at line 134 of file Bits.java.

134  {
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  }

◆ strip_nil()

B com.cliffc.aa.type.Bits< B extends Bits< B >.strip_nil
inherited

Definition at line 273 of file Bits.java.

273  {
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  }

◆ subtract()

Bits<B> com.cliffc.aa.type.Bits< B extends Bits< B >.subtract ( Bits< B >  bs)
inherited

Definition at line 374 of file Bits.java.

374  {
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  }

◆ test() [1/2]

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.test ( int  i)
inherited

Definition at line 226 of file Bits.java.

226  {
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  }

◆ test() [2/2]

static boolean com.cliffc.aa.type.Bits< B extends Bits< B >.test ( long[]  bits,
int  i 
)
staticprivateinherited

Definition at line 224 of file Bits.java.

224 { return idx(i) < bits.length && (bits[idx(i)]&mask(i))!=0; }

◆ test_recur()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.test_recur ( int  i)
inherited

Definition at line 232 of file Bits.java.

232  {
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  }

◆ toString()

String com.cliffc.aa.type.Bits< B extends Bits< B >.toString
inherited

Definition at line 133 of file Bits.java.

133 { return str(new SB()).toString(); }

◆ tree()

Tree<BitsFun> com.cliffc.aa.type.BitsFun.tree ( )

Definition at line 23 of file BitsFun.java.

23 { return TREE; }

References com.cliffc.aa.type.BitsFun.TREE.

Referenced by com.cliffc.aa.node.CallNode.err(), and com.cliffc.aa.node.CallNode.live().

Here is the caller graph for this function:

Member Data Documentation

◆ _bits

long [] com.cliffc.aa.type.Bits< B extends Bits< B >._bits
packageinherited

Definition at line 68 of file Bits.java.

◆ _con

int com.cliffc.aa.type.Bits< B extends Bits< B >._con
packageinherited

Definition at line 69 of file Bits.java.

◆ _hash

int com.cliffc.aa.type.Bits< B extends Bits< B >._hash
packageinherited

Definition at line 70 of file Bits.java.

◆ ALL

final int com.cliffc.aa.type.BitsFun.ALL = new_fidx(0)
static

◆ ANY

final BitsFun com.cliffc.aa.type.BitsFun.ANY = FULL.dual()
static

◆ EMPTY

◆ FREE

BitsFun com.cliffc.aa.type.BitsFun.FREE =null
staticprivate

Definition at line 11 of file BitsFun.java.

Referenced by com.cliffc.aa.type.BitsFun.make_impl().

◆ FULL

◆ INTERN

final HashMap<BitsFun,BitsFun> com.cliffc.aa.type.BitsFun.INTERN = new HashMap<>()
staticprivate

Definition at line 10 of file BitsFun.java.

Referenced by com.cliffc.aa.type.BitsFun.make_impl().

◆ NIL

final BitsFun com.cliffc.aa.type.BitsFun.NIL = make0(0)
static

Definition at line 35 of file BitsFun.java.

Referenced by com.cliffc.aa.type.TypeFunPtr.meet_nil().

◆ TREE

◆ XNIL

final BitsFun com.cliffc.aa.type.BitsFun.XNIL = NIL.dual()
static

Definition at line 36 of file BitsFun.java.


The documentation for this class was generated from the following file:
com.cliffc.aa.type.Bits< BitsFun >::bits
static long[] bits(int b)
Definition: Bits.java:283
com.cliffc.aa.type.Bits< BitsFun >::dual
B dual()
Definition: Bits.java:368
com.cliffc.aa.type.BitsFun.TREE
static final Bits.Tree< BitsFun > TREE
Definition: BitsFun.java:22
com.cliffc.aa.type.Bits< BitsFun >::ANY
abstract B ANY()
com.cliffc.aa.type.Bits< BitsFun >::str
SB str(SB sb)
Definition: Bits.java:134
com.cliffc.aa.type.BitsFun.EMPTY
static final BitsFun EMPTY
Definition: BitsFun.java:37
com.cliffc.aa.type.BitsFun.make0
static BitsFun make0(int bit)
Definition: BitsFun.java:44
com.cliffc.aa.type.Bits< BitsFun >::check
boolean check()
Definition: Bits.java:89
com.cliffc.aa.type.Bits< BitsFun >::make
B make(boolean any, long[] bits)
Definition: Bits.java:154
com.cliffc.aa.type.BitsFun.FULL
static final BitsFun FULL
Definition: BitsFun.java:33
com.cliffc.aa.type.Bits< BitsFun >::mask
static long mask(long i)
Definition: Bits.java:200
com.cliffc.aa.type.BitsFun.new_fidx
static int new_fidx()
Definition: BitsFun.java:26
com.cliffc.aa.type.BitsFun.ALL
static final int ALL
Definition: BitsFun.java:24
com.cliffc.aa.type.Bits< BitsFun >::test
static boolean test(long[] bits, int i)
Definition: Bits.java:224
com.cliffc.aa.type.Bits< BitsFun >::check_multi_bits
static boolean check_multi_bits(long[] bits)
Definition: Bits.java:105
com.cliffc.aa.type.Bits< BitsFun >::above_center
boolean above_center()
Definition: Bits.java:204
com.cliffc.aa.type.Bits< BitsFun >::_bits
long[] _bits
Definition: Bits.java:68
com.cliffc.aa.type.Bits< BitsFun >::join
static void join(Tree tree, long[] bits0, long[] bits1, long[] bits2)
Definition: Bits.java:349
com.cliffc.aa.type.Bits.init
void init(int con, long[] bits)
Definition: Bits.java:80
com.cliffc.aa.type.Bits< BitsFun >::_hash
int _hash
Definition: Bits.java:70
com.cliffc.aa.type.Bits< BitsFun >::_con
int _con
Definition: Bits.java:69
com.cliffc.aa.type.Bits< BitsFun >::idx
static int idx(long i)
Definition: Bits.java:199
com.cliffc.aa.type.BitsFun.INTERN
static final HashMap< BitsFun, BitsFun > INTERN
Definition: BitsFun.java:10
com.cliffc.aa.type.Bits< BitsFun >::max
int max()
Definition: Bits.java:284
com.cliffc.aa.type.BitsFun.ANY
static final BitsFun ANY
Definition: BitsFun.java:34
com.cliffc.aa.type.Bits< BitsFun >::and
static void and(long[] bits, long con)
Definition: Bits.java:282
com.cliffc.aa.type.Bits< BitsFun >::make_impl
abstract B make_impl(int con, long[] bits)
com.cliffc.aa.type.BitsFun.FREE
static BitsFun FREE
Definition: BitsFun.java:11
com.cliffc.aa.type.Bits< BitsFun >::EMPTY
abstract B EMPTY()
com.cliffc.aa.type.Bits< BitsFun >::tree
abstract Tree< B > tree()
com.cliffc.aa.type.Bits< BitsFun >::ALL
abstract B ALL()
com.cliffc.aa.type.Bits< BitsFun >::or
static void or(long[] bits, long con)
Definition: Bits.java:281
com.cliffc.aa.type.Bits< BitsFun >::meet
B meet(final B bs)
Definition: Bits.java:298
com.cliffc.aa.type.Bits< BitsFun >::is_nil
boolean is_nil()
Definition: Bits.java:208
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62
com.cliffc.aa.type.Bits< BitsFun >::is_empty
boolean is_empty()
Definition: Bits.java:207