/** f0 -> "HALLOCATE" f1 -> Exp() */
 public PGValue visit(HAllocate n, Node argu) {
   int old_hp = HP;
   PGValue exp;
   n.f0.accept(this, argu);
   exp = n.f1.accept(this, argu);
   HP = HP + exp.GetVal();
   return new Const(old_hp);
 }
 /** f0 -> "CJUMP" f1 -> Exp() f2 -> Label() */
 public PGValue visit(CJumpStmt n, Node argu) {
   PGValue p = n.f1.accept(this, argu);
   int cond = 0;
   if (p == null) return null;
   else cond = p.GetVal();
   if (cond == 1) return null;
   String l_name = (n.f2.accept(this, argu)).GetLabel();
   label_name = l_name;
   start = false;
   stop = false;
   // System.out.println("CJUMP " + l_name);
   argu.accept(this, argu);
   stop = true;
   start = true;
   return null;
 }
  /** f0 -> "CALL" f1 -> Exp() f2 -> "(" f3 -> ( Exp() )* f4 -> ")" */
  public PGValue visit(Call n, Node argu) {

    // NOTE: bug fix by jurgens@cs 10/30/07, kgo@cs 11/14/07
    //
    // details: local_arg_size was previously initialized to 20.
    // This resulted in TEMP values being overwritten by the caller.
    // For recursive calls, the overwritten values were bugs if any
    // thing stored in an overwritten temp was used after the
    // recursive call.  For this reason, we now make a copy of the
    // entire temp space before each call.

    n.f0.accept(this, argu);

    PGValue function_addr = n.f1.accept(this, argu);

    if (!(function_addr instanceof Label_pg)) {
      System.err.println("error in CALL");
      System.exit(0);
      return null; // Will never actually be reached.
    }

    String m_name = function_addr.GetLabel();

    n.f2.accept(this, argu);

    // Caller saves all local variables.
    PGValue[] saved_locals = new PGValue[TPV.length];
    System.arraycopy(TPV, 0, saved_locals, 0, TPV.length);

    // Copy call args into first N temps.
    ParamList_pg pl = (ParamList_pg) n.f3.accept(this, argu);

    // NOTE: we save and return the TEMPs for the caller, so we are
    // free to update the TPV array at this point.  kgo@cs fixed a
    // bug where this statement caused the callee to have TPV
    // side-effects for the caller.

    // NOTE: that if the method had no parameters, pl will be null.
    // This bug was discovered by Prof. Todd Millstein todd@cs.

    // check to see if the callee has any arguments and if so, pass
    // them into the TPV temp array using the caller's parameters
    if (pl != null) {
      int num_params = pl.GetVal();
      PGValue[] param_list = pl.GetList();

      for (int i = 0; i < num_params; i++) {
        TPV[i] = param_list[i];
      }
    }

    n.f4.accept(this, argu);
    met_name = m_name;
    boolean old_start = start;
    boolean old_stop = stop;
    start = true;
    stop = false;
    // System.out.println("No NO NO 222" + met_name);
    PGValue _ret = pg_root.accept(this, pg_root);
    // System.out.println("No NO NO");
    start = old_start;
    stop = old_stop;

    // Restore saved local variables.
    TPV = saved_locals;

    return _ret;
  }
 /** f0 -> "PRINT" f1 -> Exp() */
 public PGValue visit(PrintStmt n, Node argu) {
   PGValue _ret = n.f1.accept(this, argu);
   System.out.println(_ret.GetVal());
   return null;
 }