aa
com.cliffc.aa.HM.HM8.Struct Class Reference
Inheritance diagram for com.cliffc.aa.HM.HM8.Struct:
[legend]
Collaboration diagram for com.cliffc.aa.HM.HM8.Struct:
[legend]

Public Member Functions

String p ()
 
final String toString ()
 

Package Functions

 Struct (String[] ids, Syntax[] flds)
 
void add_work (Worklist work)
 
T2 debug_find ()
 
T2 find ()
 
boolean hm (Worklist work)
 
T2 lookup (String name)
 
boolean more_work (Worklist work)
 
final boolean more_work_impl (Worklist work)
 
final SB p0 (SB sb, VBitSet dups)
 
SB p1 (SB sb)
 
SB p2 (SB sb, VBitSet dups)
 
T2 post ()
 
T2 pre ()
 
void prep_lookup_deps (Ident id)
 
int prep_tree (Syntax par, VStack nongen, Worklist work)
 
final void prep_tree_impl (Syntax par, VStack nongen, Worklist work, T2 t)
 
SB str (SB sb)
 

Package Attributes

final BitsAlias _alias
 
final Syntax[] _flds
 
final String[] _ids
 
VStack _nongen
 
Syntax _par
 
T2 _post
 
T2 _pre
 
T2 _t
 

Detailed Description

Definition at line 576 of file HM8.java.

Constructor & Destructor Documentation

◆ Struct()

com.cliffc.aa.HM.HM8.Struct.Struct ( String[]  ids,
Syntax[]  flds 
)
package

Definition at line 580 of file HM8.java.

References com.cliffc.aa.HM.HM8.Struct._alias, com.cliffc.aa.HM.HM8.Struct._flds, com.cliffc.aa.HM.HM8.Struct._ids, com.cliffc.aa.type.BitsAlias.make0(), com.cliffc.aa.type.BitsAlias.new_alias(), and com.cliffc.aa.type.BitsAlias.REC.

Here is the call graph for this function:

Member Function Documentation

◆ add_work()

void com.cliffc.aa.HM.HM8.Struct.add_work ( Worklist  work)
package

Reimplemented from com.cliffc.aa.HM.HM8.Syntax.

Definition at line 644 of file HM8.java.

644  {
645  work.push(_par);
646  for( Syntax fld : _flds ) work.push(fld);
647  }

References com.cliffc.aa.HM.HM8.Struct._flds, com.cliffc.aa.HM.HM8.Syntax._par, and com.cliffc.aa.HM.HM8.Worklist.push().

Here is the call graph for this function:

◆ debug_find()

T2 com.cliffc.aa.HM.HM8.Syntax.debug_find ( )
packageinherited

Definition at line 249 of file HM8.java.

249 { return _t.debug_find(); } // Find, without the roll-up

References com.cliffc.aa.HM.HM8.Syntax._t, and com.cliffc.aa.HM.HM8.T2.debug_find().

Referenced by com.cliffc.aa.HM.HM8.hm().

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

◆ find()

T2 com.cliffc.aa.HM.HM8.Syntax.find ( )
packageinherited

Definition at line 245 of file HM8.java.

245  { // U-F find
246  T2 t = _t.find();
247  return t==_t ? t : (_t=t);
248  }

References com.cliffc.aa.HM.HM8.Syntax._t, and com.cliffc.aa.HM.HM8.T2.find().

Referenced by com.cliffc.aa.HM.HM8.T2._occurs_in(), com.cliffc.aa.HM.HM8.Lambda.add_work(), com.cliffc.aa.HM.HM8.Let.add_work(), com.cliffc.aa.HM.HM8.Ident.hm(), com.cliffc.aa.HM.HM8.Lambda.hm(), com.cliffc.aa.HM.HM8.Let.hm(), com.cliffc.aa.HM.HM8.Apply.hm(), com.cliffc.aa.HM.HM8.Struct.hm(), com.cliffc.aa.HM.HM8.Field.hm(), com.cliffc.aa.HM.HM8.Apply.is_if_nil(), and com.cliffc.aa.HM.HM8.Struct.prep_tree().

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

◆ hm()

boolean com.cliffc.aa.HM.HM8.Struct.hm ( Worklist  work)
package

Reimplemented from com.cliffc.aa.HM.HM8.Syntax.

Definition at line 596 of file HM8.java.

596  {
597  // U/F link pre/post memory with fields' memories
598  boolean progress = false, must_alloc=false;
599  progress |= pre().unify(_flds[0].pre(),work);
600  if( work==null && progress ) return true;
601  for( int i=1; i<_flds.length; i++ ) {
602  progress |= _flds[i-1].post().unify(_flds[i].pre(),work);
603  if( work==null && progress ) return true;
604  }
605  progress |= _flds[_flds.length-1].post().unify(post(),work);
606  if( work==null && progress ) return true;
607 
608  // Force result to be a struct with at least these fields.
609  // Do not allocate a T2 unless we need to pick up fields.
610  T2 rec = find();
611  for( String id : _ids )
612  if( Util.find(rec._ids, id) == -1 )
613  { must_alloc = true; break; }
614  if( must_alloc ) { // Must allocate.
615  if( work==null ) return true; // Will progress
616  T2[] t2s = new T2[_ids.length];
617  for( int i=0; i<_ids.length; i++ )
618  t2s[i] = _flds[i].find();
619  T2.make_struct(_ids,_alias,t2s).unify(rec,work);
620  rec=find();
621  progress = true;
622  }
623 
624  // Extra fields are unified with ALL since they are not created here.
625  for( int i=0; i<rec._ids.length; i++ ) {
626  if( Util.find(_ids,rec._ids[i])== -1 && rec.args(i)._con!=Type.ALL && !rec.args(i).is_err() ) {
627  if( work==null ) return true;
628  progress |= T2.make_base(Type.ALL).unify(rec.args(i),work);
629  }
630  }
631 
632  // Unify existing fields. Ignore extras on either side.
633  for( int i=0; i<_ids.length; i++ ) {
634  int idx = Util.find(rec._ids,_ids[i]);
635  if( idx!= -1 ) progress |= rec.args(idx).unify(_flds[i].find(),work);
636  if( work==null && progress ) return true;
637  }
638 
639  // Unify struct at alias into post-memory
640  progress |= _post.unify_rec(_alias.getbit(),rec,work);
641  return progress;
642  }

References com.cliffc.aa.HM.HM8.Struct._alias, com.cliffc.aa.HM.HM8.T2._con, com.cliffc.aa.HM.HM8.Struct._flds, com.cliffc.aa.HM.HM8.Struct._ids, com.cliffc.aa.HM.HM8.T2._ids, com.cliffc.aa.HM.HM8.Syntax._post, com.cliffc.aa.type.Type< T extends Type< T >.ALL, com.cliffc.aa.HM.HM8.T2.args(), com.cliffc.aa.util.Util.find(), com.cliffc.aa.HM.HM8.Syntax.find(), com.cliffc.aa.type.Bits< B extends Bits< B >.getbit(), com.cliffc.aa.HM.HM8.T2.is_err(), com.cliffc.aa.HM.HM8.T2.make_base(), com.cliffc.aa.HM.HM8.T2.make_struct(), com.cliffc.aa.HM.HM8.Syntax.post(), com.cliffc.aa.HM.HM8.Syntax.pre(), com.cliffc.aa.HM.HM8.T2.unify(), and com.cliffc.aa.HM.HM8.T2.unify_rec().

Here is the call graph for this function:

◆ lookup()

T2 com.cliffc.aa.HM.HM8.Struct.lookup ( String  name)
package

Reimplemented from com.cliffc.aa.HM.HM8.Syntax.

Definition at line 643 of file HM8.java.

643 { return _par==null ? null : _par.lookup(name); }

References com.cliffc.aa.HM.HM8.Syntax._par, and com.cliffc.aa.HM.HM8.Syntax.lookup().

Here is the call graph for this function:

◆ more_work()

boolean com.cliffc.aa.HM.HM8.Struct.more_work ( Worklist  work)
package

Reimplemented from com.cliffc.aa.HM.HM8.Syntax.

Definition at line 660 of file HM8.java.

660  {
661  if( !more_work_impl(work) ) return false;
662  for( Syntax fld : _flds )
663  if( !fld.more_work(work) )
664  return false;
665  return true;
666  }

References com.cliffc.aa.HM.HM8.Struct._flds, and com.cliffc.aa.HM.HM8.Syntax.more_work_impl().

Here is the call graph for this function:

◆ more_work_impl()

final boolean com.cliffc.aa.HM.HM8.Syntax.more_work_impl ( Worklist  work)
packageinherited

Definition at line 283 of file HM8.java.

283  {
284  boolean no_more_work = work.has(this) || !hm(null); // Either on worklist, or no-progress
285  return no_more_work;
286  }

References com.cliffc.aa.HM.HM8.Worklist.has(), and com.cliffc.aa.HM.HM8.Syntax.hm().

Referenced by com.cliffc.aa.HM.HM8.Con.more_work(), com.cliffc.aa.HM.HM8.Ident.more_work(), com.cliffc.aa.HM.HM8.Lambda.more_work(), com.cliffc.aa.HM.HM8.Let.more_work(), com.cliffc.aa.HM.HM8.Apply.more_work(), com.cliffc.aa.HM.HM8.Struct.more_work(), and com.cliffc.aa.HM.HM8.Field.more_work().

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

◆ p()

String com.cliffc.aa.HM.HM8.Syntax.p ( )
inherited

Definition at line 291 of file HM8.java.

291 { return p0(new SB(), new VBitSet()).toString(); }

References com.cliffc.aa.HM.HM8.Syntax.p0(), and com.cliffc.aa.util.SB.toString().

Here is the call graph for this function:

◆ p0()

final SB com.cliffc.aa.HM.HM8.Syntax.p0 ( SB  sb,
VBitSet  dups 
)
packageinherited

Definition at line 292 of file HM8.java.

292  {
293  _t.get_dups(dups);
294  _t.str(p1(sb.i()).p(" "), new VBitSet(),dups).nl();
295  return p2(sb.ii(1),dups).di(1);
296  }

References com.cliffc.aa.HM.HM8.Syntax._t, com.cliffc.aa.util.SB.di(), com.cliffc.aa.HM.HM8.T2.get_dups(), com.cliffc.aa.util.SB.i(), com.cliffc.aa.util.SB.ii(), com.cliffc.aa.util.SB.nl(), com.cliffc.aa.util.SB.p(), com.cliffc.aa.HM.HM8.Syntax.p1(), com.cliffc.aa.HM.HM8.Syntax.p2(), and com.cliffc.aa.HM.HM8.T2.str().

Referenced by com.cliffc.aa.HM.HM8.Syntax.p(), com.cliffc.aa.HM.HM8.Lambda.p2(), com.cliffc.aa.HM.HM8.Let.p2(), com.cliffc.aa.HM.HM8.Apply.p2(), com.cliffc.aa.HM.HM8.Struct.p2(), and com.cliffc.aa.HM.HM8.Field.p2().

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

◆ p1()

SB com.cliffc.aa.HM.HM8.Struct.p1 ( SB  sb)
package

Reimplemented from com.cliffc.aa.HM.HM8.Syntax.

Definition at line 590 of file HM8.java.

590 { return _alias.str(sb.p('*')).p("@{ ... } "); }

References com.cliffc.aa.HM.HM8.Struct._alias, com.cliffc.aa.util.SB.p(), and com.cliffc.aa.type.Bits< B extends Bits< B >.str().

Here is the call graph for this function:

◆ p2()

SB com.cliffc.aa.HM.HM8.Struct.p2 ( SB  sb,
VBitSet  dups 
)
package

Reimplemented from com.cliffc.aa.HM.HM8.Syntax.

Definition at line 591 of file HM8.java.

591  {
592  for( int i=0; i<_ids.length; i++ )
593  _flds[i].p0(sb.p(_ids[i]).p(" = "),dups);
594  return sb;
595  }

References com.cliffc.aa.HM.HM8.Struct._flds, com.cliffc.aa.HM.HM8.Struct._ids, com.cliffc.aa.util.SB.p(), and com.cliffc.aa.HM.HM8.Syntax.p0().

Here is the call graph for this function:

◆ post()

T2 com.cliffc.aa.HM.HM8.Syntax.post ( )
packageinherited

Definition at line 254 of file HM8.java.

254  {
255  T2 t = _post.find();
256  return t==_post ? t : (_post=t);
257  }

References com.cliffc.aa.HM.HM8.Syntax._post, and com.cliffc.aa.HM.HM8.T2.find().

Referenced by com.cliffc.aa.HM.HM8.Lambda.hm(), com.cliffc.aa.HM.HM8.Let.hm(), com.cliffc.aa.HM.HM8.Apply.hm(), com.cliffc.aa.HM.HM8.Struct.hm(), and com.cliffc.aa.HM.HM8.Field.hm().

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

◆ pre()

T2 com.cliffc.aa.HM.HM8.Syntax.pre ( )
packageinherited

Definition at line 250 of file HM8.java.

250  {
251  T2 t = _pre.find();
252  return t==_pre ? t : (_pre=t);
253  }

References com.cliffc.aa.HM.HM8.Syntax._pre, and com.cliffc.aa.HM.HM8.T2.find().

Referenced by com.cliffc.aa.HM.HM8.Lambda.hm(), com.cliffc.aa.HM.HM8.Let.hm(), com.cliffc.aa.HM.HM8.Apply.hm(), com.cliffc.aa.HM.HM8.Struct.hm(), and com.cliffc.aa.HM.HM8.Field.hm().

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

◆ prep_lookup_deps()

void com.cliffc.aa.HM.HM8.Struct.prep_lookup_deps ( Ident  id)
package

Reimplemented from com.cliffc.aa.HM.HM8.Syntax.

Definition at line 659 of file HM8.java.

659 { }

◆ prep_tree()

int com.cliffc.aa.HM.HM8.Struct.prep_tree ( Syntax  par,
VStack  nongen,
Worklist  work 
)
package

Reimplemented from com.cliffc.aa.HM.HM8.Syntax.

Definition at line 648 of file HM8.java.

648  {
649  T2[] t2s = new T2[_ids.length];
650  prep_tree_impl(par, nongen, work, T2.make_struct(_ids,_alias,t2s));
651  prep_tree_impl(par, nongen, work, T2.make_struct(new String[0],_alias,new T2[0]));
652  int cnt = 1; // One for self
653  for( int i=0; i<_flds.length; i++ ) { // Prep all sub-fields
654  cnt += _flds[i].prep_tree(this,nongen,work);
655  t2s[i] = _flds[i].find();
656  }
657  return cnt;
658  }

References com.cliffc.aa.HM.HM8.Struct._alias, com.cliffc.aa.HM.HM8.Struct._flds, com.cliffc.aa.HM.HM8.Struct._ids, com.cliffc.aa.HM.HM8.Syntax.find(), com.cliffc.aa.HM.HM8.T2.make_struct(), com.cliffc.aa.HM.HM8.Syntax.prep_tree(), and com.cliffc.aa.HM.HM8.Syntax.prep_tree_impl().

Here is the call graph for this function:

◆ prep_tree_impl()

final void com.cliffc.aa.HM.HM8.Syntax.prep_tree_impl ( Syntax  par,
VStack  nongen,
Worklist  work,
T2  t 
)
packageinherited

Definition at line 267 of file HM8.java.

267  {
268  _par=par;
269  _pre = T2.make_mem();
270  _t=t;
271  _post = T2.make_mem();
272  _nongen = nongen;
273  work.push(this);
274  }

References com.cliffc.aa.HM.HM8.Syntax._nongen, com.cliffc.aa.HM.HM8.Syntax._par, com.cliffc.aa.HM.HM8.Syntax._post, com.cliffc.aa.HM.HM8.Syntax._pre, com.cliffc.aa.HM.HM8.Syntax._t, com.cliffc.aa.HM.HM8.T2.make_mem(), and com.cliffc.aa.HM.HM8.Worklist.push().

Referenced by com.cliffc.aa.HM.HM8.Con.prep_tree(), com.cliffc.aa.HM.HM8.Ident.prep_tree(), com.cliffc.aa.HM.HM8.Lambda.prep_tree(), com.cliffc.aa.HM.HM8.Let.prep_tree(), com.cliffc.aa.HM.HM8.Apply.prep_tree(), com.cliffc.aa.HM.HM8.Struct.prep_tree(), and com.cliffc.aa.HM.HM8.Field.prep_tree().

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

◆ str()

SB com.cliffc.aa.HM.HM8.Struct.str ( SB  sb)
package

Reimplemented from com.cliffc.aa.HM.HM8.Syntax.

Definition at line 581 of file HM8.java.

581  {
582  _alias.str(sb.p('*')).p("@{");
583  for( int i=0; i<_ids.length; i++ ) {
584  sb.p(' ').p(_ids[i]).p(" = ");
585  _flds[i].str(sb);
586  if( i < _ids.length-1 ) sb.p(',');
587  }
588  return sb.p("}");
589  }

References com.cliffc.aa.HM.HM8.Struct._alias, com.cliffc.aa.HM.HM8.Struct._flds, com.cliffc.aa.HM.HM8.Struct._ids, com.cliffc.aa.util.SB.p(), com.cliffc.aa.type.Bits< B extends Bits< B >.str(), and com.cliffc.aa.HM.HM8.Syntax.str().

Here is the call graph for this function:

◆ toString()

final String com.cliffc.aa.HM.HM8.Syntax.toString ( )
inherited

Definition at line 288 of file HM8.java.

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

References com.cliffc.aa.HM.HM8.Syntax.str(), and com.cliffc.aa.util.SB.toString().

Here is the call graph for this function:

Member Data Documentation

◆ _alias

◆ _flds

◆ _ids

◆ _nongen

VStack com.cliffc.aa.HM.HM8.Syntax._nongen
packageinherited

◆ _par

◆ _post

◆ _pre

◆ _t


The documentation for this class was generated from the following file:
com.cliffc.aa.type.Bits.str
SB str(SB sb)
Definition: Bits.java:134
com.cliffc.aa.HM.HM8.Syntax.hm
abstract boolean hm(Worklist work)
com.cliffc.aa.util.Util.find
static int find(int[] es, int e)
Definition: Util.java:6
com.cliffc.aa.util.SB.ii
SB ii(int i)
Definition: SB.java:44
com.cliffc.aa.HM.HM8.T2.make_struct
static T2 make_struct(String[] ids, BitsAlias aliases, T2[] flds)
Definition: HM8.java:750
com.cliffc.aa.util.SB.di
SB di(int i)
Definition: SB.java:46
com.cliffc.aa.HM.HM8.Syntax._par
Syntax _par
Definition: HM8.java:240
com.cliffc.aa.HM.HM8.T2.get_dups
VBitSet get_dups(VBitSet dups)
Definition: HM8.java:1196
com.cliffc.aa.type.Type
an implementation of language AA
Definition: Type.java:94
com.cliffc.aa.HM.HM8.Struct._alias
final BitsAlias _alias
Definition: HM8.java:577
com.cliffc.aa.type.BitsAlias
Definition: BitsAlias.java:8
com.cliffc.aa.HM.HM8.Struct._ids
final String[] _ids
Definition: HM8.java:578
com.cliffc.aa.HM.HM8.T2.unify
boolean unify(T2 that, Worklist work)
Definition: HM8.java:841
com.cliffc.aa.HM.HM8.Struct._flds
final Syntax[] _flds
Definition: HM8.java:579
com.cliffc.aa.type.BitsAlias.new_alias
static int new_alias(int par)
Definition: BitsAlias.java:75
com.cliffc.aa.type.Type.ALL
static final Type ALL
Definition: Type.java:324
com.cliffc.aa.HM.HM8.T2.make_mem
static T2 make_mem()
Definition: HM8.java:751
com.cliffc.aa.type.BitsAlias.REC
static final int REC
Definition: BitsAlias.java:25
com.cliffc.aa.HM.HM8.Syntax._nongen
VStack _nongen
Definition: HM8.java:241
com.cliffc.aa.HM.HM8.T2.debug_find
T2 debug_find()
Definition: HM8.java:777
com.cliffc.aa.HM.HM8.Syntax._pre
T2 _pre
Definition: HM8.java:242
com.cliffc.aa.HM.HM8.Syntax.lookup
abstract T2 lookup(String name)
com.cliffc.aa.HM.HM8.Syntax._post
T2 _post
Definition: HM8.java:244
com.cliffc.aa.util.Util
Definition: Util.java:5
com.cliffc.aa.HM.HM8.Syntax.post
T2 post()
Definition: HM8.java:254
com.cliffc.aa.HM.HM8.T2.str
SB str(SB sb, VBitSet visit, VBitSet dups)
Definition: HM8.java:1209
com.cliffc.aa.HM.HM8.Syntax.pre
T2 pre()
Definition: HM8.java:250
com.cliffc.aa.type.Bits.getbit
int getbit()
Definition: Bits.java:202
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.HM.HM8.Syntax.p2
abstract SB p2(SB sb, VBitSet dups)
com.cliffc.aa.HM.HM8.Syntax.p1
abstract SB p1(SB sb)
com.cliffc.aa.HM.HM8.Syntax.prep_tree_impl
final void prep_tree_impl(Syntax par, VStack nongen, Worklist work, T2 t)
Definition: HM8.java:267
com.cliffc.aa.HM.HM8.T2.unify_rec
boolean unify_rec(int alias, T2 str, Worklist work)
Definition: HM8.java:1154
com.cliffc.aa.util.SB.nl
SB nl()
Definition: SB.java:48
com.cliffc.aa.HM.HM8.Syntax._t
T2 _t
Definition: HM8.java:243
com.cliffc.aa.type.BitsAlias.make0
static BitsAlias make0(int bit)
Definition: BitsAlias.java:72
com.cliffc.aa.util.SB.p
SB p(String s)
Definition: SB.java:13
com.cliffc.aa.HM.HM8.Syntax.p0
final SB p0(SB sb, VBitSet dups)
Definition: HM8.java:292
com.cliffc.aa.HM.HM8.Syntax.prep_tree
abstract int prep_tree(Syntax par, VStack nongen, Worklist work)
com.cliffc.aa.HM.HM8.Syntax.str
abstract SB str(SB sb)
com.cliffc.aa.HM.HM8.Syntax.find
T2 find()
Definition: HM8.java:245
com.cliffc.aa.util.SB.i
SB i(int d)
Definition: SB.java:38
com.cliffc.aa.HM.HM8.T2.find
T2 find()
Definition: HM8.java:788
com.cliffc.aa.HM.HM8.Syntax.more_work_impl
final boolean more_work_impl(Worklist work)
Definition: HM8.java:283
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62