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