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

Public Member Functions

String _str ()
 
String str ()
 
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 265 of file HM2.java.

Constructor & Destructor Documentation

◆ Oper()

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

Definition at line 268 of file HM2.java.

268 { _name=name; _args=args; }

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

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

Here is the caller graph for this function:

Member Function Documentation

◆ _fresh()

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

Definition at line 186 of file HM2.java.

186  {
187  HMType t2 = find();
188  if( t2 instanceof HMVar ) {
189  return t2.occurs_in(nongen) //
190  ? t2 // Keep same var
191  : vars.computeIfAbsent(t2, e -> new HMVar(((HMVar)t2)._t));
192  } else {
193  Oper op = (Oper)t2;
194  HMType[] args = new HMType[op._args.length];
195  for( int i=0; i<args.length; i++ )
196  args[i] = op._args[i]._fresh(nongen,vars);
197  return new Oper(op._name,args);
198  }
199  }

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

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

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

◆ _str()

String com.cliffc.aa.HM.HM2.Oper._str ( )

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

Definition at line 274 of file HM2.java.

274  {
275  if( _name.equals("->") )
276  return "{ "+_args[0].str()+" -> "+_args[1].str()+" }";
277  SB sb = new SB().p(_name).p('(');
278  for( HMType t : _args )
279  sb.p(t.str()).p(',');
280  return sb.unchar().p(')').toString();
281  }

References com.cliffc.aa.HM.HM2.Oper._args, com.cliffc.aa.HM.HM2.Oper._name, com.cliffc.aa.util.SB.p(), com.cliffc.aa.HM.HM2.HMType.str(), com.cliffc.aa.util.SB.toString(), and com.cliffc.aa.util.SB.unchar().

Here is the call graph for this function:

◆ find()

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

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

Definition at line 283 of file HM2.java.

283 { return this; }

◆ fresh()

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

Definition at line 182 of file HM2.java.

182  {
183  HashMap<HMType,HMType> vars = new HashMap<>();
184  return _fresh(nongen,vars);
185  }

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

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

Definition at line 269 of file HM2.java.

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

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

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

Definition at line 180 of file HM2.java.

180 { return _u==null; }

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

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

Here is the caller graph for this function:

◆ occurs_in() [1/2]

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

Definition at line 201 of file HM2.java.

201  {
202  for( HMVar x : nongen ) if( occurs_in_type(x) ) return true;
203  return false;
204  }

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

Referenced by com.cliffc.aa.HM.HM2.HMType._fresh(), and com.cliffc.aa.HM.HM2.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.HM2.HMType.occurs_in ( HMType[]  args)
packageinherited

Definition at line 205 of file HM2.java.

205  {
206  for( HMType x : args ) if( occurs_in_type(x) ) return true;
207  return false;
208  }

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

Here is the call graph for this function:

◆ occurs_in_type()

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

Definition at line 209 of file HM2.java.

209  {
210  assert is_top();
211  HMType y = v.find();
212  if( y==this )
213  return true;
214  if( y instanceof Oper )
215  return occurs_in(((Oper)y)._args);
216  return false;
217  }

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

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

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

◆ str()

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

Definition at line 178 of file HM2.java.

178 { return find()._str(); }

References com.cliffc.aa.HM.HM2.HMType._str(), and com.cliffc.aa.HM.HM2.HMType.find().

Referenced by com.cliffc.aa.HM.HM2.Oper._str().

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

◆ toString()

String com.cliffc.aa.HM.HM2.Oper.toString ( )

Definition at line 270 of file HM2.java.

270  {
271  if( _name.equals("->") ) return "{ "+_args[0]+" -> "+_args[1]+" }";
272  return _name+" "+Arrays.toString(_args);
273  }

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

◆ union()

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

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

Definition at line 284 of file HM2.java.

284  {
285  if( !(that instanceof Oper) ) return that.union(this);
286  Oper op2 = (Oper)that;
287  if( !_name.equals(op2._name) ||
288  _args.length != op2._args.length )
289  throw new RuntimeException("Cannot unify "+this+" and "+that);
290  for( int i=0; i<_args.length; i++ )
291  _args[i].union(op2._args[i]);
292  return this;
293  }

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

Here is the call graph for this function:

Member Data Documentation

◆ _args

◆ _name

◆ _u

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

The documentation for this class was generated from the following file:
com.cliffc.aa.HM.HM2.HMType._u
HMType _u
Definition: HM2.java:175
com.cliffc.aa.HM.HM2.HMType.is_top
boolean is_top()
Definition: HM2.java:180
com.cliffc.aa.HM.HM2.HMType._fresh
HMType _fresh(HashSet< HMVar > nongen, HashMap< HMType, HMType > vars)
Definition: HM2.java:186
com.cliffc.aa.util.SB.unchar
SB unchar()
Definition: SB.java:58
com.cliffc.aa.HM.HM2.HMType.occurs_in
boolean occurs_in(HashSet< HMVar >nongen)
Definition: HM2.java:201
com.cliffc.aa.HM.HM2.HMType.str
String str()
Definition: HM2.java:178
com.cliffc.aa.HM.HM2.HMType.find
abstract HMType find()
com.cliffc.aa.HM.HM2.Oper._name
final String _name
Definition: HM2.java:266
com.cliffc.aa.HM.HM2.HMType.occurs_in_type
boolean occurs_in_type(HMType v)
Definition: HM2.java:209
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.HM2.Oper.Oper
Oper(String name, HMType... args)
Definition: HM2.java:268
com.cliffc.aa.HM.HM2.HMType._str
abstract String _str()
com.cliffc.aa.HM.HM2.Oper._args
final HMType[] _args
Definition: HM2.java:267
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62