1 19 package gcc.generator; 20 21 import gcc.generator.JCatchStatement; 22 import gcc.generator.JFinallyStatement; 23 import gcc.generator.JStatement; 24 25 import java.util.Vector; 26 27 public class JTryCatchFinallyStatement extends JStatement 28 { 29 protected JTryStatement _TryStatement; 30 protected Vector _catchStatements; 31 protected JFinallyStatement _FinallyStatement; 32 33 public JTryCatchFinallyStatement( ) 34 { 35 _TryStatement = new JTryStatement(); 36 _catchStatements = new Vector(); 37 _FinallyStatement = new JFinallyStatement(); 38 } 39 40 public void addTryStatement( JStatement s ) 41 { 42 _TryStatement.addStatement( s ); 43 } 44 45 public JTryStatement getTryStatement() 46 { 47 return _TryStatement; 48 } 49 50 public JCatchStatement getCatch( JVariable v ) 51 { 52 JCatchStatement rc = null; 53 int index = _catchStatements.indexOf( v ); 54 55 if (index >= 0) 56 { 57 rc = (JCatchStatement)_catchStatements.get( index ); 58 } 59 60 return rc; 61 } 62 63 public JCatchStatement newCatch( JVariable v ) 64 { 65 JCatchStatement rc = getCatch( v ); 66 67 if (rc == null) 68 { 69 rc = new JCatchStatement( v ); 70 _catchStatements.add(rc); 71 } 72 73 return rc; 74 } 75 76 public void addCatchStatement( JVariable v, JStatement s ) 77 { 78 JCatchStatement cs = getCatch( v ); 79 80 if (cs == null) 81 { 82 cs = newCatch( v ); 83 } 84 85 cs.addStatement( s ); 86 } 87 88 public Vector getCatches() 89 { 90 return _catchStatements; 91 } 92 93 public void addFinallyStatement( JStatement s ) 94 { 95 _FinallyStatement.addStatement( s ); 96 } 97 98 public JFinallyStatement getFinallyStatement() 99 { 100 return _FinallyStatement; 101 } 102 } 103 | Popular Tags |