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 Subscript extends exprType implements expr_contextType { 8 public exprType value; 9 public sliceType slice; 10 public int ctx; 11 12 public Subscript(exprType value, sliceType slice, int ctx) { 13 this.value = value; 14 this.slice = slice; 15 this.ctx = ctx; 16 } 17 18 public Subscript(exprType value, sliceType slice, int ctx, SimpleNode 19 parent) { 20 this(value, slice, ctx); 21 this.beginLine = parent.beginLine; 22 this.beginColumn = parent.beginColumn; 23 } 24 25 public String toString() { 26 StringBuffer sb = new StringBuffer ("Subscript["); 27 sb.append("value="); 28 sb.append(dumpThis(this.value)); 29 sb.append(", "); 30 sb.append("slice="); 31 sb.append(dumpThis(this.slice)); 32 sb.append(", "); 33 sb.append("ctx="); 34 sb.append(dumpThis(this.ctx, 35 expr_contextType.expr_contextTypeNames)); 36 sb.append("]"); 37 return sb.toString(); 38 } 39 40 public void pickle(DataOutputStream ostream) throws IOException { 41 pickleThis(40, ostream); 42 pickleThis(this.value, ostream); 43 pickleThis(this.slice, ostream); 44 pickleThis(this.ctx, ostream); 45 } 46 47 public Object accept(VisitorIF visitor) throws Exception { 48 return visitor.visitSubscript(this); 49 } 50 51 public void traverse(VisitorIF visitor) throws Exception { 52 if (value != null) 53 value.accept(visitor); 54 if (slice != null) 55 slice.accept(visitor); 56 } 57 58 } 59 | Popular Tags |