aa
com.cliffc.aa.Env.VStack Class Reference
Collaboration diagram for com.cliffc.aa.Env.VStack:
[legend]

Public Member Functions

TV2[] compact ()
 
boolean isEmpty ()
 
String toString ()
 

Public Attributes

Ary< String > _flds
 
final VStack _par
 
Ary< TV2_tvars
 

Package Functions

String add_var (String fld, TV2 tv)
 

Private Member Functions

 VStack (VStack par)
 

Detailed Description

Definition at line 256 of file Env.java.

Constructor & Destructor Documentation

◆ VStack()

com.cliffc.aa.Env.VStack.VStack ( VStack  par)
private

Definition at line 260 of file Env.java.

260 { _par=par; _flds = new Ary<>(new String[1],0); _tvars = new Ary<>(new TV2[1],0); }

References com.cliffc.aa.Env.VStack._flds, com.cliffc.aa.Env.VStack._par, and com.cliffc.aa.Env.VStack._tvars.

Member Function Documentation

◆ add_var()

String com.cliffc.aa.Env.VStack.add_var ( String  fld,
TV2  tv 
)
package

Definition at line 261 of file Env.java.

261 { _flds.push(fld); _tvars.push(tv); return fld; }

References com.cliffc.aa.Env.VStack._flds, com.cliffc.aa.Env.VStack._tvars, and com.cliffc.aa.util.Ary< E >.push().

Referenced by com.cliffc.aa.Parse.func(), and com.cliffc.aa.Parse.stmt().

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

◆ compact()

TV2 [] com.cliffc.aa.Env.VStack.compact ( )

Definition at line 267 of file Env.java.

267  {
268  int cnt=0;
269  for( VStack vs = this; vs!=null; vs=vs._par )
270  cnt += vs._tvars._len;
271  TV2[] tv2s = new TV2[cnt];
272  cnt=0;
273  for( VStack vs = this; vs!=null; vs=vs._par ) {
274  System.arraycopy(vs._tvars._es,0,tv2s,cnt,vs._tvars._len);
275  cnt += vs._tvars._len;
276  }
277  return tv2s;
278  }

References com.cliffc.aa.Env.VStack._par.

Referenced by com.cliffc.aa.Parse.func().

Here is the caller graph for this function:

◆ isEmpty()

boolean com.cliffc.aa.Env.VStack.isEmpty ( )

Definition at line 262 of file Env.java.

262  {
263  return _flds.isEmpty() && (_par == null || _par.isEmpty());
264  }

References com.cliffc.aa.Env.VStack._flds, com.cliffc.aa.Env.VStack._par, com.cliffc.aa.util.Ary< E >.isEmpty(), and com.cliffc.aa.Env.VStack.isEmpty().

Referenced by com.cliffc.aa.Env.VStack.isEmpty().

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

◆ toString()

String com.cliffc.aa.Env.VStack.toString ( )

Definition at line 281 of file Env.java.

281  {
282  // These types get large & complex; find all the dups up-front to allow
283  // for prettier printing. Uses '$A' style for repeats.
285  VBitSet bs = new VBitSet();
286  for( VStack vs = this; vs!=null ; vs=vs._par )
287  if( vs._tvars != null )
288  for( TV2 tv2 : vs._tvars )
289  if( tv2 != null ) tv2.find_dups(bs,dups,0);
290 
291  // Print stack of types, grouped by depth
292  bs.clr();
293  SB sb = new SB().p("[");
294  for( VStack vs = this; vs!=null ; vs=vs._par ) {
295  if( vs._tvars != null ) {
296  for( int i=0; i<vs._tvars._len; i++ ) {
297  sb.p(vs._flds.at(i)).p('=');
298  TV2 tv2 = vs._tvars.at(i);
299  if( tv2 !=null ) tv2.str(sb,bs,dups,false,0,0);
300  sb.p(", ");
301  }
302  if( vs._tvars._len>0 ) sb.unchar(2);
303  }
304  sb.p(" >> ");
305  }
306  if( _par!=null ) sb.unchar(4);
307  return sb.p("]").toString();
308  }

References com.cliffc.aa.Env.VStack._par, com.cliffc.aa.util.VBitSet.clr(), com.cliffc.aa.tvar.TV2.find_dups(), com.cliffc.aa.util.SB.p(), com.cliffc.aa.tvar.TV2.str(), com.cliffc.aa.util.SB.toString(), and com.cliffc.aa.util.SB.unchar().

Here is the call graph for this function:

Member Data Documentation

◆ _flds

◆ _par

◆ _tvars

Ary<TV2> com.cliffc.aa.Env.VStack._tvars

Definition at line 259 of file Env.java.

Referenced by com.cliffc.aa.Env.VStack.add_var(), and com.cliffc.aa.Env.VStack.VStack().


The documentation for this class was generated from the following file:
com.cliffc.aa.Env.VStack.isEmpty
boolean isEmpty()
Definition: Env.java:262
com.cliffc.aa.util.Ary.push
E push(E e)
Add element in amortized constant time.
Definition: Ary.java:58
com.cliffc.aa.util.Ary.isEmpty
boolean isEmpty()
Definition: Ary.java:20
com.cliffc.aa.util.Ary
Definition: Ary.java:11
com.cliffc.aa.util.VBitSet.clr
VBitSet clr()
Definition: VBitSet.java:9
com.cliffc.aa.util.SB.unchar
SB unchar()
Definition: SB.java:58
com.cliffc.aa.Env.VStack._tvars
Ary< TV2 > _tvars
Definition: Env.java:259
com.cliffc.aa.tvar.TV2.find_dups
final int find_dups(VBitSet bs, NonBlockingHashMapLong< String > dups, int scnt)
Definition: TV2.java:720
com.cliffc.aa.util.VBitSet
Definition: VBitSet.java:5
com.cliffc.aa.util.SB
Tight/tiny StringBuilder wrapper.
Definition: SB.java:8
com.cliffc.aa.tvar.TV2.str
final String str(int d)
Definition: TV2.java:707
com.cliffc.aa.Env.VStack._par
final VStack _par
Definition: Env.java:257
com.cliffc.aa.util.SB.p
SB p(String s)
Definition: SB.java:13
com.cliffc.aa.tvar.TV2
Definition: TV2.java:23
com.cliffc.aa.util.NonBlockingHashMapLong< String >
com.cliffc.aa.Env.VStack.VStack
VStack(VStack par)
Definition: Env.java:260
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62
com.cliffc.aa.Env.VStack._flds
Ary< String > _flds
Definition: Env.java:258