aa
com.cliffc.aa.HM.HM8.Apply Class Reference
Inheritance diagram for com.cliffc.aa.HM.HM8.Apply:
[legend]
Collaboration diagram for com.cliffc.aa.HM.HM8.Apply:
[legend]

Public Member Functions

String p ()
 
final String toString ()
 

Package Functions

 Apply (Syntax fun, Syntax... args)
 
void add_work (Worklist work)
 
T2 debug_find ()
 
T2 find ()
 
boolean hm (Worklist work)
 
T2 lookup (String name)
 
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)
 
T2 post ()
 
T2 pre ()
 
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)
 

Package Attributes

final Syntax[] _args
 
final Syntax _fun
 
VStack _nongen
 
Syntax _par
 
T2 _post
 
T2 _pre
 
T2 _t
 

Private Member Functions

T2 is_if_nil ()
 

Detailed Description

Definition at line 475 of file HM8.java.

Constructor & Destructor Documentation

◆ Apply()

com.cliffc.aa.HM.HM8.Apply.Apply ( Syntax  fun,
Syntax...  args 
)
package

Definition at line 478 of file HM8.java.

478 { _fun = fun; _args = args; }

References com.cliffc.aa.HM.HM8.Apply._args, and com.cliffc.aa.HM.HM8.Apply._fun.

Member Function Documentation

◆ add_work()

void com.cliffc.aa.HM.HM8.Apply.add_work ( Worklist  work)
package

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

Definition at line 550 of file HM8.java.

550  {
551  work.push(_par);
552  for( Syntax arg : _args ) work.push(arg);
553  }

References com.cliffc.aa.HM.HM8.Apply._args, com.cliffc.aa.HM.HM8.Syntax._par, and com.cliffc.aa.HM.HM8.Worklist.push().

Here is the call graph for this function:

◆ debug_find()

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

Definition at line 249 of file HM8.java.

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

References com.cliffc.aa.HM.HM8.Syntax._t, and com.cliffc.aa.HM.HM8.T2.debug_find().

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

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

◆ find()

T2 com.cliffc.aa.HM.HM8.Syntax.find ( )
packageinherited

Definition at line 245 of file HM8.java.

245  { // U-F find
246  T2 t = _t.find();
247  return t==_t ? t : (_t=t);
248  }

References com.cliffc.aa.HM.HM8.Syntax._t, and com.cliffc.aa.HM.HM8.T2.find().

Referenced by com.cliffc.aa.HM.HM8.T2._occurs_in(), com.cliffc.aa.HM.HM8.Lambda.add_work(), com.cliffc.aa.HM.HM8.Let.add_work(), com.cliffc.aa.HM.HM8.Ident.hm(), com.cliffc.aa.HM.HM8.Lambda.hm(), com.cliffc.aa.HM.HM8.Let.hm(), com.cliffc.aa.HM.HM8.Apply.hm(), com.cliffc.aa.HM.HM8.Struct.hm(), com.cliffc.aa.HM.HM8.Field.hm(), com.cliffc.aa.HM.HM8.Apply.is_if_nil(), and com.cliffc.aa.HM.HM8.Struct.prep_tree().

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

◆ hm()

boolean com.cliffc.aa.HM.HM8.Apply.hm ( Worklist  work)
package

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

Definition at line 494 of file HM8.java.

494  {
495  // U/F link pre/post memory with argument memories
496  boolean progress = false;
497  progress |= pre().unify(_fun.pre(),work);
498  if( work==null && progress ) return true;
499  progress |= _fun.post().unify(_args[0].pre(),work);
500  if( work==null && progress ) return true;
501  for( int i=1; i<_args.length; i++ ) {
502  progress |= _args[i-1].post().unify(_args[i].pre(),work);
503  if( work==null && progress ) return true;
504  }
505  progress |= _args[_args.length-1].post().unify(post(),work);
506  if( work==null && progress ) return true;
507 
508  // Discover not-nil in the trivial case of directly using the 'if'
509  // primitive against a T2.is_struct(). Will not work if 'if' is some
510  // more hidden or complex function (e.q. '&&' or '||') or the predicate
511  // implies not-null on some other struct.
512  T2 str = is_if_nil();
513  if( str!=null && str.is_struct() && str._con==null ) {
514  if( work==null ) return true;
515  progress = true;
516  str._con = Type.NIL; // Add nil to a struct
517  work.addAll(str._deps);
518  }
519 
520  // Progress if:
521  // _fun is not a function
522  // any arg-pair-unifies make progress
523  // this-unify-_fun.return makes progress
524  T2 tfun = _fun.find();
525  if( !tfun.is_fun() ) {
526  if( tfun.is_err() ) return find().unify(tfun,work);
527  if( work==null ) return true; // Will-progress & just-testing
528  T2[] targs = new T2[_args.length+1];
529  for( int i=0; i<_args.length; i++ )
530  targs[i] = _args[i].find();
531  targs[_args.length] = find(); // Return
532  T2 nfun = T2.make_fun(targs);
533  progress = tfun.unify(nfun,work);
534  return tfun.find().is_err() ? find().unify(tfun.find(),work) : progress;
535  }
536 
537  if( tfun._args.length != _args.length+1 )
538  progress |= T2.make_err("Mismatched argument lengths").unify(find(),work);
539  // Check for progress amongst arg pairs
540  for( int i=0; i<_args.length; i++ ) {
541  progress |= tfun.args(i).unify(_args[i].find(),work);
542  if( progress && work==null )
543  return true; // Will-progress & just-testing early exit
544  }
545  progress |= tfun.args(_args.length).unify(find(),work);
546  if( tfun.find().is_err() ) return find().unify(tfun.find(),work);
547  return progress;
548  }

References com.cliffc.aa.HM.HM8.Apply._args, com.cliffc.aa.HM.HM8.T2._args, com.cliffc.aa.HM.HM8.Apply._fun, com.cliffc.aa.HM.HM8.Worklist.addAll(), com.cliffc.aa.HM.HM8.T2.args(), com.cliffc.aa.HM.HM8.Syntax.find(), com.cliffc.aa.HM.HM8.T2.find(), com.cliffc.aa.HM.HM8.T2.is_err(), com.cliffc.aa.HM.HM8.T2.is_fun(), com.cliffc.aa.HM.HM8.Apply.is_if_nil(), com.cliffc.aa.HM.HM8.T2.make_err(), com.cliffc.aa.HM.HM8.T2.make_fun(), com.cliffc.aa.type.Type< T extends Type< T >.NIL, com.cliffc.aa.HM.HM8.Syntax.post(), com.cliffc.aa.HM.HM8.Syntax.pre(), com.cliffc.aa.HM.HM8.Apply.str(), and com.cliffc.aa.HM.HM8.T2.unify().

Here is the call graph for this function:

◆ is_if_nil()

T2 com.cliffc.aa.HM.HM8.Apply.is_if_nil ( )
private

Definition at line 570 of file HM8.java.

570  {
571  return _fun instanceof Ident && Util.eq(((Ident)_fun)._name,"if") && _args[0] instanceof Ident ? _args[0].find() : null;
572  }

References com.cliffc.aa.HM.HM8.Apply._args, com.cliffc.aa.HM.HM8.Apply._fun, com.cliffc.aa.util.Util.eq(), and com.cliffc.aa.HM.HM8.Syntax.find().

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

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

◆ lookup()

T2 com.cliffc.aa.HM.HM8.Apply.lookup ( String  name)
package

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

Definition at line 549 of file HM8.java.

549 { return _par==null ? null : _par.lookup(name); }

References com.cliffc.aa.HM.HM8.Syntax._par, and com.cliffc.aa.HM.HM8.Syntax.lookup().

Here is the call graph for this function:

◆ more_work()

boolean com.cliffc.aa.HM.HM8.Apply.more_work ( Worklist  work)
package

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

Definition at line 563 of file HM8.java.

563  {
564  if( !more_work_impl(work) ) return false;
565  if( !_fun.more_work(work) ) return false;
566  for( Syntax arg : _args ) if( !arg.more_work(work) ) return false;
567  return true;
568  }

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

Here is the call graph for this function:

◆ more_work_impl()

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

Definition at line 283 of file HM8.java.

283  {
284  boolean no_more_work = work.has(this) || !hm(null); // Either on worklist, or no-progress
285  return no_more_work;
286  }

References com.cliffc.aa.HM.HM8.Worklist.has(), and com.cliffc.aa.HM.HM8.Syntax.hm().

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

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

◆ p()

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

Definition at line 291 of file HM8.java.

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

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

Here is the call graph for this function:

◆ p0()

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

Definition at line 292 of file HM8.java.

292  {
293  _t.get_dups(dups);
294  _t.str(p1(sb.i()).p(" "), new VBitSet(),dups).nl();
295  return p2(sb.ii(1),dups).di(1);
296  }

References com.cliffc.aa.HM.HM8.Syntax._t, com.cliffc.aa.util.SB.di(), com.cliffc.aa.HM.HM8.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.HM8.Syntax.p1(), com.cliffc.aa.HM.HM8.Syntax.p2(), and com.cliffc.aa.HM.HM8.T2.str().

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

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

◆ p1()

SB com.cliffc.aa.HM.HM8.Apply.p1 ( SB  sb)
package

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

Definition at line 485 of file HM8.java.

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

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

Here is the call graph for this function:

◆ p2()

SB com.cliffc.aa.HM.HM8.Apply.p2 ( SB  sb,
VBitSet  dups 
)
package

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

Definition at line 486 of file HM8.java.

486  {
487  _fun.p0(sb,dups);
488  for( Syntax arg : _args ) arg.p0(sb,dups);
489  return sb;
490  }

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

Here is the call graph for this function:

◆ post()

T2 com.cliffc.aa.HM.HM8.Syntax.post ( )
packageinherited

Definition at line 254 of file HM8.java.

254  {
255  T2 t = _post.find();
256  return t==_post ? t : (_post=t);
257  }

References com.cliffc.aa.HM.HM8.Syntax._post, and com.cliffc.aa.HM.HM8.T2.find().

Referenced by com.cliffc.aa.HM.HM8.Lambda.hm(), com.cliffc.aa.HM.HM8.Let.hm(), com.cliffc.aa.HM.HM8.Apply.hm(), com.cliffc.aa.HM.HM8.Struct.hm(), and com.cliffc.aa.HM.HM8.Field.hm().

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

◆ pre()

T2 com.cliffc.aa.HM.HM8.Syntax.pre ( )
packageinherited

Definition at line 250 of file HM8.java.

250  {
251  T2 t = _pre.find();
252  return t==_pre ? t : (_pre=t);
253  }

References com.cliffc.aa.HM.HM8.Syntax._pre, and com.cliffc.aa.HM.HM8.T2.find().

Referenced by com.cliffc.aa.HM.HM8.Lambda.hm(), com.cliffc.aa.HM.HM8.Let.hm(), com.cliffc.aa.HM.HM8.Apply.hm(), com.cliffc.aa.HM.HM8.Struct.hm(), and com.cliffc.aa.HM.HM8.Field.hm().

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

◆ prep_lookup_deps()

void com.cliffc.aa.HM.HM8.Apply.prep_lookup_deps ( Ident  id)
package

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

Definition at line 562 of file HM8.java.

562 { }

◆ prep_tree()

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

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

Definition at line 554 of file HM8.java.

554  {
555  prep_tree_impl(par,nongen,work,T2.make_leaf());
556  int cnt = 1+_fun.prep_tree(this,nongen,work);
557  for( Syntax arg : _args ) cnt += arg.prep_tree(this,nongen,work);
558  T2 str = is_if_nil();
559  if( str!=null ) str.push_update(this);
560  return cnt;
561  }

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

Here is the call graph for this function:

◆ prep_tree_impl()

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

Definition at line 267 of file HM8.java.

267  {
268  _par=par;
269  _pre = T2.make_mem();
270  _t=t;
271  _post = T2.make_mem();
272  _nongen = nongen;
273  work.push(this);
274  }

References com.cliffc.aa.HM.HM8.Syntax._nongen, com.cliffc.aa.HM.HM8.Syntax._par, com.cliffc.aa.HM.HM8.Syntax._post, com.cliffc.aa.HM.HM8.Syntax._pre, com.cliffc.aa.HM.HM8.Syntax._t, com.cliffc.aa.HM.HM8.T2.make_mem(), and com.cliffc.aa.HM.HM8.Worklist.push().

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

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

◆ str()

SB com.cliffc.aa.HM.HM8.Apply.str ( SB  sb)
package

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

Definition at line 479 of file HM8.java.

479  {
480  _fun.str(sb.p("(")).p(" ");
481  for( Syntax arg : _args )
482  arg.str(sb).p(" ");
483  return sb.unchar().p(")");
484  }

References com.cliffc.aa.HM.HM8.Apply._args, com.cliffc.aa.HM.HM8.Apply._fun, com.cliffc.aa.util.SB.p(), com.cliffc.aa.HM.HM8.Syntax.str(), and com.cliffc.aa.util.SB.unchar().

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

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

◆ toString()

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

Definition at line 288 of file HM8.java.

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

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

Here is the call graph for this function:

Member Data Documentation

◆ _args

◆ _fun

◆ _nongen

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

◆ _par

◆ _post

◆ _pre

◆ _t


The documentation for this class was generated from the following file:
com.cliffc.aa.HM.HM8.Syntax.hm
abstract boolean hm(Worklist work)
com.cliffc.aa.util.Util.eq
static boolean eq(String s0, String s1)
Definition: Util.java:16
com.cliffc.aa.util.SB.ii
SB ii(int i)
Definition: SB.java:44
com.cliffc.aa.util.SB.di
SB di(int i)
Definition: SB.java:46
com.cliffc.aa.HM.HM8.Syntax._par
Syntax _par
Definition: HM8.java:240
com.cliffc.aa.HM.HM8.T2.get_dups
VBitSet get_dups(VBitSet dups)
Definition: HM8.java:1196
com.cliffc.aa.type.Type
an implementation of language AA
Definition: Type.java:94
com.cliffc.aa.HM.HM8.T2.unify
boolean unify(T2 that, Worklist work)
Definition: HM8.java:841
com.cliffc.aa.util.SB.unchar
SB unchar()
Definition: SB.java:58
com.cliffc.aa.HM.HM8.T2.make_mem
static T2 make_mem()
Definition: HM8.java:751
com.cliffc.aa.HM.HM8.Apply._args
final Syntax[] _args
Definition: HM8.java:477
com.cliffc.aa.HM.HM8.Syntax._nongen
VStack _nongen
Definition: HM8.java:241
com.cliffc.aa.HM.HM8.T2.debug_find
T2 debug_find()
Definition: HM8.java:777
com.cliffc.aa.HM.HM8.Syntax._pre
T2 _pre
Definition: HM8.java:242
com.cliffc.aa.HM.HM8.Syntax.lookup
abstract T2 lookup(String name)
com.cliffc.aa.HM.HM8.Syntax._post
T2 _post
Definition: HM8.java:244
com.cliffc.aa.util.Util
Definition: Util.java:5
com.cliffc.aa.HM.HM8.Apply._fun
final Syntax _fun
Definition: HM8.java:476
com.cliffc.aa.HM.HM8.Syntax.post
T2 post()
Definition: HM8.java:254
com.cliffc.aa.HM.HM8.T2.str
SB str(SB sb, VBitSet visit, VBitSet dups)
Definition: HM8.java:1209
com.cliffc.aa.HM.HM8.Syntax.pre
T2 pre()
Definition: HM8.java:250
com.cliffc.aa.HM.HM8.Syntax.more_work
abstract boolean more_work(Worklist work)
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.type.Type.NIL
static final Type NIL
Definition: Type.java:332
com.cliffc.aa.HM.HM8.Syntax.p2
abstract SB p2(SB sb, VBitSet dups)
com.cliffc.aa.HM.HM8.Syntax.p1
abstract SB p1(SB sb)
com.cliffc.aa.HM.HM8.Syntax.prep_tree_impl
final void prep_tree_impl(Syntax par, VStack nongen, Worklist work, T2 t)
Definition: HM8.java:267
com.cliffc.aa.util.SB.nl
SB nl()
Definition: SB.java:48
com.cliffc.aa.HM.HM8.Syntax._t
T2 _t
Definition: HM8.java:243
com.cliffc.aa.util.SB.p
SB p(String s)
Definition: SB.java:13
com.cliffc.aa.HM.HM8.Apply.is_if_nil
T2 is_if_nil()
Definition: HM8.java:570
com.cliffc.aa.HM.HM8.Syntax.p0
final SB p0(SB sb, VBitSet dups)
Definition: HM8.java:292
com.cliffc.aa.HM.HM8.Syntax.prep_tree
abstract int prep_tree(Syntax par, VStack nongen, Worklist work)
com.cliffc.aa.HM.HM8.Syntax.str
abstract SB str(SB sb)
com.cliffc.aa.HM.HM8.Syntax.find
T2 find()
Definition: HM8.java:245
com.cliffc.aa.util.SB.i
SB i(int d)
Definition: SB.java:38
com.cliffc.aa.HM.HM8.T2.find
T2 find()
Definition: HM8.java:788
com.cliffc.aa.HM.HM8.Syntax.more_work_impl
final boolean more_work_impl(Worklist work)
Definition: HM8.java:283
com.cliffc.aa.HM.HM8.Apply.str
SB str(SB sb)
Definition: HM8.java:479
com.cliffc.aa.util.SB.toString
String toString()
Definition: SB.java:62