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