1 package org.python.parser.ast; 3 import org.python.parser.SimpleNode; 4 import java.io.DataOutputStream ; 5 import java.io.IOException ; 6 7 public class UnaryOp extends exprType implements unaryopType { 8 public int op; 9 public exprType operand; 10 11 public UnaryOp(int op, exprType operand) { 12 this.op = op; 13 this.operand = operand; 14 } 15 16 public UnaryOp(int op, exprType operand, SimpleNode parent) { 17 this(op, operand); 18 this.beginLine = parent.beginLine; 19 this.beginColumn = parent.beginColumn; 20 } 21 22 public String toString() { 23 StringBuffer sb = new StringBuffer ("UnaryOp["); 24 sb.append("op="); 25 sb.append(dumpThis(this.op, unaryopType.unaryopTypeNames)); 26 sb.append(", "); 27 sb.append("operand="); 28 sb.append(dumpThis(this.operand)); 29 sb.append("]"); 30 return sb.toString(); 31 } 32 33 public void pickle(DataOutputStream ostream) throws IOException { 34 pickleThis(30, ostream); 35 pickleThis(this.op, ostream); 36 pickleThis(this.operand, ostream); 37 } 38 39 public Object accept(VisitorIF visitor) throws Exception { 40 return visitor.visitUnaryOp(this); 41 } 42 43 public void traverse(VisitorIF visitor) throws Exception { 44 if (operand != null) 45 operand.accept(visitor); 46 } 47 48 } 49 | Popular Tags |