aa
com.cliffc.aa.HM.HM9.Root Class Reference
Inheritance diagram for com.cliffc.aa.HM.HM9.Root:
[legend]
Collaboration diagram for com.cliffc.aa.HM.HM9.Root:
[legend]

Public Member Functions

String p ()
 
final String toString ()
 

Package Functions

 Root (Syntax body)
 
void add_hm_work (Worklist work)
 
void add_val_work (Syntax child, Worklist work)
 
T2 debug_find ()
 
T2 find ()
 
Type flow_type ()
 
boolean hm (Worklist work)
 
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)
 
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)
 
Type val (Worklist work)
 

Static Package Functions

static Type widen (T2 t2)
 

Package Attributes

final Syntax[] _args
 
Type _flow
 
final Syntax _fun
 
T2 _hmt
 
VStack _nongen
 
Syntax _par
 

Private Member Functions

T2 is_if_nil ()
 

Static Private Member Functions

static Type add_sig (Type t)
 
static Type xval (TypeFunPtr fun)
 

Static Private Attributes

static final HashMap< T2, TypeT2MAP = new HashMap<>()
 
static final NonBlockingHashMapLong< String > WDUPS = new NonBlockingHashMapLong<>()
 

Detailed Description

Definition at line 735 of file HM9.java.

Constructor & Destructor Documentation

◆ Root()

com.cliffc.aa.HM.HM9.Root.Root ( Syntax  body)
package

Definition at line 736 of file HM9.java.

736 { super(body); }

Member Function Documentation

◆ add_hm_work()

void com.cliffc.aa.HM.HM9.Root.add_hm_work ( Worklist  work)
package

Reimplemented from com.cliffc.aa.HM.HM9.Apply.

Definition at line 739 of file HM9.java.

739 { }

◆ add_sig()

static Type com.cliffc.aa.HM.HM9.Root.add_sig ( Type  t)
staticprivate

Definition at line 759 of file HM9.java.

759  {
760  if( t instanceof TypeFunPtr ) {
761  Type rez = add_sig(xval((TypeFunPtr)t));
763  } else {
764  return t;
765  }
766  }

References com.cliffc.aa.type.TypeFunSig.make(), com.cliffc.aa.type.TypeTuple.make_args(), com.cliffc.aa.type.TypeTuple.make_ret(), and com.cliffc.aa.HM.HM9.Root.xval().

Referenced by com.cliffc.aa.HM.HM9.Root.flow_type().

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

◆ add_val_work()

void com.cliffc.aa.HM.HM9.Apply.add_val_work ( Syntax  child,
Worklist  work 
)
packageinherited

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

Definition at line 687 of file HM9.java.

687  {
688  // If function changes type, recompute self
689  if( child==_fun ) work.push(this);
690  // If an argument changes type, adjust the lambda arg types
691  Type flow = _fun._flow;
692  if( flow.above_center() ) return;
693  if( !(flow instanceof TypeFunPtr) ) return;
694  // Meet the actuals over the formals.
695  for( int fidx : ((TypeFunPtr)flow)._fidxs ) {
696  Lambda fun = Lambda.FUNS.get(fidx);
697  if( fun!=null ) {
698  fun.find().push_update(this); // Discovered as call-site; if the Lambda changes the Apply needs to be revisited.
699  for( int i=0; i<fun._types.length; i++ ) {
700  Type formal = fun._types[i];
701  Type actual = this instanceof Root ? Root.widen(fun.targ(i)) : _args[i]._flow;
702  Type rez = formal.meet(actual);
703  if( formal != rez ) {
704  fun._types[i] = rez;
705  work.addAll(fun.targ(i)._deps);
706  work.push(fun._body);
707  if( i==0 && fun instanceof If ) work.push(fun); // Specifically If might need more unification
708  }
709  }
710  }
711  }
712  }

References com.cliffc.aa.HM.HM9.Apply._args, com.cliffc.aa.HM.HM9.Lambda._body, com.cliffc.aa.HM.HM9.T2._deps, com.cliffc.aa.HM.HM9.Syntax._flow, com.cliffc.aa.HM.HM9.Apply._fun, com.cliffc.aa.HM.HM9.Lambda._types, com.cliffc.aa.type.Type< T extends Type< T >.above_center(), com.cliffc.aa.HM.HM9.Worklist.addAll(), com.cliffc.aa.HM.HM9.Syntax.find(), com.cliffc.aa.HM.HM9.Lambda.FUNS, com.cliffc.aa.type.Type< T extends Type< T >.meet(), com.cliffc.aa.HM.HM9.Worklist.push(), com.cliffc.aa.HM.HM9.T2.push_update(), com.cliffc.aa.HM.HM9.Lambda.targ(), and com.cliffc.aa.HM.HM9.Root.widen().

Referenced by com.cliffc.aa.HM.HM9.Root.val().

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

◆ debug_find()

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

Definition at line 329 of file HM9.java.

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

References com.cliffc.aa.HM.HM9.Syntax._hmt, and com.cliffc.aa.HM.HM9.T2.debug_find().

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

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

◆ find()

◆ flow_type()

Type com.cliffc.aa.HM.HM9.Root.flow_type ( )
package

Definition at line 757 of file HM9.java.

757 { return add_sig(_flow); }

References com.cliffc.aa.HM.HM9.Syntax._flow, and com.cliffc.aa.HM.HM9.Root.add_sig().

Here is the call graph for this function:

◆ hm()

boolean com.cliffc.aa.HM.HM9.Root.hm ( Worklist  work)
package

Reimplemented from com.cliffc.aa.HM.HM9.Apply.

Definition at line 738 of file HM9.java.

738 { return find().unify(_fun.find(),work); }

References com.cliffc.aa.HM.HM9.Apply._fun, com.cliffc.aa.HM.HM9.Syntax.find(), and com.cliffc.aa.HM.HM9.T2.unify().

Here is the call graph for this function:

◆ is_if_nil()

T2 com.cliffc.aa.HM.HM9.Apply.is_if_nil ( )
privateinherited

Definition at line 729 of file HM9.java.

729  {
730  return _fun instanceof If && _args[0] instanceof Ident ? _args[0].find() : null;
731  }

References com.cliffc.aa.HM.HM9.Apply._args, com.cliffc.aa.HM.HM9.Apply._fun, and com.cliffc.aa.HM.HM9.Syntax.find().

Referenced by com.cliffc.aa.HM.HM9.Apply.hm(), and com.cliffc.aa.HM.HM9.Apply.prep_tree().

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

◆ more_work()

boolean com.cliffc.aa.HM.HM9.Apply.more_work ( Worklist  work)
packageinherited

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

Definition at line 722 of file HM9.java.

722  {
723  if( !more_work_impl(work) ) return false;
724  if( !_fun.more_work(work) ) return false;
725  for( Syntax arg : _args ) if( !arg.more_work(work) ) return false;
726  return true;
727  }

References com.cliffc.aa.HM.HM9.Apply._args, com.cliffc.aa.HM.HM9.Apply._fun, com.cliffc.aa.HM.HM9.Syntax.more_work(), and com.cliffc.aa.HM.HM9.Syntax.more_work_impl().

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

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

◆ more_work_impl()

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

Definition at line 362 of file HM9.java.

362  {
363  if( work.has(this) ) return true;
364  if( DO_HM && hm(null) ) // Any more HM work?
365  return false; // Found HM work not on worklist
366  if( DO_GCP && val(null)!=_flow )
367  return false; // Found GCP work not on worklist
368  return true;
369  }

References com.cliffc.aa.HM.HM9.Syntax._flow, com.cliffc.aa.HM.HM9.DO_GCP, com.cliffc.aa.HM.HM9.DO_HM, com.cliffc.aa.HM.HM9.Worklist.has(), com.cliffc.aa.HM.HM9.Syntax.hm(), and com.cliffc.aa.HM.HM9.Syntax.val().

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

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

◆ p()

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

Definition at line 374 of file HM9.java.

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

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

Here is the call graph for this function:

◆ p0()

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

Definition at line 375 of file HM9.java.

375  {
376  _hmt.get_dups(dups);
377  VBitSet visit = new VBitSet();
378  p1(sb.i());
379  if( DO_HM ) _hmt .str(sb.p(", HM="), visit,dups);
380  if( DO_GCP ) _flow.str(sb.p(", CCP="),visit.clr(),null,false);
381  sb.nl();
382  return p2(sb.ii(1),dups).di(1);
383  }

References com.cliffc.aa.HM.HM9.Syntax._flow, com.cliffc.aa.HM.HM9.Syntax._hmt, com.cliffc.aa.util.VBitSet.clr(), com.cliffc.aa.util.SB.di(), com.cliffc.aa.HM.HM9.DO_GCP, com.cliffc.aa.HM.HM9.DO_HM, com.cliffc.aa.HM.HM9.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.HM9.Syntax.p1(), com.cliffc.aa.HM.HM9.Syntax.p2(), com.cliffc.aa.type.Type< T extends Type< T >.str(), and com.cliffc.aa.HM.HM9.T2.str().

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

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

◆ p1()

SB com.cliffc.aa.HM.HM9.Apply.p1 ( SB  sb)
packageinherited

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

Definition at line 591 of file HM9.java.

591 { return sb.p("(...)"); }

References com.cliffc.aa.util.SB.p().

Here is the call graph for this function:

◆ p2()

SB com.cliffc.aa.HM.HM9.Apply.p2 ( SB  sb,
VBitSet  dups 
)
packageinherited

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

Definition at line 592 of file HM9.java.

592  {
593  _fun.p0(sb,dups);
594  for( Syntax arg : _args ) arg.p0(sb,dups);
595  return sb;
596  }

References com.cliffc.aa.HM.HM9.Apply._args, com.cliffc.aa.HM.HM9.Apply._fun, and com.cliffc.aa.HM.HM9.Syntax.p0().

Here is the call graph for this function:

◆ prep_lookup_deps()

void com.cliffc.aa.HM.HM9.Syntax.prep_lookup_deps ( Ident  id)
packageinherited

Reimplemented in com.cliffc.aa.HM.HM9.Let, and com.cliffc.aa.HM.HM9.Lambda.

Definition at line 358 of file HM9.java.

358 {}

◆ prep_tree()

int com.cliffc.aa.HM.HM9.Apply.prep_tree ( Syntax  par,
VStack  nongen,
Worklist  work 
)
packageinherited

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

Definition at line 714 of file HM9.java.

714  {
715  prep_tree_impl(par,nongen,work,T2.make_leaf());
716  int cnt = 1+_fun.prep_tree(this,nongen,work);
717  for( Syntax arg : _args ) cnt += arg.prep_tree(this,nongen,work);
718  T2 str = is_if_nil();
719  if( str!=null ) str.push_update(this);
720  return cnt;
721  }

References com.cliffc.aa.HM.HM9.Apply._args, com.cliffc.aa.HM.HM9.Apply._fun, com.cliffc.aa.HM.HM9.Apply.is_if_nil(), com.cliffc.aa.HM.HM9.T2.make_leaf(), com.cliffc.aa.HM.HM9.Syntax.prep_tree(), com.cliffc.aa.HM.HM9.Syntax.prep_tree_impl(), and com.cliffc.aa.HM.HM9.Apply.str().

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

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

◆ prep_tree_impl()

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

Definition at line 351 of file HM9.java.

351  {
352  _par = par;
353  _hmt = t;
354  _flow= Type.XSCALAR;
355  _nongen = nongen;
356  work.push(this);
357  }

References com.cliffc.aa.HM.HM9.Syntax._flow, com.cliffc.aa.HM.HM9.Syntax._hmt, com.cliffc.aa.HM.HM9.Syntax._nongen, com.cliffc.aa.HM.HM9.Syntax._par, com.cliffc.aa.HM.HM9.Worklist.push(), and com.cliffc.aa.type.Type< T extends Type< T >.XSCALAR.

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

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

◆ str()

SB com.cliffc.aa.HM.HM9.Root.str ( SB  sb)
package

Reimplemented from com.cliffc.aa.HM.HM9.Apply.

Definition at line 737 of file HM9.java.

737 { return _fun.str(sb); }

References com.cliffc.aa.HM.HM9.Apply._fun, and com.cliffc.aa.HM.HM9.Syntax.str().

Here is the call graph for this function:

◆ toString()

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

Definition at line 371 of file HM9.java.

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

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

Referenced by com.cliffc.aa.HM.HM9.Lambda.p1().

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

◆ val()

Type com.cliffc.aa.HM.HM9.Root.val ( Worklist  work)
package

Reimplemented from com.cliffc.aa.HM.HM9.Apply.

Definition at line 749 of file HM9.java.

749  {
750  // Here we do some extra work, "as if" our arguments (which only lazily exist)
751  // may have had their types change.
752  add_val_work(null,work);
753 
754  return _fun._flow;
755  }

References com.cliffc.aa.HM.HM9.Syntax._flow, com.cliffc.aa.HM.HM9.Apply._fun, and com.cliffc.aa.HM.HM9.Apply.add_val_work().

Here is the call graph for this function:

◆ widen()

static Type com.cliffc.aa.HM.HM9.Root.widen ( T2  t2)
staticpackage

Definition at line 742 of file HM9.java.

742 { return t2.as_flow(); }

References com.cliffc.aa.HM.HM9.T2.as_flow().

Referenced by com.cliffc.aa.HM.HM9.Apply.add_val_work(), and com.cliffc.aa.HM.HM9.Pair1.Pair1X.apply().

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

◆ xval()

static Type com.cliffc.aa.HM.HM9.Root.xval ( TypeFunPtr  fun)
staticprivate

Definition at line 743 of file HM9.java.

743  {
744  Type rez = Type.XSCALAR;
745  for( int fidx : fun._fidxs )
746  rez = rez.meet(Lambda.FUNS.get(fidx).apply(null));
747  return rez;
748  }

References com.cliffc.aa.type.TypeFunPtr._fidxs, com.cliffc.aa.HM.HM9.Lambda.FUNS, com.cliffc.aa.type.Type< T extends Type< T >.meet(), and com.cliffc.aa.type.Type< T extends Type< T >.XSCALAR.

Referenced by com.cliffc.aa.HM.HM9.Root.add_sig().

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

Member Data Documentation

◆ _args

◆ _flow

◆ _fun

◆ _hmt

◆ _nongen

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

◆ _par

◆ T2MAP

final HashMap<T2,Type> com.cliffc.aa.HM.HM9.Apply.T2MAP = new HashMap<>()
staticprivateinherited

◆ WDUPS

final NonBlockingHashMapLong<String> com.cliffc.aa.HM.HM9.Apply.WDUPS = new NonBlockingHashMapLong<>()
staticprivateinherited

The documentation for this class was generated from the following file:
com.cliffc.aa.HM.HM9.Syntax.prep_tree_impl
final void prep_tree_impl(Syntax par, VStack nongen, Worklist work, T2 t)
Definition: HM9.java:351
com.cliffc.aa.type.TypeFunPtr
Definition: TypeFunPtr.java:23
com.cliffc.aa.type.TypeTuple.make_args
static TypeTuple make_args(Type[] ts)
Definition: TypeTuple.java:106
com.cliffc.aa.HM.HM9.Syntax.hm
abstract boolean hm(Worklist work)
com.cliffc.aa.type.TypeTuple.make_ret
static TypeTuple make_ret(Type trez)
Definition: TypeTuple.java:120
com.cliffc.aa.HM.HM9.Syntax.more_work
abstract boolean more_work(Worklist work)
com.cliffc.aa.util.SB.ii
SB ii(int i)
Definition: SB.java:44
com.cliffc.aa.HM.HM9.Apply._fun
final Syntax _fun
Definition: HM9.java:582
com.cliffc.aa.HM.HM9.Syntax.find
T2 find()
Definition: HM9.java:325
com.cliffc.aa.util.SB.di
SB di(int i)
Definition: SB.java:46
com.cliffc.aa.type.Type.widen
Type widen()
Definition: Type.java:828
com.cliffc.aa.type.Type.XSCALAR
static final Type XSCALAR
Definition: Type.java:329
com.cliffc.aa.HM.HM9.Syntax.p0
final SB p0(SB sb, VBitSet dups)
Definition: HM9.java:375
com.cliffc.aa.type.Type
an implementation of language AA
Definition: Type.java:94
com.cliffc.aa.type.TypeFunSig.make
static TypeFunSig make(String[] args, TypeTuple formals, TypeTuple ret)
Definition: TypeFunSig.java:71
com.cliffc.aa.type.TypeTuple
Definition: TypeTuple.java:11
com.cliffc.aa.type.TypeFunPtr._fidxs
BitsFun _fidxs
Definition: TypeFunPtr.java:26
com.cliffc.aa.util.VBitSet.clr
VBitSet clr()
Definition: VBitSet.java:9
com.cliffc.aa.type.Type.meet
final Type meet(Type t)
Definition: Type.java:412
com.cliffc.aa.type.Type.str
SB str(SB sb, VBitSet dups, TypeMem mem, boolean debug)
Definition: Type.java:131
com.cliffc.aa.HM.HM9.Syntax.p1
abstract SB p1(SB sb)
com.cliffc.aa.HM.HM9.T2.find
T2 find()
Definition: HM9.java:1355
com.cliffc.aa.type.Type.above_center
boolean above_center()
Definition: Type.java:741
com.cliffc.aa.HM.HM9.Apply._args
final Syntax[] _args
Definition: HM9.java:583
com.cliffc.aa.HM.HM9.Syntax._hmt
T2 _hmt
Definition: HM9.java:324
com.cliffc.aa.HM.HM9.T2.debug_find
T2 debug_find()
Definition: HM9.java:1344
com.cliffc.aa.HM.HM9.Apply.add_val_work
void add_val_work(Syntax child, Worklist work)
Definition: HM9.java:687
com.cliffc.aa.HM.HM9.Syntax.more_work_impl
final boolean more_work_impl(Worklist work)
Definition: HM9.java:362
com.cliffc.aa.HM.HM9.T2.str
SB str(SB sb, VBitSet visit, VBitSet dups)
Definition: HM9.java:2040
com.cliffc.aa.util.VBitSet
Definition: VBitSet.java:5
com.cliffc.aa.HM.HM9.Apply.is_if_nil
T2 is_if_nil()
Definition: HM9.java:729
com.cliffc.aa.util.SB
Tight/tiny StringBuilder wrapper.
Definition: SB.java:8
com.cliffc.aa.HM.HM9.Syntax.str
abstract SB str(SB sb)
com.cliffc.aa.HM.HM9.Root.xval
static Type xval(TypeFunPtr fun)
Definition: HM9.java:743
com.cliffc.aa.HM.HM9.Apply.str
SB str(SB sb)
Definition: HM9.java:585
com.cliffc.aa.util.SB.nl
SB nl()
Definition: SB.java:48
com.cliffc.aa.util.SB.p
SB p(String s)
Definition: SB.java:13
com.cliffc.aa.type.TypeFunSig
Definition: TypeFunSig.java:10
com.cliffc.aa.HM.HM9.Root.add_sig
static Type add_sig(Type t)
Definition: HM9.java:759
com.cliffc.aa.HM.HM9.Syntax.prep_tree
abstract int prep_tree(Syntax par, VStack nongen, Worklist work)
com.cliffc.aa.HM.HM9.Syntax._nongen
VStack _nongen
Definition: HM9.java:323
com.cliffc.aa.util.SB.i
SB i(int d)
Definition: SB.java:38
com.cliffc.aa.HM.HM9.DO_GCP
static final boolean DO_GCP
Definition: HM9.java:79
com.cliffc.aa.HM.HM9.T2.unify
boolean unify(T2 that, Worklist work)
Definition: HM9.java:1528
com.cliffc.aa.HM.HM9.Syntax.p2
abstract SB p2(SB sb, VBitSet dups)
com.cliffc.aa.HM.HM9.DO_HM
static final boolean DO_HM
Definition: HM9.java:78
com.cliffc.aa.HM.HM9.Syntax._flow
Type _flow
Definition: HM9.java:332
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62
com.cliffc.aa.HM.HM9.T2.get_dups
VBitSet get_dups(VBitSet dups)
Definition: HM9.java:2025
com.cliffc.aa.HM.HM9.Syntax.val
abstract Type val(Worklist work)
com.cliffc.aa.HM.HM9.Syntax._par
Syntax _par
Definition: HM9.java:322