aa
com.cliffc.aa.HM.HM7.T2 Class Reference
Collaboration diagram for com.cliffc.aa.HM.HM7.T2:
[legend]

Public Member Functions

String p ()
 
String toString ()
 

Package Functions

boolean _cycle_equals (T2 t)
 
VBitSet _get_dups (VBitSet visit, VBitSet dups)
 
boolean _nongen_in (VStack nongen)
 
boolean _occurs_in (Syntax syn)
 
boolean _occurs_in_type (T2 x)
 
void add_deps_work (Worklist work)
 
T2 args (int i)
 
T2 copy ()
 
boolean cycle_equals (T2 t)
 
T2 find ()
 
boolean fresh_unify (T2 that, VStack nongen, Worklist work)
 
VBitSet get_dups (VBitSet dups)
 
boolean is_base ()
 
boolean is_fun ()
 
boolean is_leaf ()
 
boolean is_nil ()
 
boolean is_struct ()
 
boolean isa (String name)
 
boolean no_uf ()
 
boolean nongen_in (VStack syn)
 
boolean occurs_in (Syntax syn)
 
boolean occurs_in_type (T2 x)
 
boolean or0 (T2 that, Worklist work)
 
String p (VBitSet dups)
 
T2 push_update (Ary< Syntax > as)
 
void push_update (Syntax a)
 
SB str (SB sb, VBitSet visit, VBitSet dups)
 
boolean unify (T2 that, Worklist work)
 
boolean union (T2 that, Worklist work)
 

Static Package Functions

static T2 make_base (Type con)
 
static T2 make_fun (T2... args)
 
static T2 make_leaf ()
 
static T2 make_nil ()
 
static T2 make_struct (String[] ids, T2[] flds)
 
static T2 prim (String name, T2... args)
 
static void reset ()
 

Package Attributes

T2[] _args
 
Type _con
 
Ary< Syntax_deps
 
String[] _ids
 
String _name
 
final int _uid
 

Static Package Attributes

static final VBitSet UPDATE_VISIT = new VBitSet()
 

Private Member Functions

 T2 (@NotNull String name, Type con, String[] ids, T2 @NotNull ... args)
 
boolean _cycle_equals_struct (T2 t)
 
T2 _fresh (VStack nongen)
 
boolean _fresh_unify (T2 that, VStack nongen, Worklist work)
 
boolean _fresh_unify_struct (T2 that, VStack nongen, Worklist work)
 
SB _p (SB sb, VBitSet visit, VBitSet dups)
 
boolean _unify (T2 that, Worklist work)
 
void add_deps_work_impl (Worklist work)
 
void add_fld (String id, T2 fld, Worklist work)
 
long dbl_uid (T2 t)
 
boolean fresh_base (T2 that, Worklist work)
 
void push_update_impl (Syntax a)
 
boolean unify_base (T2 that, Worklist work)
 
boolean vput (T2 that, boolean progress)
 

Static Private Member Functions

static SB str (SB sb, VBitSet visit, T2 t, VBitSet dups)
 

Static Private Attributes

static final HashMap< T2, T2CDUPS = new HashMap<>()
 
static int CNT =0
 
static final HashMap< Long, T2DUPS = new HashMap<>()
 
static final VBitSet ODUPS = new VBitSet()
 
static final HashMap< T2, T2VARS = new HashMap<>()
 
static int VCNT
 
static final HashMap< T2, Integer > VNAMES = new HashMap<>()
 

Detailed Description

Definition at line 621 of file HM7.java.

Constructor & Destructor Documentation

◆ T2()

com.cliffc.aa.HM.HM7.T2.T2 ( @NotNull String  name,
Type  con,
String[]  ids,
T2 @NotNull ...  args 
)
private

Definition at line 651 of file HM7.java.

651  {
652  _uid = CNT++;
653  _name= name;
654  _con = con;
655  _ids = ids;
656  _args= args;
657  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2._ids, com.cliffc.aa.HM.HM7.T2._name, com.cliffc.aa.HM.HM7.T2._uid, com.cliffc.aa.HM.HM7.T2.args(), and com.cliffc.aa.HM.HM7.T2.CNT.

Referenced by com.cliffc.aa.HM.HM7.T2.copy(), com.cliffc.aa.HM.HM7.T2.make_base(), com.cliffc.aa.HM.HM7.T2.make_fun(), com.cliffc.aa.HM.HM7.T2.make_leaf(), com.cliffc.aa.HM.HM7.T2.make_nil(), com.cliffc.aa.HM.HM7.T2.make_struct(), and com.cliffc.aa.HM.HM7.T2.prim().

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

Member Function Documentation

◆ _cycle_equals()

boolean com.cliffc.aa.HM.HM7.T2._cycle_equals ( T2  t)
package

Definition at line 968 of file HM7.java.

968  {
969  assert no_uf() && t.no_uf();
970  if( this==t ) return true;
971  if( is_base() && t.is_base() )
972  return _con==t._con; // Base-cases have to be completely identical
973  if( !Util.eq(_name,t._name) || // Wrong type-var names
974  _args.length != t._args.length ) // Mismatched sizes
975  return false;
976  if( _args==t._args ) return true;
977  // Cycles stall the equal/unequal decision until we see a difference.
978  T2 tc = CDUPS.get(this);
979  if( tc!=null )
980  return tc==t; // Cycle check; true if both cycling the same
981  CDUPS.put(this,t);
982  if( is_struct() ) // Struct equality honors field names without regard to order
983  return _cycle_equals_struct(t);
984  for( int i=0; i<_args.length; i++ )
985  if( !args(i)._cycle_equals(t.args(i)) )
986  return false;
987  return true;
988  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2._cycle_equals_struct(), com.cliffc.aa.HM.HM7.T2._name, com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.HM.HM7.T2.CDUPS, com.cliffc.aa.util.Util.eq(), com.cliffc.aa.HM.HM7.T2.is_base(), com.cliffc.aa.HM.HM7.T2.is_struct(), and com.cliffc.aa.HM.HM7.T2.no_uf().

Referenced by com.cliffc.aa.HM.HM7.T2._cycle_equals_struct(), and com.cliffc.aa.HM.HM7.T2.cycle_equals().

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

◆ _cycle_equals_struct()

boolean com.cliffc.aa.HM.HM7.T2._cycle_equals_struct ( T2  t)
private

Definition at line 990 of file HM7.java.

990  {
991  assert is_struct() && t.is_struct();
992  if( _con != t._con ) return false;
993  for( int i=0; i<_args.length; i++ ) {
994  int idx = Util.find(t._ids,_ids[i]);
995  if( idx==-1 || !args(i)._cycle_equals(t.args(idx)) )
996  return false;
997  }
998  return true;
999  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2._cycle_equals(), com.cliffc.aa.HM.HM7.T2._ids, com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.util.Util.find(), and com.cliffc.aa.HM.HM7.T2.is_struct().

Referenced by com.cliffc.aa.HM.HM7.T2._cycle_equals().

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

◆ _fresh()

T2 com.cliffc.aa.HM.HM7.T2._fresh ( VStack  nongen)
private

Definition at line 894 of file HM7.java.

894  {
895  assert no_uf();
896  T2 rez = VARS.get(this);
897  if( rez!=null ) return rez; // Been there, done that
898 
899  if( is_leaf() ) {
900  // If occurs_in lexical scope, keep same variable, else make a new leaf
901  T2 t = nongen_in(nongen) ? this : T2.make_leaf();
902  VARS.put(this,t);
903  return t;
904  } else { // Structure is deep-replicated
905  T2 t = copy();
906  VARS.put(this,t); // Stop cyclic structure looping
907  for( int i=0; i<_args.length; i++ )
908  t._args[i] = args(i)._fresh(nongen);
909  return t;
910  }
911  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._fresh(), com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.HM.HM7.T2.copy(), com.cliffc.aa.HM.HM7.T2.is_leaf(), com.cliffc.aa.HM.HM7.T2.make_leaf(), com.cliffc.aa.HM.HM7.T2.no_uf(), com.cliffc.aa.HM.HM7.T2.nongen_in(), and com.cliffc.aa.HM.HM7.T2.VARS.

Referenced by com.cliffc.aa.HM.HM7.T2._fresh(), com.cliffc.aa.HM.HM7.T2._fresh_unify(), and com.cliffc.aa.HM.HM7.T2._fresh_unify_struct().

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

◆ _fresh_unify()

boolean com.cliffc.aa.HM.HM7.T2._fresh_unify ( T2  that,
VStack  nongen,
Worklist  work 
)
private

Definition at line 830 of file HM7.java.

830  {
831  assert no_uf() && that.no_uf();
832  T2 prior = VARS.get(this);
833  if( prior!=null ) // Been there, done that
834  return prior.find()._unify(that,work); // Also 'prior' needs unification with 'that'
835  if( cycle_equals(that) ) return vput(that,false);
836 
837  // Attempting to pre-compute occurs_in, by computing 'is_fresh' in the
838  // Ident.hm() call does NOT work. The 'is_fresh' is for the top-layer
839  // only, not the internal layers. As soon as we structural recurse down
840  // a layer, 'is_fresh' does not correlate with an occurs_in check.
841  if( nongen_in(nongen) ) return vput(that,_unify(that,work)); // Famous 'occurs-check', switch to normal unify
842  if( this.is_leaf() ) return vput(that,false); // Lazy map LHS tvar to RHS
843  if( that.is_leaf() ) // RHS is a tvar; union with a deep copy of LHS
844  return work==null || vput(that,that.union(_fresh(nongen),work));
845  // Bases MEET cons in RHS
846  if( is_base() && that.is_base() ) return vput(that,fresh_base(that,work));
847  // Unify struct with nil
848  if( is_nil() && that.is_struct() ) return vput(that,or0(that,work));
849  if( that.is_nil() && is_struct() )
850  return work==null || vput(that,that.or0(_fresh(nongen),work));
851 
852  if( !Util.eq(_name,that._name) ||
853  (!is_struct() && _args.length != that._args.length) )
854  throw new RuntimeException("Cannot unify "+this+" and "+that);
855 
856  // Structural recursion unification, lazy on LHS
857  vput(that,false); // Early set, to stop cycles
858  boolean progress = false;
859  if( is_struct() )
860  progress = _fresh_unify_struct(that,nongen,work);
861  else {
862  for( int i=0; i<_args.length; i++ ) {
863  progress |= args(i)._fresh_unify(that.args(i),nongen,work);
864  if( progress && work==null ) return true;
865  }
866  }
867  return progress;
868  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._fresh(), com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._fresh_unify_struct(), com.cliffc.aa.HM.HM7.T2._name, com.cliffc.aa.HM.HM7.T2._unify(), com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.HM.HM7.T2.cycle_equals(), com.cliffc.aa.util.Util.eq(), com.cliffc.aa.HM.HM7.T2.find(), com.cliffc.aa.HM.HM7.T2.fresh_base(), com.cliffc.aa.HM.HM7.T2.is_base(), com.cliffc.aa.HM.HM7.T2.is_leaf(), com.cliffc.aa.HM.HM7.T2.is_nil(), com.cliffc.aa.HM.HM7.T2.is_struct(), com.cliffc.aa.HM.HM7.T2.no_uf(), com.cliffc.aa.HM.HM7.T2.nongen_in(), com.cliffc.aa.HM.HM7.T2.or0(), com.cliffc.aa.HM.HM7.T2.union(), com.cliffc.aa.HM.HM7.T2.VARS, and com.cliffc.aa.HM.HM7.T2.vput().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._fresh_unify_struct(), and com.cliffc.aa.HM.HM7.T2.fresh_unify().

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

◆ _fresh_unify_struct()

boolean com.cliffc.aa.HM.HM7.T2._fresh_unify_struct ( T2  that,
VStack  nongen,
Worklist  work 
)
private

Definition at line 871 of file HM7.java.

871  {
872  assert is_struct() && that.is_struct();
873  if( _con!=null && that._con==null ) {
874  if( work==null ) return true; // Will progress
875  that._con = Type.NIL; // Allow nil
876  }
877  boolean progress = false;
878  for( int i=0; i<_args.length; i++ ) {
879  int idx = Util.find(that._ids,_ids[i]);
880  if( idx == -1 ) { // Missing field on RHS
881  if( work==null ) return true; // Will definitely make progress
882  progress = true;
883  that.add_fld(_ids[i],args(i)._fresh(nongen), work);
884  } else
885  progress |= args(i)._fresh_unify(that.args(idx),nongen,work);
886  if( progress && work==null ) return true;
887  }
888  return progress;
889  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2._fresh(), com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._ids, com.cliffc.aa.HM.HM7.T2.add_fld(), com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.util.Util.find(), com.cliffc.aa.HM.HM7.T2.is_struct(), and com.cliffc.aa.type.Type< T extends Type< T >.NIL.

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify().

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

◆ _get_dups()

VBitSet com.cliffc.aa.HM.HM7.T2._get_dups ( VBitSet  visit,
VBitSet  dups 
)
package

Definition at line 1034 of file HM7.java.

1034  {
1035  if( visit.tset(_uid) && no_uf() ) dups.set(_uid);
1036  else
1037  for( T2 t : _args )
1038  if( t!=null )
1039  t._get_dups(visit,dups);
1040  return dups;
1041  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._uid, com.cliffc.aa.HM.HM7.T2.no_uf(), and com.cliffc.aa.util.VBitSet.tset().

Referenced by com.cliffc.aa.HM.HM7.T2.get_dups().

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

◆ _nongen_in()

boolean com.cliffc.aa.HM.HM7.T2._nongen_in ( VStack  nongen)
package

Definition at line 953 of file HM7.java.

953  {
954  for( T2 t2 : nongen )
955  if( _occurs_in_type(t2.find()) )
956  return true;
957  return false;
958  }

References com.cliffc.aa.HM.HM7.T2._occurs_in_type().

Referenced by com.cliffc.aa.HM.HM7.T2.nongen_in().

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

◆ _occurs_in()

boolean com.cliffc.aa.HM.HM7.T2._occurs_in ( Syntax  syn)
package

Definition at line 928 of file HM7.java.

928  {
929  for( ; syn!=null; syn=syn._par )
930  if( _occurs_in_type(syn.find()) )
931  return true;
932  return false;
933  }

References com.cliffc.aa.HM.HM7.T2._occurs_in_type(), com.cliffc.aa.HM.HM7.Syntax._par, and com.cliffc.aa.HM.HM7.Syntax.find().

Referenced by com.cliffc.aa.HM.HM7.T2.occurs_in().

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

◆ _occurs_in_type()

boolean com.cliffc.aa.HM.HM7.T2._occurs_in_type ( T2  x)
package

Definition at line 935 of file HM7.java.

935  {
936  assert no_uf() && x.no_uf();
937  if( x==this ) return true;
938  if( ODUPS.tset(x._uid) ) return false; // Been there, done that
939  if( !x.is_leaf() )
940  for( int i=0; i<x._args.length; i++ )
941  if( _occurs_in_type(x.args(i)) )
942  return true;
943  return false;
944  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._uid, com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.HM.HM7.T2.is_leaf(), com.cliffc.aa.HM.HM7.T2.no_uf(), com.cliffc.aa.HM.HM7.T2.ODUPS, and com.cliffc.aa.util.VBitSet.tset().

Referenced by com.cliffc.aa.HM.HM7.T2._nongen_in(), com.cliffc.aa.HM.HM7.T2._occurs_in(), and com.cliffc.aa.HM.HM7.T2.occurs_in_type().

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

◆ _p()

SB com.cliffc.aa.HM.HM7.T2._p ( SB  sb,
VBitSet  visit,
VBitSet  dups 
)
private

Definition at line 1086 of file HM7.java.

1086  {
1087  assert no_uf();
1088  if( is_base() ) return sb.p(_con instanceof TypeMemPtr ? "str" : _con.toString() );
1089  if( is_leaf() || dups.get(_uid) ) { // Leafs or Duplicates? Take some effort to pretty-print cycles
1090  Integer ii = VNAMES.get(this);
1091  if( ii==null ) VNAMES.put(this,ii=VCNT++);
1092  // 2nd and later visits use the short form
1093  boolean later = !is_leaf() && visit.tset(_uid);
1094  if( later ) sb.p('$');
1095  char c = (char)('A'+ii);
1096  if( c<'V' ) sb.p(c); else sb.p("V"+ii);
1097  if( is_leaf() || later ) return sb;
1098  // First visit prints the V._uid and the type
1099  sb.p(':');
1100  }
1101 
1102  // Special printing for functions: { arg -> body }
1103  if( is_fun() ) {
1104  sb.p("{ ");
1105  for( int i=0; i<_args.length-1; i++ )
1106  args(i)._p(sb,visit,dups).p(" ");
1107  return args(_args.length-1)._p(sb.p("-> "),visit,dups).p(" }");
1108  }
1109 
1110  // Special printing for structures: @{ fld0 = body, fld1 = body, ... }
1111  if( is_struct() ) {
1112  sb.p("@{");
1113  for( int i=0; i<_ids.length; i++ )
1114  args(i)._p(sb.p(' ').p(_ids[i]).p(" = "),visit,dups).p(',');
1115  sb.unchar().p("}");
1116  if( _con==Type.NIL ) sb.p('?');
1117  return sb;
1118  }
1119 
1120  // Generic structural T2: (fun arg0 arg1...)
1121  sb.p("(").p(_name).p(" ");
1122  for( int i=0; i<_args.length; i++ ) args(i)._p(sb,visit,dups).p(" ");
1123  return sb.unchar().p(")");
1124  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2._ids, com.cliffc.aa.HM.HM7.T2._name, com.cliffc.aa.HM.HM7.T2._p(), com.cliffc.aa.HM.HM7.T2._uid, com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.HM.HM7.T2.is_base(), com.cliffc.aa.HM.HM7.T2.is_fun(), com.cliffc.aa.HM.HM7.T2.is_leaf(), com.cliffc.aa.HM.HM7.T2.is_struct(), com.cliffc.aa.type.Type< T extends Type< T >.NIL, com.cliffc.aa.HM.HM7.T2.no_uf(), com.cliffc.aa.util.SB.p(), com.cliffc.aa.type.Type< T extends Type< T >.toString(), com.cliffc.aa.util.VBitSet.tset(), com.cliffc.aa.util.SB.unchar(), com.cliffc.aa.HM.HM7.T2.VCNT, and com.cliffc.aa.HM.HM7.T2.VNAMES.

Referenced by com.cliffc.aa.HM.HM7.T2._p(), and com.cliffc.aa.HM.HM7.T2.p().

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

◆ _unify()

boolean com.cliffc.aa.HM.HM7.T2._unify ( T2  that,
Worklist  work 
)
private

Definition at line 735 of file HM7.java.

735  {
736  assert no_uf() && that.no_uf();
737  if( this==that ) return false;
738 
739  // two leafs union in either order, so keep lower uid
740  if( is_leaf() && that.is_leaf() && _uid<that._uid ) return that.union(this,work);
741  if( is_leaf() ) return union(that,work);
742  if( that.is_leaf() ) return that.union(this,work);
743  if( is_base() && that.is_base() ) return unify_base(that,work);
744  // Unify struct with nil
745  if( is_nil() && that.is_struct() ) return or0(that,work);
746  if( that.is_nil() && is_struct() ) return that.or0(this,work);
747 
748  if( !Util.eq(_name,that._name) )
749  throw new RuntimeException("Cannot unify "+this+" and "+that);
750  assert _args!=that._args; // Not expecting to share _args and not 'this'
751  if( !is_struct() && _args.length != that._args.length )
752  throw new RuntimeException("Cannot unify "+this+" and "+that);
753 
754  // Cycle check
755  long luid = dbl_uid(that);
756  T2 rez = DUPS.get(luid);
757  assert rez==null || rez==that;
758  if( rez!=null ) return false; // Been there, done that
759  DUPS.put(luid,that); // Close cycles
760 
761  if( work==null ) return true; // Here we definitely make progress; bail out early if just testing
762 
763  // Structural recursion unification.
764  // Structs unify only on matching fields, and add missing fields.
765  if( is_struct() ) {
766  // Unification for structs is more complicated; args are aligned via
767  // field names and not by position.
768  for( int i=0; i<_ids.length; i++ ) { // For all fields in LHS
769  int idx = Util.find(that._ids,_ids[i]);
770  if( idx==-1 ) that.add_fld(_ids[i],args(i), work); // Extend 'that' with matching field from 'this'
771  else args(i)._unify(that.args(idx),work); // Unify matching field
772  that = that.find(); // Recursively, might have already rolled this up
773  }
774  if( _con!=null && that._con==null ) that._con=Type.NIL;
775  if( this==that ) return true; // Might have unioned this-into-that recursively, exit now with progress
776  } else {
777  for( int i=0; i<_args.length; i++ ) // For all fields in LHS
778  args(i)._unify(that.args(i),work);
779  }
780  return union(that,work);
781  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2._ids, com.cliffc.aa.HM.HM7.T2._name, com.cliffc.aa.HM.HM7.T2._uid, com.cliffc.aa.HM.HM7.T2._unify(), com.cliffc.aa.HM.HM7.T2.add_fld(), com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.HM.HM7.T2.dbl_uid(), com.cliffc.aa.HM.HM7.T2.DUPS, com.cliffc.aa.util.Util.eq(), com.cliffc.aa.util.Util.find(), com.cliffc.aa.HM.HM7.T2.find(), com.cliffc.aa.HM.HM7.T2.is_base(), com.cliffc.aa.HM.HM7.T2.is_leaf(), com.cliffc.aa.HM.HM7.T2.is_nil(), com.cliffc.aa.HM.HM7.T2.is_struct(), com.cliffc.aa.type.Type< T extends Type< T >.NIL, com.cliffc.aa.HM.HM7.T2.no_uf(), com.cliffc.aa.HM.HM7.T2.or0(), com.cliffc.aa.HM.HM7.T2.unify_base(), and com.cliffc.aa.HM.HM7.T2.union().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._unify(), and com.cliffc.aa.HM.HM7.T2.unify().

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

◆ add_deps_work()

void com.cliffc.aa.HM.HM7.T2.add_deps_work ( Worklist  work)
package

Definition at line 1018 of file HM7.java.

1018 { assert UPDATE_VISIT.isEmpty(); add_deps_work_impl(work); UPDATE_VISIT.clear(); }

References com.cliffc.aa.HM.HM7.T2.add_deps_work_impl(), and com.cliffc.aa.HM.HM7.T2.UPDATE_VISIT.

Referenced by com.cliffc.aa.HM.HM7.Ident.add_occurs().

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

◆ add_deps_work_impl()

void com.cliffc.aa.HM.HM7.T2.add_deps_work_impl ( Worklist  work)
private

Definition at line 1019 of file HM7.java.

1019  {
1020  if( is_leaf() || _args.length==0 ) {
1021  work.addAll(_deps);
1022  } else {
1023  if( UPDATE_VISIT.tset(_uid) ) return;
1024  for( int i=0; i<_args.length; i++ )
1025  args(i).add_deps_work_impl(work);
1026  }
1027  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._deps, com.cliffc.aa.HM.HM7.T2._uid, com.cliffc.aa.HM.HM7.T2.add_deps_work_impl(), com.cliffc.aa.HM.HM7.Worklist.addAll(), com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.HM.HM7.T2.is_leaf(), com.cliffc.aa.util.VBitSet.tset(), and com.cliffc.aa.HM.HM7.T2.UPDATE_VISIT.

Referenced by com.cliffc.aa.HM.HM7.T2.add_deps_work(), and com.cliffc.aa.HM.HM7.T2.add_deps_work_impl().

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

◆ add_fld()

void com.cliffc.aa.HM.HM7.T2.add_fld ( String  id,
T2  fld,
Worklist  work 
)
private

Definition at line 783 of file HM7.java.

783  {
784  assert is_struct();
785  int len = _ids.length;
786  _ids = Arrays.copyOf( _ids,len+1);
787  _args = Arrays.copyOf(_args,len+1);
788  _ids [len] = id ;
789  _args[len] = fld;
790  work.addAll(_deps); //
791  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._deps, com.cliffc.aa.HM.HM7.T2._ids, com.cliffc.aa.HM.HM7.Worklist.addAll(), com.cliffc.aa.HM.HM7.id(), and com.cliffc.aa.HM.HM7.T2.is_struct().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify_struct(), and com.cliffc.aa.HM.HM7.T2._unify().

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

◆ args()

T2 com.cliffc.aa.HM.HM7.T2.args ( int  i)
package

Definition at line 681 of file HM7.java.

681  {
682  T2 u = _args[i];
683  T2 uu = u.find();
684  return u==uu ? uu : (_args[i]=uu);
685  }

References com.cliffc.aa.HM.HM7.T2._args, and com.cliffc.aa.HM.HM7.T2.find().

Referenced by com.cliffc.aa.HM.HM7.T2._cycle_equals(), com.cliffc.aa.HM.HM7.T2._cycle_equals_struct(), com.cliffc.aa.HM.HM7.T2._fresh(), com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._fresh_unify_struct(), com.cliffc.aa.HM.HM7.T2._occurs_in_type(), com.cliffc.aa.HM.HM7.T2._p(), com.cliffc.aa.HM.HM7.T2._unify(), com.cliffc.aa.HM.HM7.T2.add_deps_work_impl(), com.cliffc.aa.HM.HM7.Lambda.hm(), com.cliffc.aa.HM.HM7.Apply.hm(), com.cliffc.aa.HM.HM7.Struct.hm(), com.cliffc.aa.HM.HM7.T2.make_fun(), com.cliffc.aa.HM.HM7.T2.prim(), com.cliffc.aa.HM.HM7.T2.push_update_impl(), and com.cliffc.aa.HM.HM7.T2.T2().

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

◆ copy()

T2 com.cliffc.aa.HM.HM7.T2.copy ( )
package

Definition at line 649 of file HM7.java.

649 { return new T2(_name,_con,_ids,new T2[_args.length]); }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2._ids, com.cliffc.aa.HM.HM7.T2._name, and com.cliffc.aa.HM.HM7.T2.T2().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh().

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

◆ cycle_equals()

boolean com.cliffc.aa.HM.HM7.T2.cycle_equals ( T2  t)
package

Definition at line 962 of file HM7.java.

962  {
963  assert CDUPS.isEmpty();
964  boolean rez = _cycle_equals(t);
965  CDUPS.clear();
966  return rez;
967  }

References com.cliffc.aa.HM.HM7.T2._cycle_equals(), and com.cliffc.aa.HM.HM7.T2.CDUPS.

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify().

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

◆ dbl_uid()

long com.cliffc.aa.HM.HM7.T2.dbl_uid ( T2  t)
private

Definition at line 793 of file HM7.java.

793 { return ((long)_uid<<32)|t._uid; }

References com.cliffc.aa.HM.HM7.T2._uid.

Referenced by com.cliffc.aa.HM.HM7.T2._unify().

Here is the caller graph for this function:

◆ find()

T2 com.cliffc.aa.HM.HM7.T2.find ( )
package

Definition at line 669 of file HM7.java.

669  {
670  if( !is_leaf() ) return this; // Shortcut
671  T2 u = _args[0];
672  if( u==null ) return this; // Shortcut
673  if( u.no_uf() ) return u; // Shortcut
674  // U-F fixup
675  while( u.is_leaf() && u._args[0]!=null ) u = u._args[0];
676  T2 v = this, v2;
677  while( !v.is_leaf() && (v2=v._args[0])!=u ) { v._args[0]=u; v = v2; }
678  return u;
679  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2.is_leaf(), and com.cliffc.aa.HM.HM7.T2.no_uf().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._unify(), com.cliffc.aa.HM.HM7.Ident.add_occurs(), com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.HM.HM7.Syntax.debug_find(), com.cliffc.aa.HM.HM7.Syntax.find(), com.cliffc.aa.HM.HM7.hm(), com.cliffc.aa.HM.HM7.Ident.hm(), com.cliffc.aa.HM.HM7.T2.p(), com.cliffc.aa.HM.HM7.Lambda.targ(), and com.cliffc.aa.HM.HM7.Let.targ().

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

◆ fresh_base()

boolean com.cliffc.aa.HM.HM7.T2.fresh_base ( T2  that,
Worklist  work 
)
private

Definition at line 804 of file HM7.java.

804  {
805  Type con = _con.meet(that._con);
806  if( con==that._con ) return false; // No progress
807  if( work==null ) return true;
808  that._con = con; // Yes progress, but no update if null work
809  return true;
810  }

References com.cliffc.aa.HM.HM7.T2._con, and com.cliffc.aa.type.Type< T extends Type< T >.meet().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify().

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

◆ fresh_unify()

boolean com.cliffc.aa.HM.HM7.T2.fresh_unify ( T2  that,
VStack  nongen,
Worklist  work 
)
package

Definition at line 819 of file HM7.java.

819  {
820  assert VARS.isEmpty() && DUPS.isEmpty();
821  int old = CNT;
822  boolean progress = _fresh_unify(that,nongen,work);
823  VARS.clear(); DUPS.clear();
824  if( work==null && old!=CNT && DEBUG_LEAKS )
825  throw unimpl("busted, made T2s but just testing");
826  return progress;
827  }

References com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2.CNT, com.cliffc.aa.HM.HM7.DEBUG_LEAKS, com.cliffc.aa.HM.HM7.T2.DUPS, and com.cliffc.aa.HM.HM7.T2.VARS.

Referenced by com.cliffc.aa.HM.HM7.Ident.hm().

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

◆ get_dups()

VBitSet com.cliffc.aa.HM.HM7.T2.get_dups ( VBitSet  dups)
package

Definition at line 1033 of file HM7.java.

1033 { return _get_dups(new VBitSet(),dups); }

References com.cliffc.aa.HM.HM7.T2._get_dups().

Referenced by com.cliffc.aa.HM.HM7.T2.p(), com.cliffc.aa.HM.HM7.Syntax.p0(), and com.cliffc.aa.HM.HM7.T2.toString().

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

◆ is_base()

boolean com.cliffc.aa.HM.HM7.T2.is_base ( )
package

Definition at line 663 of file HM7.java.

663 { return isa("Base") && _con!=null; }

References com.cliffc.aa.HM.HM7.T2._con, and com.cliffc.aa.HM.HM7.T2.isa().

Referenced by com.cliffc.aa.HM.HM7.T2._cycle_equals(), com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._p(), com.cliffc.aa.HM.HM7.T2._unify(), com.cliffc.aa.HM.HM7.T2.occurs_in(), and com.cliffc.aa.HM.HM7.T2.str().

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

◆ is_fun()

boolean com.cliffc.aa.HM.HM7.T2.is_fun ( )
package

Definition at line 665 of file HM7.java.

665 { return isa("->"); }

References com.cliffc.aa.HM.HM7.T2.isa().

Referenced by com.cliffc.aa.HM.HM7.T2._p(), com.cliffc.aa.HM.HM7.Lambda.hm(), com.cliffc.aa.HM.HM7.Apply.hm(), and com.cliffc.aa.HM.HM7.T2.str().

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

◆ is_leaf()

boolean com.cliffc.aa.HM.HM7.T2.is_leaf ( )
package

Definition at line 660 of file HM7.java.

660 { return _name.charAt(0)=='V' || (isa("Base") && _con==null); }

References com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2._name, and com.cliffc.aa.HM.HM7.T2.isa().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh(), com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._occurs_in_type(), com.cliffc.aa.HM.HM7.T2._p(), com.cliffc.aa.HM.HM7.T2._unify(), com.cliffc.aa.HM.HM7.T2.add_deps_work_impl(), com.cliffc.aa.HM.HM7.T2.find(), com.cliffc.aa.HM.HM7.T2.no_uf(), and com.cliffc.aa.HM.HM7.T2.str().

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

◆ is_nil()

boolean com.cliffc.aa.HM.HM7.T2.is_nil ( )
package

Definition at line 664 of file HM7.java.

664 { return isa("Nil"); }

References com.cliffc.aa.HM.HM7.T2.isa().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._unify(), and com.cliffc.aa.HM.HM7.T2.or0().

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

◆ is_struct()

boolean com.cliffc.aa.HM.HM7.T2.is_struct ( )
package

Definition at line 666 of file HM7.java.

666 { return isa("@{}"); }

References com.cliffc.aa.HM.HM7.T2.isa().

Referenced by com.cliffc.aa.HM.HM7.T2._cycle_equals(), com.cliffc.aa.HM.HM7.T2._cycle_equals_struct(), com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._fresh_unify_struct(), com.cliffc.aa.HM.HM7.T2._p(), com.cliffc.aa.HM.HM7.T2._unify(), com.cliffc.aa.HM.HM7.T2.add_fld(), com.cliffc.aa.HM.HM7.Struct.hm(), com.cliffc.aa.HM.HM7.T2.or0(), and com.cliffc.aa.HM.HM7.T2.str().

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

◆ isa()

boolean com.cliffc.aa.HM.HM7.T2.isa ( String  name)
package

Definition at line 662 of file HM7.java.

662 { return Util.eq(_name,name); }

References com.cliffc.aa.HM.HM7.T2._name, and com.cliffc.aa.util.Util.eq().

Referenced by com.cliffc.aa.HM.HM7.T2.is_base(), com.cliffc.aa.HM.HM7.T2.is_fun(), com.cliffc.aa.HM.HM7.T2.is_leaf(), com.cliffc.aa.HM.HM7.T2.is_nil(), and com.cliffc.aa.HM.HM7.T2.is_struct().

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

◆ make_base()

static T2 com.cliffc.aa.HM.HM7.T2.make_base ( Type  con)
staticpackage

Definition at line 645 of file HM7.java.

645 { return new T2("Base",con,null); }

References com.cliffc.aa.HM.HM7.T2.T2().

Referenced by com.cliffc.aa.HM.HM7.hm(), and com.cliffc.aa.HM.HM7.Con.prep_tree().

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

◆ make_fun()

static T2 com.cliffc.aa.HM.HM7.T2.make_fun ( T2...  args)
staticpackage

Definition at line 643 of file HM7.java.

643 { return new T2("->",null,null,args); }

References com.cliffc.aa.HM.HM7.T2.args(), and com.cliffc.aa.HM.HM7.T2.T2().

Referenced by com.cliffc.aa.HM.HM7.hm(), com.cliffc.aa.HM.HM7.Lambda.hm(), and com.cliffc.aa.HM.HM7.Apply.hm().

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

◆ make_leaf()

static T2 com.cliffc.aa.HM.HM7.T2.make_leaf ( )
staticpackage

Definition at line 644 of file HM7.java.

644 { return new T2("V"+CNT,null,null,new T2[1]); }

References com.cliffc.aa.HM.HM7.T2.CNT, and com.cliffc.aa.HM.HM7.T2.T2().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh(), com.cliffc.aa.HM.HM7.hm(), com.cliffc.aa.HM.HM7.Lambda.Lambda(), com.cliffc.aa.HM.HM7.Let.Let(), com.cliffc.aa.HM.HM7.Ident.prep_tree(), com.cliffc.aa.HM.HM7.Lambda.prep_tree(), com.cliffc.aa.HM.HM7.Apply.prep_tree(), and com.cliffc.aa.HM.HM7.Field.prep_tree().

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

◆ make_nil()

static T2 com.cliffc.aa.HM.HM7.T2.make_nil ( )
staticpackage

Definition at line 646 of file HM7.java.

646 { return new T2("Nil",null,null); }

References com.cliffc.aa.HM.HM7.T2.T2().

Referenced by com.cliffc.aa.HM.HM7.hm(), and com.cliffc.aa.HM.HM7.Con.prep_tree().

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

◆ make_struct()

static T2 com.cliffc.aa.HM.HM7.T2.make_struct ( String[]  ids,
T2[]  flds 
)
staticpackage

Definition at line 647 of file HM7.java.

647 { return new T2("@{}", null,ids,flds); }

References com.cliffc.aa.HM.HM7.T2.T2().

Referenced by com.cliffc.aa.HM.HM7.Struct.hm(), com.cliffc.aa.HM.HM7.Field.hm(), and com.cliffc.aa.HM.HM7.Struct.prep_tree().

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

◆ no_uf()

boolean com.cliffc.aa.HM.HM7.T2.no_uf ( )
package

Definition at line 661 of file HM7.java.

661 { return !is_leaf() || _args[0]==null; }

References com.cliffc.aa.HM.HM7.T2._args, and com.cliffc.aa.HM.HM7.T2.is_leaf().

Referenced by com.cliffc.aa.HM.HM7.T2._cycle_equals(), com.cliffc.aa.HM.HM7.T2._fresh(), com.cliffc.aa.HM.HM7.T2._fresh_unify(), com.cliffc.aa.HM.HM7.T2._get_dups(), com.cliffc.aa.HM.HM7.T2._occurs_in_type(), com.cliffc.aa.HM.HM7.T2._p(), com.cliffc.aa.HM.HM7.T2._unify(), com.cliffc.aa.HM.HM7.T2.find(), com.cliffc.aa.HM.HM7.T2.push_update_impl(), and com.cliffc.aa.HM.HM7.T2.union().

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

◆ nongen_in()

boolean com.cliffc.aa.HM.HM7.T2.nongen_in ( VStack  syn)
package

Definition at line 946 of file HM7.java.

946  {
947  if( syn==null ) return false;
948  assert ODUPS.isEmpty();
949  boolean found = _nongen_in(syn);
950  ODUPS.clear();
951  return found;
952  }

References com.cliffc.aa.HM.HM7.T2._nongen_in(), and com.cliffc.aa.HM.HM7.T2.ODUPS.

Referenced by com.cliffc.aa.HM.HM7.T2._fresh(), and com.cliffc.aa.HM.HM7.T2._fresh_unify().

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

◆ occurs_in()

boolean com.cliffc.aa.HM.HM7.T2.occurs_in ( Syntax  syn)
package

Definition at line 914 of file HM7.java.

914  {
915  if( syn==null ) return false;
916  if( is_base() ) return false;
917  assert ODUPS.isEmpty();
918  boolean found = _occurs_in(syn);
919  ODUPS.clear();
920  return found;
921  }

References com.cliffc.aa.HM.HM7.T2._occurs_in(), com.cliffc.aa.HM.HM7.T2.is_base(), and com.cliffc.aa.HM.HM7.T2.ODUPS.

Referenced by com.cliffc.aa.HM.HM7.Ident.add_occurs().

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

◆ occurs_in_type()

boolean com.cliffc.aa.HM.HM7.T2.occurs_in_type ( T2  x)
package

Definition at line 922 of file HM7.java.

922  {
923  assert ODUPS.isEmpty();
924  boolean found = _occurs_in_type(x);
925  ODUPS.clear();
926  return found;
927  }

References com.cliffc.aa.HM.HM7.T2._occurs_in_type(), and com.cliffc.aa.HM.HM7.T2.ODUPS.

Here is the call graph for this function:

◆ or0()

boolean com.cliffc.aa.HM.HM7.T2.or0 ( T2  that,
Worklist  work 
)
package

Definition at line 709 of file HM7.java.

709  {
710  assert is_nil() && that.is_struct();
711  if( work==null ) return that._con==null; // Progress if moving from not-nil to nilable
712  if( that._con == Type.NIL ) return false;// Already nilable
713  _args = new T2[1]; // Room for U-F
714  that._con=Type.NIL;
715  return union(that,work);
716  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2.is_nil(), com.cliffc.aa.HM.HM7.T2.is_struct(), and com.cliffc.aa.type.Type< T extends Type< T >.NIL.

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify(), and com.cliffc.aa.HM.HM7.T2._unify().

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

◆ p() [1/2]

String com.cliffc.aa.HM.HM7.T2.p ( )

Definition at line 1082 of file HM7.java.

1082 { return p(get_dups(new VBitSet())); }

References com.cliffc.aa.HM.HM7.T2.get_dups(), and com.cliffc.aa.HM.HM7.T2.p().

Referenced by com.cliffc.aa.HM.HM7.T2.p(), com.cliffc.aa.HM.TestHM7.test01(), com.cliffc.aa.HM.TestHM6.test01(), com.cliffc.aa.HM.TestHM4.test01(), com.cliffc.aa.HM.TestHM5.test01(), com.cliffc.aa.HM.TestHM7.test02(), com.cliffc.aa.HM.TestHM6.test02(), com.cliffc.aa.HM.TestHM4.test02(), com.cliffc.aa.HM.TestHM5.test02(), com.cliffc.aa.HM.TestHM7.test03(), com.cliffc.aa.HM.TestHM6.test03(), com.cliffc.aa.HM.TestHM4.test03(), com.cliffc.aa.HM.TestHM5.test03(), com.cliffc.aa.HM.TestHM7.test04(), com.cliffc.aa.HM.TestHM6.test04(), com.cliffc.aa.HM.TestHM4.test04(), com.cliffc.aa.HM.TestHM5.test04(), com.cliffc.aa.HM.TestHM7.test05(), com.cliffc.aa.HM.TestHM6.test05(), com.cliffc.aa.HM.TestHM4.test05(), com.cliffc.aa.HM.TestHM5.test05(), com.cliffc.aa.HM.TestHM7.test06(), com.cliffc.aa.HM.TestHM6.test06(), com.cliffc.aa.HM.TestHM4.test06(), com.cliffc.aa.HM.TestHM5.test06(), com.cliffc.aa.HM.TestHM7.test07(), com.cliffc.aa.HM.TestHM6.test07(), com.cliffc.aa.HM.TestHM4.test07(), com.cliffc.aa.HM.TestHM5.test07(), com.cliffc.aa.HM.TestHM7.test08(), com.cliffc.aa.HM.TestHM6.test08(), com.cliffc.aa.HM.TestHM5.test08(), com.cliffc.aa.HM.TestHM4.test08(), com.cliffc.aa.HM.TestHM7.test09(), com.cliffc.aa.HM.TestHM6.test09(), com.cliffc.aa.HM.TestHM5.test09(), com.cliffc.aa.HM.TestHM4.test09(), com.cliffc.aa.HM.TestHM7.test10(), com.cliffc.aa.HM.TestHM6.test10(), com.cliffc.aa.HM.TestHM5.test10(), com.cliffc.aa.HM.TestHM4.test10(), com.cliffc.aa.HM.TestHM7.test11(), com.cliffc.aa.HM.TestHM6.test11(), com.cliffc.aa.HM.TestHM5.test11(), com.cliffc.aa.HM.TestHM4.test11(), com.cliffc.aa.HM.TestHM7.test12(), com.cliffc.aa.HM.TestHM6.test12(), com.cliffc.aa.HM.TestHM5.test12(), com.cliffc.aa.HM.TestHM4.test12(), com.cliffc.aa.HM.TestHM7.test13(), com.cliffc.aa.HM.TestHM6.test13(), com.cliffc.aa.HM.TestHM5.test13(), com.cliffc.aa.HM.TestHM4.test13(), com.cliffc.aa.HM.TestHM7.test14(), com.cliffc.aa.HM.TestHM6.test14(), com.cliffc.aa.HM.TestHM5.test14(), com.cliffc.aa.HM.TestHM4.test14(), com.cliffc.aa.HM.TestHM7.test15(), com.cliffc.aa.HM.TestHM6.test15(), com.cliffc.aa.HM.TestHM4.test15(), com.cliffc.aa.HM.TestHM5.test15(), com.cliffc.aa.HM.TestHM7.test16(), com.cliffc.aa.HM.TestHM6.test16(), com.cliffc.aa.HM.TestHM4.test16(), com.cliffc.aa.HM.TestHM5.test16(), com.cliffc.aa.HM.TestHM7.test17(), com.cliffc.aa.HM.TestHM6.test17(), com.cliffc.aa.HM.TestHM5.test17(), com.cliffc.aa.HM.TestHM4.test17(), com.cliffc.aa.HM.TestHM7.test18(), com.cliffc.aa.HM.TestHM6.test18(), com.cliffc.aa.HM.TestHM4.test18(), com.cliffc.aa.HM.TestHM5.test18(), com.cliffc.aa.HM.TestHM7.test19(), com.cliffc.aa.HM.TestHM6.test19(), com.cliffc.aa.HM.TestHM5.test19(), com.cliffc.aa.HM.TestHM4.test19(), com.cliffc.aa.HM.TestHM7.test20(), com.cliffc.aa.HM.TestHM6.test20(), com.cliffc.aa.HM.TestHM4.test20(), com.cliffc.aa.HM.TestHM5.test20(), com.cliffc.aa.HM.TestHM7.test21(), com.cliffc.aa.HM.TestHM6.test21(), com.cliffc.aa.HM.TestHM4.test21(), com.cliffc.aa.HM.TestHM5.test21(), com.cliffc.aa.HM.TestHM7.test22(), com.cliffc.aa.HM.TestHM6.test22(), com.cliffc.aa.HM.TestHM4.test22(), com.cliffc.aa.HM.TestHM5.test22(), com.cliffc.aa.HM.TestHM7.test23(), com.cliffc.aa.HM.TestHM6.test23(), com.cliffc.aa.HM.TestHM5.test23(), com.cliffc.aa.HM.TestHM4.test23(), com.cliffc.aa.HM.TestHM7.test24(), com.cliffc.aa.HM.TestHM7.test25(), com.cliffc.aa.HM.TestHM7.test26(), com.cliffc.aa.HM.TestHM7.test27(), com.cliffc.aa.HM.TestHM7.test28(), com.cliffc.aa.HM.TestHM7.test29(), com.cliffc.aa.HM.TestHM7.test30(), com.cliffc.aa.HM.TestHM7.test31(), and com.cliffc.aa.HM.TestHM7.test32().

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

◆ p() [2/2]

String com.cliffc.aa.HM.HM7.T2.p ( VBitSet  dups)
package

Definition at line 1085 of file HM7.java.

1085 { VCNT=0; VNAMES.clear(); return find()._p(new SB(), new VBitSet(), dups).toString(); }

References com.cliffc.aa.HM.HM7.T2._p(), com.cliffc.aa.HM.HM7.T2.find(), com.cliffc.aa.util.SB.toString(), com.cliffc.aa.HM.HM7.T2.VCNT, and com.cliffc.aa.HM.HM7.T2.VNAMES.

Here is the call graph for this function:

◆ prim()

static T2 com.cliffc.aa.HM.HM7.T2.prim ( String  name,
T2...  args 
)
staticpackage

Definition at line 648 of file HM7.java.

648 { return new T2(name,null,null,args); }

References com.cliffc.aa.HM.HM7.T2.args(), and com.cliffc.aa.HM.HM7.T2.T2().

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

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

◆ push_update() [1/2]

T2 com.cliffc.aa.HM.HM7.T2.push_update ( Ary< Syntax as)
package

Definition at line 1006 of file HM7.java.

1006 { if( as != null ) for( Syntax a : as ) push_update(a); return this; }

References com.cliffc.aa.HM.HM7.T2.push_update().

Referenced by com.cliffc.aa.HM.HM7.Field.hm(), com.cliffc.aa.HM.HM7.Lambda.prep_lookup_deps(), com.cliffc.aa.HM.HM7.Let.prep_lookup_deps(), and com.cliffc.aa.HM.HM7.T2.push_update().

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

◆ push_update() [2/2]

void com.cliffc.aa.HM.HM7.T2.push_update ( Syntax  a)
package

Definition at line 1007 of file HM7.java.

1007 { assert UPDATE_VISIT.isEmpty(); push_update_impl(a); UPDATE_VISIT.clear(); }

References com.cliffc.aa.HM.HM7.T2.push_update_impl(), and com.cliffc.aa.HM.HM7.T2.UPDATE_VISIT.

Here is the call graph for this function:

◆ push_update_impl()

void com.cliffc.aa.HM.HM7.T2.push_update_impl ( Syntax  a)
private

Definition at line 1008 of file HM7.java.

1008  {
1009  assert no_uf();
1010  if( UPDATE_VISIT.tset(_uid) ) return;
1011  if( _deps==null ) _deps = new Ary<>(Syntax.class);
1012  if( _deps.find(a)==-1 ) _deps.push(a);
1013  for( int i=0; i<_args.length; i++ )
1014  if( _args[i]!=null )
1015  args(i).push_update_impl(a);
1016  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._deps, com.cliffc.aa.HM.HM7.T2._uid, com.cliffc.aa.HM.HM7.T2.args(), com.cliffc.aa.HM.HM7.T2.no_uf(), com.cliffc.aa.HM.HM7.T2.push_update_impl(), com.cliffc.aa.util.VBitSet.tset(), and com.cliffc.aa.HM.HM7.T2.UPDATE_VISIT.

Referenced by com.cliffc.aa.HM.HM7.T2.push_update(), and com.cliffc.aa.HM.HM7.T2.push_update_impl().

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

◆ reset()

static void com.cliffc.aa.HM.HM7.T2.reset ( )
staticpackage

Definition at line 1126 of file HM7.java.

1126 { CNT=0; DUPS.clear(); VARS.clear(); ODUPS.clear(); CDUPS.clear(); UPDATE_VISIT.clear(); }

References com.cliffc.aa.HM.HM7.T2.CDUPS, com.cliffc.aa.HM.HM7.T2.CNT, com.cliffc.aa.HM.HM7.T2.DUPS, com.cliffc.aa.HM.HM7.T2.ODUPS, com.cliffc.aa.HM.HM7.T2.UPDATE_VISIT, and com.cliffc.aa.HM.HM7.T2.VARS.

Referenced by com.cliffc.aa.HM.HM7.reset().

Here is the caller graph for this function:

◆ str() [1/2]

static SB com.cliffc.aa.HM.HM7.T2.str ( SB  sb,
VBitSet  visit,
T2  t,
VBitSet  dups 
)
staticprivate

Definition at line 1079 of file HM7.java.

1079 { return t==null ? sb.p("_") : t.str(sb,visit,dups); }

References com.cliffc.aa.util.SB.p(), and com.cliffc.aa.HM.HM7.T2.str().

Here is the call graph for this function:

◆ str() [2/2]

SB com.cliffc.aa.HM.HM7.T2.str ( SB  sb,
VBitSet  visit,
VBitSet  dups 
)
package

Definition at line 1046 of file HM7.java.

1046  {
1047  if( is_leaf() || is_base() ) {
1048  if( is_base() ) sb.p(_con instanceof TypeMemPtr ? "str" : _con.toString()); else sb.p(_name);
1049  return _args.length==0 || _args[0]==null ? sb : _args[0].str(sb.p(">>"), visit, dups);
1050  }
1051  boolean dup = dups.get(_uid);
1052  if( dup ) sb.p("$V").p(_uid);
1053  if( visit.tset(_uid) && dup ) return sb;
1054  if( dup ) sb.p(':');
1055 
1056  // Special printing for functions
1057  if( is_fun() ) {
1058  sb.p("{ ");
1059  for( int i=0; i<_args.length-1; i++ )
1060  str(sb,visit,_args[i],dups).p(" ");
1061  return str(sb.p("-> "),visit,_args[_args.length-1],dups).p(" }");
1062  }
1063 
1064  // Special printing for structures
1065  if( is_struct() ) {
1066  sb.p("@{");
1067  for( int i=0; i<_ids.length; i++ )
1068  str(sb.p(' ').p(_ids[i]).p(" = "),visit,_args[i],dups).p(',');
1069  sb.unchar().p("}");
1070  if( _con==Type.NIL ) sb.p('?');
1071  return sb;
1072  }
1073 
1074  // Generic structural T2
1075  sb.p("(").p(_name).p(" ");
1076  for( T2 t : _args ) str(sb,visit,t,dups).p(" ");
1077  return sb.unchar().p(")");
1078  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, com.cliffc.aa.HM.HM7.T2._ids, com.cliffc.aa.HM.HM7.T2._name, com.cliffc.aa.HM.HM7.T2._uid, com.cliffc.aa.HM.HM7.T2.is_base(), com.cliffc.aa.HM.HM7.T2.is_fun(), com.cliffc.aa.HM.HM7.T2.is_leaf(), com.cliffc.aa.HM.HM7.T2.is_struct(), com.cliffc.aa.type.Type< T extends Type< T >.NIL, com.cliffc.aa.util.SB.p(), com.cliffc.aa.HM.HM7.T2.str(), com.cliffc.aa.type.Type< T extends Type< T >.toString(), com.cliffc.aa.util.VBitSet.tset(), and com.cliffc.aa.util.SB.unchar().

Referenced by com.cliffc.aa.HM.HM7.Syntax.p0(), com.cliffc.aa.HM.HM7.VStack.str(), com.cliffc.aa.HM.HM7.T2.str(), and com.cliffc.aa.HM.HM7.T2.toString().

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

◆ toString()

String com.cliffc.aa.HM.HM7.T2.toString ( )

Definition at line 1045 of file HM7.java.

1045 { return str(new SB(), new VBitSet(), get_dups(new VBitSet()) ).toString(); }

References com.cliffc.aa.HM.HM7.T2.get_dups(), com.cliffc.aa.HM.HM7.T2.str(), and com.cliffc.aa.util.SB.toString().

Here is the call graph for this function:

◆ unify()

boolean com.cliffc.aa.HM.HM7.T2.unify ( T2  that,
Worklist  work 
)
package

Definition at line 724 of file HM7.java.

724  {
725  if( this==that ) return false;
726  assert DUPS.isEmpty();
727  boolean progress = _unify(that,work);
728  DUPS.clear();
729  return progress;
730  }

References com.cliffc.aa.HM.HM7.T2._unify(), and com.cliffc.aa.HM.HM7.T2.DUPS.

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

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

◆ unify_base()

boolean com.cliffc.aa.HM.HM7.T2.unify_base ( T2  that,
Worklist  work 
)
private

Definition at line 795 of file HM7.java.

795  {
796  Type con = _con.meet(that._con);
797  if( con==that._con ) return false; // No progress
798  if( work==null ) return true;
799  that._con = con; // Yes progress, but no update if null work
800  _args = new T2[1]; // Room for a forwarding pointer
801  _con=null; // Flip from 'Base' to 'Leaf'
802  return union(that,work);
803  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._con, and com.cliffc.aa.type.Type< T extends Type< T >.meet().

Referenced by com.cliffc.aa.HM.HM7.T2._unify().

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

◆ union()

boolean com.cliffc.aa.HM.HM7.T2.union ( T2  that,
Worklist  work 
)
package

Definition at line 689 of file HM7.java.

689  {
690  assert no_uf(); // Cannot union twice
691  if( this==that ) return false;
692  if( work==null ) return true; // Report progress without changing
693  // Worklist: put updates on the worklist for revisiting
694  if( _deps != null ) {
695  work.addAll(_deps); // Re-Apply
696  // Merge update lists, for future unions
697  if( that._deps==null && that.is_leaf() ) that._deps = _deps;
698  else
699  for( Syntax dep : _deps ) that.push_update(dep);
700  _deps = null;
701  }
702  _args[0] = that; // U-F update
703  if( _name.charAt(0)!='V' ) _name = "V"+_uid; // Flag as a leaf & unified
704  assert !no_uf();
705  return true;
706  }

References com.cliffc.aa.HM.HM7.T2._args, com.cliffc.aa.HM.HM7.T2._deps, com.cliffc.aa.HM.HM7.T2._name, com.cliffc.aa.HM.HM7.T2._uid, and com.cliffc.aa.HM.HM7.T2.no_uf().

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify(), and com.cliffc.aa.HM.HM7.T2._unify().

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

◆ vput()

boolean com.cliffc.aa.HM.HM7.T2.vput ( T2  that,
boolean  progress 
)
private

Definition at line 891 of file HM7.java.

891 { VARS.put(this,that); return progress; }

References com.cliffc.aa.HM.HM7.T2.VARS.

Referenced by com.cliffc.aa.HM.HM7.T2._fresh_unify().

Here is the caller graph for this function:

Member Data Documentation

◆ _args

◆ _con

◆ _deps

◆ _ids

◆ _name

◆ _uid

◆ CDUPS

final HashMap<T2,T2> com.cliffc.aa.HM.HM7.T2.CDUPS = new HashMap<>()
staticprivate

◆ CNT

◆ DUPS

final HashMap<Long,T2> com.cliffc.aa.HM.HM7.T2.DUPS = new HashMap<>()
staticprivate

◆ ODUPS

◆ UPDATE_VISIT

◆ VARS

final HashMap<T2,T2> com.cliffc.aa.HM.HM7.T2.VARS = new HashMap<>()
staticprivate

◆ VCNT

int com.cliffc.aa.HM.HM7.T2.VCNT
staticprivate

Definition at line 1083 of file HM7.java.

Referenced by com.cliffc.aa.HM.HM7.T2._p(), and com.cliffc.aa.HM.HM7.T2.p().

◆ VNAMES

final HashMap<T2,Integer> com.cliffc.aa.HM.HM7.T2.VNAMES = new HashMap<>()
staticprivate

Definition at line 1084 of file HM7.java.

Referenced by com.cliffc.aa.HM.HM7.T2._p(), and com.cliffc.aa.HM.HM7.T2.p().


The documentation for this class was generated from the following file:
com.cliffc.aa.HM.HM7.T2.unify_base
boolean unify_base(T2 that, Worklist work)
Definition: HM7.java:795
com.cliffc.aa.HM.HM7.T2.copy
T2 copy()
Definition: HM7.java:649
com.cliffc.aa.HM.HM7.T2.str
SB str(SB sb, VBitSet visit, VBitSet dups)
Definition: HM7.java:1046
com.cliffc.aa.HM.HM7.T2._p
SB _p(SB sb, VBitSet visit, VBitSet dups)
Definition: HM7.java:1086
com.cliffc.aa.HM.HM7.T2._fresh_unify_struct
boolean _fresh_unify_struct(T2 that, VStack nongen, Worklist work)
Definition: HM7.java:871
com.cliffc.aa.HM.HM7.T2.find
T2 find()
Definition: HM7.java:669
com.cliffc.aa.util.Util.find
static int find(int[] es, int e)
Definition: Util.java:6
com.cliffc.aa.HM.HM7.T2.p
String p()
Definition: HM7.java:1082
com.cliffc.aa.util.Util.eq
static boolean eq(String s0, String s1)
Definition: Util.java:16
com.cliffc.aa.type.Type.toString
final String toString()
Definition: Type.java:127
com.cliffc.aa.HM.HM7.T2.fresh_base
boolean fresh_base(T2 that, Worklist work)
Definition: HM7.java:804
com.cliffc.aa.type.Type
an implementation of language AA
Definition: Type.java:94
com.cliffc.aa.util.Ary
Definition: Ary.java:11
com.cliffc.aa.HM.HM7.T2._name
String _name
Definition: HM7.java:628
com.cliffc.aa.HM.HM7.T2._deps
Ary< Syntax > _deps
Definition: HM7.java:640
com.cliffc.aa.HM.HM7.T2._nongen_in
boolean _nongen_in(VStack nongen)
Definition: HM7.java:953
com.cliffc.aa.HM.HM7.T2.args
T2 args(int i)
Definition: HM7.java:681
com.cliffc.aa.HM.HM7.T2.no_uf
boolean no_uf()
Definition: HM7.java:661
com.cliffc.aa.HM.HM7.T2._occurs_in_type
boolean _occurs_in_type(T2 x)
Definition: HM7.java:935
com.cliffc.aa.HM.HM7.T2.is_fun
boolean is_fun()
Definition: HM7.java:665
com.cliffc.aa.HM.HM7.id
static String id()
Definition: HM7.java:158
com.cliffc.aa.HM.HM7.T2.vput
boolean vput(T2 that, boolean progress)
Definition: HM7.java:891
com.cliffc.aa.HM.HM7.T2.UPDATE_VISIT
static final VBitSet UPDATE_VISIT
Definition: HM7.java:1005
com.cliffc.aa.HM.HM7.T2.VARS
static final HashMap< T2, T2 > VARS
Definition: HM7.java:818
com.cliffc.aa.type.Type.meet
final Type meet(Type t)
Definition: Type.java:412
com.cliffc.aa.util.SB.unchar
SB unchar()
Definition: SB.java:58
com.cliffc.aa.util.VBitSet.tset
boolean tset(int idx)
Definition: VBitSet.java:7
com.cliffc.aa.HM.HM7.T2.push_update
T2 push_update(Ary< Syntax > as)
Definition: HM7.java:1006
com.cliffc.aa.HM.HM7.T2.dbl_uid
long dbl_uid(T2 t)
Definition: HM7.java:793
com.cliffc.aa.HM.HM7.T2._con
Type _con
Definition: HM7.java:634
com.cliffc.aa.HM.HM7.T2.T2
T2(@NotNull String name, Type con, String[] ids, T2 @NotNull ... args)
Definition: HM7.java:651
com.cliffc.aa.HM.HM7.T2._cycle_equals_struct
boolean _cycle_equals_struct(T2 t)
Definition: HM7.java:990
com.cliffc.aa.HM.HM7.T2.CDUPS
static final HashMap< T2, T2 > CDUPS
Definition: HM7.java:961
com.cliffc.aa.util.Util
Definition: Util.java:5
com.cliffc.aa.HM.HM7.T2._unify
boolean _unify(T2 that, Worklist work)
Definition: HM7.java:735
com.cliffc.aa.HM.HM7.T2.is_nil
boolean is_nil()
Definition: HM7.java:664
com.cliffc.aa.HM.HM7.T2.nongen_in
boolean nongen_in(VStack syn)
Definition: HM7.java:946
com.cliffc.aa.HM.HM7.T2.is_leaf
boolean is_leaf()
Definition: HM7.java:660
com.cliffc.aa.HM.HM7.T2._uid
final int _uid
Definition: HM7.java:623
com.cliffc.aa.HM.HM7.T2._cycle_equals
boolean _cycle_equals(T2 t)
Definition: HM7.java:968
com.cliffc.aa.HM.HM7.T2.is_struct
boolean is_struct()
Definition: HM7.java:666
com.cliffc.aa.HM.HM7.T2.VNAMES
static final HashMap< T2, Integer > VNAMES
Definition: HM7.java:1084
com.cliffc.aa.util.VBitSet
Definition: VBitSet.java:5
com.cliffc.aa.HM.HM7.T2._get_dups
VBitSet _get_dups(VBitSet visit, VBitSet dups)
Definition: HM7.java:1034
com.cliffc.aa.util.SB
Tight/tiny StringBuilder wrapper.
Definition: SB.java:8
com.cliffc.aa.type.Type.NIL
static final Type NIL
Definition: Type.java:332
com.cliffc.aa.HM.HM7.T2.is_base
boolean is_base()
Definition: HM7.java:663
com.cliffc.aa.HM.HM7.T2.CNT
static int CNT
Definition: HM7.java:622
com.cliffc.aa.HM.HM7.T2.get_dups
VBitSet get_dups(VBitSet dups)
Definition: HM7.java:1033
com.cliffc.aa.HM.HM7.T2.isa
boolean isa(String name)
Definition: HM7.java:662
com.cliffc.aa.HM.HM7.T2.or0
boolean or0(T2 that, Worklist work)
Definition: HM7.java:709
com.cliffc.aa.util.SB.p
SB p(String s)
Definition: SB.java:13
com.cliffc.aa.HM.HM7.T2._ids
String[] _ids
Definition: HM7.java:637
com.cliffc.aa.HM.HM7.T2.push_update_impl
void push_update_impl(Syntax a)
Definition: HM7.java:1008
com.cliffc.aa.HM.HM7.T2.VCNT
static int VCNT
Definition: HM7.java:1083
com.cliffc.aa.HM.HM7.T2.add_deps_work_impl
void add_deps_work_impl(Worklist work)
Definition: HM7.java:1019
com.cliffc.aa.HM.HM7.T2._fresh
T2 _fresh(VStack nongen)
Definition: HM7.java:894
com.cliffc.aa.HM.HM7.T2.cycle_equals
boolean cycle_equals(T2 t)
Definition: HM7.java:962
com.cliffc.aa.HM.HM7.T2._args
T2[] _args
Definition: HM7.java:631
com.cliffc.aa.HM.HM7.T2._occurs_in
boolean _occurs_in(Syntax syn)
Definition: HM7.java:928
com.cliffc.aa.HM.HM7.T2._fresh_unify
boolean _fresh_unify(T2 that, VStack nongen, Worklist work)
Definition: HM7.java:830
com.cliffc.aa.HM.HM7.T2.DUPS
static final HashMap< Long, T2 > DUPS
Definition: HM7.java:723
com.cliffc.aa.HM.HM7.DEBUG_LEAKS
static boolean DEBUG_LEAKS
Definition: HM7.java:25
com.cliffc.aa.HM.HM7.T2.ODUPS
static final VBitSet ODUPS
Definition: HM7.java:913
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62
com.cliffc.aa.type.TypeMemPtr
Definition: TypeMemPtr.java:14