aa
com.cliffc.aa.HM.HM1.Oper Class Reference
Inheritance diagram for com.cliffc.aa.HM.HM1.Oper:
[legend]
Collaboration diagram for com.cliffc.aa.HM.HM1.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)
 
HMType _fresh (HashSet< HMVar > nongen, HashMap< HMType, HMType > vars)
 
HMType find ()
 
HMType fresh (HashSet< HMVar > nongen)
 
boolean is_top ()
 
boolean occurs_in (HashSet< HMVar >nongen)
 
boolean occurs_in (HMType[] args)
 
boolean occurs_in_type (HMType v)
 
HMType union (HMType that)
 

Static Package Functions

static Oper fun (HMType... args)
 

Package Attributes

final HMType[] _args
 
final String _name
 
HMType _u
 

Detailed Description

Definition at line 248 of file HM1.java.

Constructor & Destructor Documentation

◆ Oper()

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

Definition at line 251 of file HM1.java.

251 { _name=name; _args=args; }

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

Referenced by com.cliffc.aa.HM.HM1.Oper.fun(), and com.cliffc.aa.HM.HM1.Oper.union().

Here is the caller graph for this function:

Member Function Documentation

◆ _fresh()

HMType com.cliffc.aa.HM.HM1.HMType._fresh ( HashSet< HMVar nongen,
HashMap< HMType, HMType vars 
)
packageinherited

Definition at line 171 of file HM1.java.

171  {
172  HMType t2 = find();
173  if( t2 instanceof HMVar ) {
174  return t2.occurs_in(nongen) //
175  ? t2 // Keep same var
176  : vars.computeIfAbsent(t2, e -> new HMVar(((HMVar)t2)._t));
177  } else {
178  Oper op = (Oper)t2;
179  HMType[] args = new HMType[op._args.length];
180  for( int i=0; i<args.length; i++ )
181  args[i] = op._args[i]._fresh(nongen,vars);
182  return new Oper(op._name,args);
183  }
184  }

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

Referenced by com.cliffc.aa.HM.HM1.HMType._fresh(), and com.cliffc.aa.HM.HM1.HMType.fresh().

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

◆ _str()

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

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

Definition at line 253 of file HM1.java.

253  {
254  if( _name.equals("->") ) {
255  sb.p("{ ");
256  for( int i=0; i<_args.length-1; i++ )
257  _args[i]._str(sb,dups,debug).p(" ");
258  sb.p("-> ");
259  _args[_args.length-1]._str(sb,dups,debug);
260  return sb.p(" }");
261  }
262  sb.p(_name).p('(');
263  for( HMType t : _args )
264  t._str(sb,dups,debug).p(',');
265  return sb.unchar().p(')');
266  }

References com.cliffc.aa.HM.HM1.Oper._args, com.cliffc.aa.HM.HM1.Oper._name, com.cliffc.aa.HM.HM1.HMType._str(), com.cliffc.aa.util.SB.p(), and com.cliffc.aa.util.SB.unchar().

Here is the call graph for this function:

◆ find()

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

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

Definition at line 268 of file HM1.java.

268 { return this; }

◆ fresh()

HMType com.cliffc.aa.HM.HM1.HMType.fresh ( HashSet< HMVar nongen)
packageinherited

Definition at line 167 of file HM1.java.

167  {
168  HashMap<HMType,HMType> vars = new HashMap<>();
169  return _fresh(nongen,vars);
170  }

References com.cliffc.aa.HM.HM1.HMType._fresh().

Referenced by com.cliffc.aa.HM.HM1.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.HM1.Oper.fun ( HMType...  args)
staticpackage

Definition at line 252 of file HM1.java.

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

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

Referenced by com.cliffc.aa.HM.HM1.HM(), com.cliffc.aa.HM.HM1.Lambda.hm(), com.cliffc.aa.HM.HM1.Lambda2.hm(), and com.cliffc.aa.HM.HM1.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.HM1.HMType.is_top ( )
packageinherited

Definition at line 165 of file HM1.java.

165 { return _u==null; }

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

Referenced by com.cliffc.aa.HM.HM1.HMType.occurs_in_type(), and com.cliffc.aa.HM.HM1.HMVar.type().

Here is the caller graph for this function:

◆ occurs_in() [1/2]

boolean com.cliffc.aa.HM.HM1.HMType.occurs_in ( HashSet< HMVar nongen)
packageinherited

Definition at line 186 of file HM1.java.

186  {
187  for( HMVar x : nongen ) if( occurs_in_type(x) ) return true;
188  return false;
189  }

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

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

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

◆ occurs_in() [2/2]

boolean com.cliffc.aa.HM.HM1.HMType.occurs_in ( HMType[]  args)
packageinherited

Definition at line 190 of file HM1.java.

190  {
191  for( HMType x : args ) if( occurs_in_type(x) ) return true;
192  return false;
193  }

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

Here is the call graph for this function:

◆ occurs_in_type()

boolean com.cliffc.aa.HM.HM1.HMType.occurs_in_type ( HMType  v)
packageinherited

Definition at line 194 of file HM1.java.

194  {
195  assert is_top();
196  HMType y = v.find();
197  if( y==this )
198  return true;
199  if( y instanceof Oper )
200  return occurs_in(((Oper)y)._args);
201  return false;
202  }

References com.cliffc.aa.HM.HM1.HMType.find(), com.cliffc.aa.HM.HM1.HMType.is_top(), and com.cliffc.aa.HM.HM1.HMType.occurs_in().

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

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

◆ str()

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

Definition at line 163 of file HM1.java.

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

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

Here is the call graph for this function:

◆ toString()

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

Definition at line 162 of file HM1.java.

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

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

Here is the call graph for this function:

◆ union()

HMType com.cliffc.aa.HM.HM1.Oper.union ( HMType  that)
package

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

Definition at line 269 of file HM1.java.

269  {
270  if( !(that instanceof Oper) ) return that.union(this);
271  Oper op2 = (Oper)that;
272  if( !_name.equals(op2._name) ||
273  _args.length != op2._args.length )
274  throw new RuntimeException("Cannot unify "+this+" and "+that);
275  for( int i=0; i<_args.length; i++ )
276  _args[i].union(op2._args[i]);
277  return this;
278  }

References com.cliffc.aa.HM.HM1.Oper._args, com.cliffc.aa.HM.HM1.Oper._name, com.cliffc.aa.HM.HM1.Oper.Oper(), and com.cliffc.aa.HM.HM1.HMType.union().

Here is the call graph for this function:

Member Data Documentation

◆ _args

final HMType [] com.cliffc.aa.HM.HM1.Oper._args
package

◆ _name

final String com.cliffc.aa.HM.HM1.Oper._name
package

◆ _u

HMType com.cliffc.aa.HM.HM1.HMType._u
packageinherited

The documentation for this class was generated from the following file:
com.cliffc.aa.HM.HM1.Oper._name
final String _name
Definition: HM1.java:249
com.cliffc.aa.HM.HM1.HMType._str
abstract SB _str(SB sb, VBitSet vbs, boolean debug)
com.cliffc.aa.HM.HM1.HMType._fresh
HMType _fresh(HashSet< HMVar > nongen, HashMap< HMType, HMType > vars)
Definition: HM1.java:171
com.cliffc.aa.HM.HM1.Oper._args
final HMType[] _args
Definition: HM1.java:250
com.cliffc.aa.HM.HM1.HMType.occurs_in_type
boolean occurs_in_type(HMType v)
Definition: HM1.java:194
com.cliffc.aa.HM.HM1.HMType.is_top
boolean is_top()
Definition: HM1.java:165
com.cliffc.aa.util.SB.unchar
SB unchar()
Definition: SB.java:58
com.cliffc.aa.HM.HM1.Oper._str
SB _str(SB sb, VBitSet dups, boolean debug)
Definition: HM1.java:253
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.util.SB.p
SB p(String s)
Definition: SB.java:13
com.cliffc.aa.HM.HM1.HMType.occurs_in
boolean occurs_in(HashSet< HMVar >nongen)
Definition: HM1.java:186
com.cliffc.aa.HM.HM1.Oper.Oper
Oper(String name, HMType... args)
Definition: HM1.java:251
com.cliffc.aa.HM.HM1.HMType._u
HMType _u
Definition: HM1.java:159
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62
com.cliffc.aa.HM.HM1.HMType.find
abstract HMType find()