aa
com.cliffc.aa.HM.HM3.Oper Class Reference
Inheritance diagram for com.cliffc.aa.HM.HM3.Oper:
[legend]
Collaboration diagram for com.cliffc.aa.HM.HM3.Oper:
[legend]

Public Member Functions

SB _str (SB sb, VBitSet dups, boolean debug)
 
String str ()
 
final String toString ()
 

Package Functions

 Oper (String name, HMType... args)
 
boolean _eq (HMType v, BitSetSparse dups)
 
HMType _fresh (VStack vstk, HashMap< HMVar, HMVar > vars, HashMap< Oper, Oper > opers)
 
final boolean eq (HMType v)
 
HMType find ()
 
HMType fresh (VStack vstk)
 
boolean is_top ()
 
boolean occurs_in (HMType[] args, VBitSet dups)
 
boolean occurs_in (VStack vstk, VBitSet dups)
 
boolean occurs_in_type (HMType v, VBitSet dups)
 
HMType union (HMType that, Worklist work)
 

Static Package Functions

static Oper fun (HMType... args)
 
static void reset ()
 

Package Attributes

final HMType[] _args
 
Ary< Ident_ids
 
final String _name
 
HMType _u
 
final int _uid
 

Static Package Attributes

static final HashMap< HMVar, HMVarEQS = new HashMap<>()
 

Static Private Attributes

static int CNT
 

Detailed Description

Definition at line 394 of file HM3.java.

Constructor & Destructor Documentation

◆ Oper()

com.cliffc.aa.HM.HM3.Oper.Oper ( String  name,
HMType...  args 
)
package

Definition at line 397 of file HM3.java.

397 { _name=name; _args=args; }

References com.cliffc.aa.HM.HM3.Oper._args, and com.cliffc.aa.HM.HM3.Oper._name.

Referenced by com.cliffc.aa.HM.HM3.Oper._eq(), com.cliffc.aa.HM.HM3.Oper._fresh(), com.cliffc.aa.HM.HM3.Oper.fun(), and com.cliffc.aa.HM.HM3.Oper.union().

Here is the caller graph for this function:

Member Function Documentation

◆ _eq()

boolean com.cliffc.aa.HM.HM3.Oper._eq ( HMType  v,
BitSetSparse  dups 
)
package

Reimplemented from com.cliffc.aa.HM.HM3.HMType.

Definition at line 432 of file HM3.java.

432  {
433  assert is_top() && v.is_top();
434  if( this==v ) return true;
435  if( !(v instanceof Oper) ) return false;
436  if( dups.tset(_uid,v._uid) )
437  return true; // Checked already, something else has to be equal/unequal
438  Oper o = (Oper)v;
439  if( !_name.equals(o._name) ||
440  _args.length!=o._args.length ) return false;
441  for( int i=0; i<_args.length; i++ ) {
442  HMType h0 = _args[i];
443  HMType h1 = o._args[i];
444  if( !h0.is_top() ) _args[i] = h0 = h0.find();
445  if( !h1.is_top() ) o._args[i] = h1 = h1.find();
446  if( !h0._eq(h1,dups) )
447  return false;
448  }
449  return true;
450  }

References com.cliffc.aa.HM.HM3.Oper._args, com.cliffc.aa.HM.HM3.HMType._eq(), com.cliffc.aa.HM.HM3.Oper._name, com.cliffc.aa.HM.HM3.HMType._uid, com.cliffc.aa.HM.HM3.HMType.find(), com.cliffc.aa.HM.HM3.HMType.is_top(), com.cliffc.aa.HM.HM3.Oper.Oper(), and com.cliffc.aa.util.BitSetSparse.tset().

Here is the call graph for this function:

◆ _fresh()

HMType com.cliffc.aa.HM.HM3.Oper._fresh ( VStack  vstk,
HashMap< HMVar, HMVar vars,
HashMap< Oper, Oper opers 
)
package

Reimplemented from com.cliffc.aa.HM.HM3.HMType.

Definition at line 451 of file HM3.java.

451  {
452  assert is_top();
453  Oper op = opers.get(this);
454  if( op!=null ) return op;
455  HMType[] args = new HMType[_args.length];
456  op = new Oper(_name,args);
457  opers.put(this,op); // Stop cyclic structure endless looping
458  for( int i=0; i<_args.length; i++ )
459  args[i] = _args[i].find()._fresh(vstk,vars,opers);
460  return op;
461  }

References com.cliffc.aa.HM.HM3.Oper._args, com.cliffc.aa.HM.HM3.HMType._fresh(), com.cliffc.aa.HM.HM3.Oper._name, com.cliffc.aa.HM.HM3.Oper.find(), com.cliffc.aa.HM.HM3.HMType.is_top(), and com.cliffc.aa.HM.HM3.Oper.Oper().

Here is the call graph for this function:

◆ _str()

SB com.cliffc.aa.HM.HM3.Oper._str ( SB  sb,
VBitSet  dups,
boolean  debug 
)

Reimplemented from com.cliffc.aa.HM.HM3.HMType.

Definition at line 399 of file HM3.java.

399  {
400  if( dups.tset(_uid) ) return sb.p("v").p(_uid).p("$"); // Stop infinite print loops
401  if( _name.equals("->") ) {
402  if( debug ) sb.p("v").p(_uid).p(":");
403  sb.p("{ ");
404  _args[0]._str(sb,dups,debug);
405  sb.p(" -> ");
406  _args[1]._str(sb,dups,debug);
407  return sb.p(" }");
408  }
409  sb.p(_name);
410  if( debug ) sb.p(_uid);
411  sb.p('(');
412  for( HMType t : _args )
413  t._str(sb,dups,debug).p(',');
414  return sb.unchar().p(')');
415  }

References com.cliffc.aa.HM.HM3.Oper._args, com.cliffc.aa.HM.HM3.Oper._name, com.cliffc.aa.HM.HM3.HMType._str(), com.cliffc.aa.HM.HM3.HMType._uid, com.cliffc.aa.util.SB.p(), com.cliffc.aa.util.VBitSet.tset(), and com.cliffc.aa.util.SB.unchar().

Here is the call graph for this function:

◆ eq()

final boolean com.cliffc.aa.HM.HM3.HMType.eq ( HMType  v)
packageinherited

Definition at line 291 of file HM3.java.

291 { EQS.clear(); return find()._eq(v, new BitSetSparse()); }

References com.cliffc.aa.HM.HM3.HMType._eq(), com.cliffc.aa.HM.HM3.HMType.EQS, and com.cliffc.aa.HM.HM3.HMType.find().

Referenced by com.cliffc.aa.HM.HM3.Lambda.progress(), com.cliffc.aa.HM.HM3.Let.progress(), and com.cliffc.aa.HM.HM3.Apply.progress().

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

◆ find()

HMType com.cliffc.aa.HM.HM3.Oper.find ( )
package

Reimplemented from com.cliffc.aa.HM.HM3.HMType.

Definition at line 417 of file HM3.java.

417 { return this; }

Referenced by com.cliffc.aa.HM.HM3.Oper._fresh().

Here is the caller graph for this function:

◆ fresh()

HMType com.cliffc.aa.HM.HM3.HMType.fresh ( VStack  vstk)
packageinherited

Definition at line 294 of file HM3.java.

294  {
295  HashMap<HMVar,HMVar> vars = new HashMap<>();
296  HashMap<Oper,Oper> opers = new HashMap<>();
297  return find()._fresh(vstk,vars,opers);
298  }

References com.cliffc.aa.HM.HM3.HMType._fresh(), and com.cliffc.aa.HM.HM3.HMType.find().

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

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

◆ fun()

static Oper com.cliffc.aa.HM.HM3.Oper.fun ( HMType...  args)
staticpackage

Definition at line 398 of file HM3.java.

398 { return new Oper("->",args); }

References com.cliffc.aa.HM.HM3.Oper.Oper().

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

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

◆ is_top()

boolean com.cliffc.aa.HM.HM3.HMType.is_top ( )
packageinherited

Definition at line 289 of file HM3.java.

289 { return _u==null; }

References com.cliffc.aa.HM.HM3.HMType._u.

Referenced by com.cliffc.aa.HM.HM3.Oper._eq(), com.cliffc.aa.HM.HM3.HMVar._fresh(), com.cliffc.aa.HM.HM3.Oper._fresh(), com.cliffc.aa.HM.HM3.HMType.occurs_in_type(), and com.cliffc.aa.HM.HM3.HMVar.type().

Here is the caller graph for this function:

◆ occurs_in() [1/2]

boolean com.cliffc.aa.HM.HM3.HMType.occurs_in ( HMType[]  args,
VBitSet  dups 
)
packageinherited

Definition at line 306 of file HM3.java.

306  {
307  for( HMType x : args ) if( occurs_in_type(x,dups) ) return true;
308  return false;
309  }

References com.cliffc.aa.HM.HM3.HMType.occurs_in_type().

Here is the call graph for this function:

◆ occurs_in() [2/2]

boolean com.cliffc.aa.HM.HM3.HMType.occurs_in ( VStack  vstk,
VBitSet  dups 
)
packageinherited

Definition at line 301 of file HM3.java.

301  {
302  if( vstk==null ) return false;
303  for( HMVar x : vstk ) if( occurs_in_type(x,dups) ) return true;
304  return false;
305  }

References com.cliffc.aa.HM.HM3.HMType.occurs_in_type().

Referenced by com.cliffc.aa.HM.HM3.HMVar._fresh(), and com.cliffc.aa.HM.HM3.HMType.occurs_in_type().

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

◆ occurs_in_type()

boolean com.cliffc.aa.HM.HM3.HMType.occurs_in_type ( HMType  v,
VBitSet  dups 
)
packageinherited

Definition at line 310 of file HM3.java.

310  {
311  assert is_top();
312  if( dups.tset(v._uid) )
313  return false; // Been there, done that
314  HMType y = v.find(); // Find top
315  if( y==this ) // Occurs in type?
316  return true; // Yup, occurs in type right here
317  if( y instanceof Oper ) // Structural recursive test
318  return occurs_in(((Oper)y)._args,dups);
319  return false;
320  }

References com.cliffc.aa.HM.HM3.HMType._uid, com.cliffc.aa.HM.HM3.HMType.find(), com.cliffc.aa.HM.HM3.HMType.is_top(), com.cliffc.aa.HM.HM3.HMType.occurs_in(), and com.cliffc.aa.util.VBitSet.tset().

Referenced by com.cliffc.aa.HM.HM3.HMType.occurs_in(), and com.cliffc.aa.HM.HM3.HMVar.union().

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

◆ reset()

static void com.cliffc.aa.HM.HM3.HMType.reset ( )
staticpackageinherited

Definition at line 281 of file HM3.java.

281 { CNT=1; }

References com.cliffc.aa.HM.HM3.HMType.CNT.

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

Here is the caller graph for this function:

◆ str()

String com.cliffc.aa.HM.HM3.HMType.str ( )
inherited

Definition at line 287 of file HM3.java.

287 { return _str(new SB(),new VBitSet(),false).toString(); }

References com.cliffc.aa.HM.HM3.HMType._str(), and com.cliffc.aa.util.SB.toString().

Here is the call graph for this function:

◆ toString()

final String com.cliffc.aa.HM.HM3.HMType.toString ( )
inherited

Definition at line 286 of file HM3.java.

286 { return _str(new SB(),new VBitSet(),true).toString(); }

References com.cliffc.aa.HM.HM3.HMType._str(), and com.cliffc.aa.util.SB.toString().

Here is the call graph for this function:

◆ union()

HMType com.cliffc.aa.HM.HM3.Oper.union ( HMType  that,
Worklist  work 
)
package

Reimplemented from com.cliffc.aa.HM.HM3.HMType.

Definition at line 418 of file HM3.java.

418  {
419  if( this==that ) return this;
420  if( !(that instanceof Oper) ) return that.union(this,work);
421  if( _uid < that._uid ) return that.union(this,work); // Minimize unique CNT values
422  Oper op2 = (Oper)that;
423  if( !_name.equals(op2._name) ||
424  _args.length != op2._args.length )
425  throw new RuntimeException("Cannot unify "+this+" and "+that);
426  for( int i=0; i<_args.length; i++ )
427  _args[i] = _args[i].union(op2._args[i],work); // Both union, and update U-F
428  if( _ids!=null ) { for( Ident id : _ids ) id._hm=null; work.addAll( _ids); }
429  if( that._ids!=null ) { for( Ident id : that._ids ) id._hm=null; work.addAll(that._ids); }
430  return that;
431  }

References com.cliffc.aa.HM.HM3.Oper._args, com.cliffc.aa.HM.HM3.HMType._ids, com.cliffc.aa.HM.HM3.Oper._name, com.cliffc.aa.HM.HM3.HMType._uid, com.cliffc.aa.HM.HM3.Oper.Oper(), and com.cliffc.aa.HM.HM3.HMType.union().

Here is the call graph for this function:

Member Data Documentation

◆ _args

◆ _ids

Ary<Ident> com.cliffc.aa.HM.HM3.HMType._ids
packageinherited

◆ _name

◆ _u

◆ _uid

◆ CNT

int com.cliffc.aa.HM.HM3.HMType.CNT
staticprivateinherited

◆ EQS

final HashMap<HMVar,HMVar> com.cliffc.aa.HM.HM3.HMType.EQS = new HashMap<>()
staticpackageinherited

Definition at line 290 of file HM3.java.

Referenced by com.cliffc.aa.HM.HM3.HMVar._eq(), and com.cliffc.aa.HM.HM3.HMType.eq().


The documentation for this class was generated from the following file:
com.cliffc.aa.HM.HM3.HMType.HMType
HMType()
Definition: HM3.java:282
com.cliffc.aa.util.BitSetSparse.tset
boolean tset(int b0, int b1)
Definition: BitSetSparse.java:6
com.cliffc.aa.HM.HM3.Oper._args
final HMType[] _args
Definition: HM3.java:396
com.cliffc.aa.HM.HM3.HMType.occurs_in
boolean occurs_in(VStack vstk, VBitSet dups)
Definition: HM3.java:301
com.cliffc.aa.HM.HM3.Oper.Oper
Oper(String name, HMType... args)
Definition: HM3.java:397
com.cliffc.aa.HM.HM3.HMType._u
HMType _u
Definition: HM3.java:278
com.cliffc.aa.util.BitSetSparse
Definition: BitSetSparse.java:4
com.cliffc.aa.HM.HM3.HMType.find
abstract HMType find()
com.cliffc.aa.HM.HM3.HMType._ids
Ary< Ident > _ids
Definition: HM3.java:283
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.HM3.HMType._uid
final int _uid
Definition: HM3.java:279
com.cliffc.aa.HM.HM3.Oper.find
HMType find()
Definition: HM3.java:417
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.HM3.HMType._eq
abstract boolean _eq(HMType v, BitSetSparse dups)
com.cliffc.aa.HM.HM3.HMType.is_top
boolean is_top()
Definition: HM3.java:289
com.cliffc.aa.HM.HM3.HMType.CNT
static int CNT
Definition: HM3.java:280
com.cliffc.aa.util.SB.p
SB p(String s)
Definition: SB.java:13
com.cliffc.aa.HM.HM3.HMType._str
abstract SB _str(SB sb, VBitSet vbs, boolean debug)
com.cliffc.aa.HM.HM3.HMType._fresh
abstract HMType _fresh(VStack vstk, HashMap< HMVar, HMVar > vars, HashMap< Oper, Oper > opers)
com.cliffc.aa.HM.HM3.HMType.EQS
static final HashMap< HMVar, HMVar > EQS
Definition: HM3.java:290
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62
com.cliffc.aa.HM.HM3.HMType.occurs_in_type
boolean occurs_in_type(HMType v, VBitSet dups)
Definition: HM3.java:310
com.cliffc.aa.HM.HM3.Oper._name
final String _name
Definition: HM3.java:395