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

Classes

class  Apply
 
class  Con
 
class  HMType
 
class  HMVar
 
class  Ident
 
class  Lambda
 
class  Let
 
class  Oper
 
class  Syntax
 
class  VStack
 
class  Worklist
 

Static Public Member Functions

static HMType hm (Syntax prog)
 

Static Package Functions

static void reset ()
 

Static Package Attributes

static final HashMap< String, HMTypeENV = new HashMap<>()
 

Detailed Description

Definition at line 31 of file HM3.java.

Member Function Documentation

◆ hm()

static HMType com.cliffc.aa.HM.HM3.hm ( Syntax  prog)
static

Definition at line 34 of file HM3.java.

34  {
35  // Simple types
36  HMVar bool = new HMVar(TypeInt.BOOL);
37  HMVar int64 = new HMVar(TypeInt.INT64);
38  HMVar flt64 = new HMVar(TypeFlt.FLT64);
39  HMVar strp = new HMVar(TypeMemPtr.STRPTR);
40 
41  // Primitives
42  HMVar var1 = new HMVar();
43  HMVar var2 = new HMVar();
44  ENV.put("pair",Oper.fun(var1, Oper.fun(var2, new Oper("pair",var1,var2))));
45 
46  // { pred:bool lhs:var3 rhs:var3 -> var3 }
47  HMVar var3 = new HMVar();
48  ENV.put("if/else",Oper.fun(bool,Oper.fun(var3,Oper.fun(var3,var3))));
49 
50  ENV.put("dec",Oper.fun(int64,int64));
51  ENV.put("*",Oper.fun(int64,Oper.fun(int64,int64)));
52  ENV.put("==0",Oper.fun(int64,bool));
53 
54  // Print a string; int->str
55  ENV.put("str",Oper.fun(int64,strp));
56  // Factor
57  ENV.put("factor",Oper.fun(flt64,new Oper("pair",flt64,flt64)));
58 
59 
60  // Prep for SSA: pre-gather all the (unique) ids. Store a linked-list of
61  // non-generative IDs (those mid-definition in Lambda & Let, or in the old
62  // "nongen" HashSet), for use by Ident.hm.
63  final Worklist work = new Worklist();
64  prog.get_ids(null,work);
65 
66  // Worklist:
67  int cnt=0;
68  while( work.len()>0 ) { // While not empty
69  Syntax s = work.pop(); // Get work
70  HMType nnn = s.hm(work);
71  if( nnn!=null ) { // If progress
72  s._hm = nnn; // Move progress state
73  s.add_neighbors(work); // Neighbors get reinspected for progress
74  }
75  assert prog.check_progress(work); // Everything that can make progress is on the worklist
76  cnt++; // Which iter count, for debug only
77  }
78  return prog._hm;
79  }

References com.cliffc.aa.HM.HM3.Syntax._hm, com.cliffc.aa.HM.HM3.Syntax.add_neighbors(), com.cliffc.aa.type.TypeInt.BOOL, com.cliffc.aa.HM.HM3.Syntax.check_progress(), com.cliffc.aa.HM.HM3.ENV, com.cliffc.aa.type.TypeFlt.FLT64, com.cliffc.aa.HM.HM3.Oper.fun(), com.cliffc.aa.HM.HM3.Syntax.get_ids(), com.cliffc.aa.HM.HM3.Syntax.hm(), com.cliffc.aa.type.TypeInt.INT64, com.cliffc.aa.HM.HM3.Worklist.len(), com.cliffc.aa.HM.HM3.Worklist.pop(), and com.cliffc.aa.type.TypeMemPtr.STRPTR.

Referenced by com.cliffc.aa.HM.TestHM3.test00(), com.cliffc.aa.HM.TestHM3.test01(), com.cliffc.aa.HM.TestHM3.test02(), com.cliffc.aa.HM.TestHM3.test03(), com.cliffc.aa.HM.TestHM3.test04(), com.cliffc.aa.HM.TestHM3.test05(), com.cliffc.aa.HM.TestHM3.test05a(), com.cliffc.aa.HM.TestHM3.test06(), com.cliffc.aa.HM.TestHM3.test07(), com.cliffc.aa.HM.TestHM3.test08(), com.cliffc.aa.HM.TestHM3.test09(), com.cliffc.aa.HM.TestHM3.test10(), com.cliffc.aa.HM.TestHM3.test11(), and com.cliffc.aa.HM.TestHM3.test12().

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

◆ reset()

static void com.cliffc.aa.HM.HM3.reset ( )
staticpackage

Definition at line 80 of file HM3.java.

80 { ENV.clear(); HMType.reset(); }

References com.cliffc.aa.HM.HM3.ENV, and com.cliffc.aa.HM.HM3.HMType.reset().

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

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

Member Data Documentation

◆ ENV


The documentation for this class was generated from the following file:
com.cliffc.aa.type.TypeInt
Definition: TypeInt.java:9
com.cliffc.aa.type.TypeFlt
Definition: TypeFlt.java:9
com.cliffc.aa.type.TypeInt.INT64
static final TypeInt INT64
Definition: TypeInt.java:39
com.cliffc.aa.HM.HM3.ENV
static final HashMap< String, HMType > ENV
Definition: HM3.java:32
com.cliffc.aa.type.TypeMemPtr.STRPTR
static final TypeMemPtr STRPTR
Definition: TypeMemPtr.java:97
com.cliffc.aa.type.TypeInt.BOOL
static final TypeInt BOOL
Definition: TypeInt.java:43
com.cliffc.aa.type.TypeMemPtr
Definition: TypeMemPtr.java:14
com.cliffc.aa.type.TypeFlt.FLT64
static final TypeFlt FLT64
Definition: TypeFlt.java:38