aa
com.cliffc.aa.type.Bits< B extends Bits< B > Class Template Referenceabstract
Inheritance diagram for com.cliffc.aa.type.Bits< B extends Bits< B >:
[legend]
Collaboration diagram for com.cliffc.aa.type.Bits< B extends Bits< B >:
[legend]

Classes

class  Iter
 
class  Tree
 

Public Member Functions

int abit ()
 
boolean above_center ()
 
abstract B ALL ()
 
abstract B ANY ()
 
int bitCount ()
 
IBitSet bitset ()
 
clear (int bit)
 
dual ()
 
abstract B 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 ()
 

Package Functions

void init (int con, long[] bits)
 
final B make (int bit)
 
abstract B make_impl (int con, long[] bits)
 
boolean may_nil ()
 
not_nil ()
 
abstract Tree< B > tree ()
 

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)
 

Detailed Description

Definition at line 61 of file Bits.java.

Member Function Documentation

◆ abit()

◆ above_center()

◆ ALL()

abstract B com.cliffc.aa.type.Bits< B extends Bits< B >.ALL ( )
abstract

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.meet().

Here is the caller graph for this function:

◆ and()

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

Definition at line 282 of file Bits.java.

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

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.clear(), and com.cliffc.aa.type.Bits< BitsRPC >.not_nil().

Here is the caller graph for this function:

◆ ANY()

abstract B com.cliffc.aa.type.Bits< B extends Bits< B >.ANY ( )
abstract

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.meet().

Here is the caller graph for this function:

◆ bitCount()

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

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  }

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

Here is the caller graph for this function:

◆ bits()

◆ bitset()

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

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 ( )
private

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  }

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.init().

Here is the caller graph for this function:

◆ check_multi_bits()

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

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  }

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.check(), and com.cliffc.aa.type.Bits< BitsRPC >.make().

Here is the caller graph for this function:

◆ clear()

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

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  }

Referenced by com.cliffc.aa.HM.HM.T2._fresh_unify(), com.cliffc.aa.Env.close_display(), com.cliffc.aa.HM.HM9.NotNil.hm(), com.cliffc.aa.node.NewObjNode.promote_forward(), com.cliffc.aa.type.Bits< BitsRPC >.subtract(), and com.cliffc.aa.HM.HM.T2.unify_nil().

Here is the caller graph for this function:

◆ dual()

◆ EMPTY()

abstract B com.cliffc.aa.type.Bits< B extends Bits< B >.EMPTY ( )
abstract

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.clear(), and com.cliffc.aa.type.Bits< BitsRPC >.set().

Here is the caller graph for this function:

◆ equals()

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

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 ( )

Definition at line 202 of file Bits.java.

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

Referenced by com.cliffc.aa.type.TypeMemPtr.depth(), com.cliffc.aa.type.TypeFunPtr.fidx(), com.cliffc.aa.type.TypeMemPtr.getbit(), com.cliffc.aa.HM.HM8.Struct.hm(), and com.cliffc.aa.type.TypeRPC.rpc().

Here is the caller graph for this function:

◆ hashCode()

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

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)
staticprivate

◆ init()

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

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  }

Referenced by com.cliffc.aa.type.BitsFun.make_impl(), com.cliffc.aa.type.BitsRPC.make_impl(), and com.cliffc.aa.type.BitsAlias.make_impl().

Here is the caller graph for this function:

◆ is_con()

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

Definition at line 206 of file Bits.java.

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

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

Here is the caller graph for this function:

◆ is_empty()

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

Definition at line 207 of file Bits.java.

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

Referenced by com.cliffc.aa.node.CallNode._ideal_grow(), com.cliffc.aa.node.MemSplitNode.add_alias(), com.cliffc.aa.node.CallNode.err(), com.cliffc.aa.type.Bits< BitsRPC >.is_con(), and com.cliffc.aa.type.Bits< BitsRPC >.meet().

Here is the caller graph for this function:

◆ is_nil()

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

Definition at line 208 of file Bits.java.

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

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.is_con().

Here is the caller graph for this function:

◆ isa()

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

Definition at line 372 of file Bits.java.

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

Referenced by com.cliffc.aa.node.MemSplitNode.add_alias(), com.cliffc.aa.type.TypeMemPtr.ax_meet_nil(), com.cliffc.aa.node.MemJoinNode.can_bypass(), com.cliffc.aa.type.TypeRPC.meet_nil(), com.cliffc.aa.type.TypeFunPtr.meet_nil(), com.cliffc.aa.type.TypeMemPtr.meet_nil(), com.cliffc.aa.type.TypeMemPtr.oop_deep_impl(), and com.cliffc.aa.type.TypeMemPtr.widen().

Here is the caller graph for this function:

◆ iterator()

Iterator<Integer> com.cliffc.aa.type.Bits< B extends Bits< B >.iterator ( )
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)

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 
)
staticprivate

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  }

Referenced by com.cliffc.aa.node.LoadNode._find_previous_store_call(), com.cliffc.aa.node.MemSplitNode.add_alias(), com.cliffc.aa.node.LoadNode.find_previous_store(), and com.cliffc.aa.type.Bits< BitsRPC >.meet().

Here is the caller graph for this function:

◆ make() [1/3]

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

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  }

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.clear(), com.cliffc.aa.type.Bits< BitsRPC >.make(), com.cliffc.aa.type.BitsRPC.make0(), com.cliffc.aa.type.BitsFun.make0(), com.cliffc.aa.type.BitsAlias.make0(), com.cliffc.aa.type.Bits< BitsRPC >.meet(), com.cliffc.aa.type.Bits< BitsRPC >.meet_nil(), com.cliffc.aa.type.Bits< BitsRPC >.not_nil(), com.cliffc.aa.type.Bits< BitsRPC >.set(), com.cliffc.aa.type.Bits< BitsRPC >.strip_nil(), com.cliffc.aa.HM.TestHM9.test36(), com.cliffc.aa.HM.TestHM.test52(), com.cliffc.aa.HM.TestHM.test55(), and com.cliffc.aa.HM.TestHM.test57().

Here is the caller graph for this function:

◆ make() [2/3]

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

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)

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  }

◆ make_impl()

abstract B com.cliffc.aa.type.Bits< B extends Bits< B >.make_impl ( int  con,
long[]  bits 
)
abstractpackage

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.dual(), and com.cliffc.aa.type.Bits< BitsRPC >.make().

Here is the caller graph for this function:

◆ mask()

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

Definition at line 200 of file Bits.java.

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

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.and(), com.cliffc.aa.type.Bits< B extends Bits< B >.Iter.hasNext(), com.cliffc.aa.type.Bits< BitsRPC >.join(), com.cliffc.aa.type.Bits< BitsRPC >.make(), com.cliffc.aa.type.Bits< BitsRPC >.or(), and com.cliffc.aa.type.Bits< BitsRPC >.test().

Here is the caller graph for this function:

◆ max()

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

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  }

Referenced by com.cliffc.aa.type.TypeMem.and_unused(), com.cliffc.aa.type.Bits< BitsRPC >.make(), com.cliffc.aa.type.TypeMem.make(), com.cliffc.aa.type.TypeMem.remove_no_escapes(), and com.cliffc.aa.type.TypeMem.slice_reaching_aliases().

Here is the caller graph for this function:

◆ may_nil()

boolean com.cliffc.aa.type.Bits< B extends Bits< B >.may_nil ( )
package

Definition at line 209 of file Bits.java.

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

Referenced by com.cliffc.aa.type.TypeMem.all_reaching_aliases(), com.cliffc.aa.type.TypeRPC.may_nil(), com.cliffc.aa.type.TypeFunPtr.may_nil(), and com.cliffc.aa.type.TypeMemPtr.may_nil().

Here is the caller graph for this function:

◆ meet()

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

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  }

Referenced by com.cliffc.aa.HM.HM.T2._find_fidxs(), com.cliffc.aa.node.CallNode._ideal_grow(), com.cliffc.aa.HM.HM8.T2._unify(), com.cliffc.aa.node.MemSplitNode.add_alias(), com.cliffc.aa.type.TypeStruct.ax_meet(), com.cliffc.aa.type.TypeMemPtr.ax_meet_nil(), com.cliffc.aa.node.CallNode.escapees(), com.cliffc.aa.type.Bits< BitsRPC >.isa(), com.cliffc.aa.node.CallNode.live_use(), com.cliffc.aa.HM.HM9.T2.meet_alias(), com.cliffc.aa.HM.HM.T2.meet_alias(), com.cliffc.aa.HM.HM9.T2.meet_fidxs(), com.cliffc.aa.HM.HM.T2.meet_fidxs(), com.cliffc.aa.type.TypeRPC.meet_nil(), com.cliffc.aa.type.TypeFunPtr.meet_nil(), com.cliffc.aa.type.TypeMemPtr.meet_nil(), com.cliffc.aa.type.Bits< BitsRPC >.set(), com.cliffc.aa.type.TestType.testFunction(), com.cliffc.aa.node.UnresolvedNode.value(), com.cliffc.aa.node.CallNode.value(), com.cliffc.aa.type.TypeRPC.xmeet(), com.cliffc.aa.type.TypeFunPtr.xmeet(), and com.cliffc.aa.type.TypeMemPtr.xmeet().

Here is the caller graph for this function:

◆ meet_nil()

B com.cliffc.aa.type.Bits< B extends Bits< B >.meet_nil ( )

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  }

Referenced by com.cliffc.aa.HM.HM.T2._find_nil(), com.cliffc.aa.HM.TestHM.build_cycle(), com.cliffc.aa.HM.TestHM9.build_cycle(), com.cliffc.aa.HM.TestHM.build_cycle2(), com.cliffc.aa.HM.HM.NotNil.hm(), com.cliffc.aa.type.TypeMemPtr.make_nil(), com.cliffc.aa.type.TestApprox.testApprox7(), and com.cliffc.aa.type.TestType.testOOPsNulls().

Here is the caller graph for this function:

◆ not_nil()

B com.cliffc.aa.type.Bits< B extends Bits< B >.not_nil ( )
package

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  }

Referenced by com.cliffc.aa.type.TypeRPC.not_nil(), com.cliffc.aa.type.TypeFunPtr.not_nil(), and com.cliffc.aa.type.TypeMemPtr.not_nil().

Here is the caller graph for this function:

◆ oob()

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

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 
)
staticprivate

Definition at line 281 of file Bits.java.

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

Referenced by com.cliffc.aa.type.Bits< BitsRPC >.make(), com.cliffc.aa.type.Bits< BitsRPC >.meet(), and com.cliffc.aa.type.Bits< BitsRPC >.meet_nil().

Here is the caller graph for this function:

◆ overlaps()

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

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  }

Referenced by com.cliffc.aa.node.MemSplitNode.check_split().

Here is the caller graph for this function:

◆ set()

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

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  }

Referenced by com.cliffc.aa.HM.HM9.T2._fresh_unify(), com.cliffc.aa.node.MemSplitNode._update(), com.cliffc.aa.type.TypeMem.aliases(), com.cliffc.aa.type.TypeMem.all_reaching_aliases(), com.cliffc.aa.type.TypeMem.and_unused(), com.cliffc.aa.Env.init(), and com.cliffc.aa.node.TestNodeSmall.testRecursiveDisplay().

Here is the caller graph for this function:

◆ str()

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

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  }

Referenced by com.cliffc.aa.HM.HM8.T2._p(), com.cliffc.aa.HM.HM9.T2._p(), com.cliffc.aa.HM.HM8.Struct.p1(), com.cliffc.aa.type.TypeRPC.str(), com.cliffc.aa.type.TypeMemPtr.str(), com.cliffc.aa.type.TypeFunPtr.str(), com.cliffc.aa.HM.HM8.Struct.str(), com.cliffc.aa.HM.HM8.T2.str(), com.cliffc.aa.HM.HM9.T2.str(), com.cliffc.aa.HM.HM.T2.str(), and com.cliffc.aa.type.Bits< BitsRPC >.toString().

Here is the caller graph for this function:

◆ strip_nil()

B com.cliffc.aa.type.Bits< B extends Bits< B >.strip_nil ( )

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  }

Referenced by com.cliffc.aa.type.TypeMemPtr.getbit0(), com.cliffc.aa.type.TypeMemPtr.is_display_ptr(), and com.cliffc.aa.TestParse.test_ptr0().

Here is the caller graph for this function:

◆ subtract()

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

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)

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 
)
staticprivate

Definition at line 224 of file Bits.java.

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

Referenced by com.cliffc.aa.HM.HM9.T2._fresh_unify(), com.cliffc.aa.HM.HM.T2._fresh_unify(), com.cliffc.aa.HM.HM.T2._p(), com.cliffc.aa.node.MemSplitNode._update(), com.cliffc.aa.type.TypeStruct.ax_impl_ptr(), com.cliffc.aa.type.Bits< BitsRPC >.check(), com.cliffc.aa.type.TestApprox.check_leaf(), com.cliffc.aa.type.Bits< BitsRPC >.clear(), com.cliffc.aa.type.TypeMemPtr.depth(), com.cliffc.aa.node.ScopeNode.get_type(), com.cliffc.aa.HM.HM9.Apply.hm(), com.cliffc.aa.HM.HM9.Field.hm(), com.cliffc.aa.HM.HM.Field.hm(), com.cliffc.aa.node.CallEpiNode.ideal_reduce(), com.cliffc.aa.node.CallNode.ideal_reduce(), com.cliffc.aa.type.Bits< BitsRPC >.join(), com.cliffc.aa.type.Bits< BitsRPC >.make(), com.cliffc.aa.type.TypeMemPtr.max(), com.cliffc.aa.type.Bits< BitsRPC >.meet_nil(), com.cliffc.aa.type.TypeRPC.must_nil(), com.cliffc.aa.type.TypeFunPtr.must_nil(), com.cliffc.aa.type.TypeMemPtr.must_nil(), com.cliffc.aa.type.Bits< BitsRPC >.not_nil(), com.cliffc.aa.node.NewObjNode.promote_forward(), com.cliffc.aa.type.Bits< BitsRPC >.set(), com.cliffc.aa.node.FunNode.split_size(), com.cliffc.aa.type.TypeMemPtr.str(), com.cliffc.aa.type.Bits< BitsRPC >.str(), com.cliffc.aa.type.TypeRPC.test(), com.cliffc.aa.type.Bits< BitsRPC >.test(), com.cliffc.aa.TestParse.test_ptr0(), com.cliffc.aa.type.Bits< BitsRPC >.test_recur(), and com.cliffc.aa.type.TestType.testRecursive().

Here is the caller graph for this function:

◆ test_recur()

◆ toString()

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

Definition at line 133 of file Bits.java.

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

◆ tree()

abstract Tree<B> com.cliffc.aa.type.Bits< B extends Bits< B >.tree ( )
abstractpackage

Member Data Documentation

◆ _bits

◆ _con

◆ _hash


The documentation for this class was generated from the following file:
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.check
boolean check()
Definition: Bits.java:89
com.cliffc.aa.type.Bits.make
B make(boolean any, long[] bits)
Definition: Bits.java:154
com.cliffc.aa.type.Bits.mask
static long mask(long i)
Definition: Bits.java:200
com.cliffc.aa.type.Bits.test
static boolean test(long[] bits, int i)
Definition: Bits.java:224
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.Bits.join
static void join(Tree tree, long[] bits0, long[] bits1, long[] bits2)
Definition: Bits.java:349
com.cliffc.aa.type.Bits._hash
int _hash
Definition: Bits.java:70
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.max
int max()
Definition: Bits.java:284
com.cliffc.aa.type.Bits.and
static void and(long[] bits, long con)
Definition: Bits.java:282
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.Bits.tree
abstract Tree< B > tree()
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.meet
B meet(final B bs)
Definition: Bits.java:298
com.cliffc.aa.type.Bits.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.is_empty
boolean is_empty()
Definition: Bits.java:207