| /* Generated By:JJTree: Do not edit this line. ASTInteger.java */ |
| /* JJT: 0.3pre1 */ |
| |
| package Mini; |
| import org.apache.bcel.classfile.*; |
| import org.apache.bcel.generic.*; |
| |
| /** |
| * |
| * @version $Id$ |
| * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A> |
| */ |
| public class ASTInteger extends ASTExpr { |
| private int value; |
| |
| // Generated methods |
| ASTInteger(int id) { |
| super(id); |
| } |
| |
| ASTInteger(MiniParser p, int id) { |
| super(p, id); |
| } |
| |
| public static Node jjtCreate(MiniParser p, int id) { |
| return new ASTInteger(p, id); |
| } |
| |
| // closeNode, dump inherited from Expr |
| |
| /** |
| * @return identifier and line/column number of appearance |
| */ |
| public String toString() { |
| return super.toString() + " = " + value; |
| } |
| |
| /** |
| * Overrides ASTExpr.traverse() |
| */ |
| public ASTExpr traverse(Environment env) { |
| this.env = env; |
| return this; // Nothing to reduce/traverse here |
| } |
| |
| /** |
| * Second pass |
| * Overrides AstExpr.eval() |
| * @return type of expression |
| */ |
| public int eval(int expected) { |
| is_simple = true; // (Very) simple expression, always true |
| |
| return type = T_INT; |
| } |
| |
| /** |
| * Fourth pass, produce Java code. |
| */ |
| public void code(StringBuffer buf) { |
| ASTFunDecl.push(buf, "" + value); |
| } |
| |
| /** |
| * Fifth pass, produce Java byte code. |
| */ |
| public void byte_code(InstructionList il, MethodGen method, ConstantPoolGen cp) { |
| il.append(new PUSH(cp, value)); ASTFunDecl.push(); |
| } |
| |
| void setValue(int value) { this.value = value; } |
| int getValue() { return value; } |
| } |