1 19 package gcc.generator; 20 21 import java.util.Vector; 22 23 public class JIfElseIfElseStatement extends JStatement 24 { 25 protected JIfStatement _ifStatement; 26 protected Vector _elseifStatements; 27 protected JElseStatement _elseStatement; 28 29 public JIfElseIfElseStatement( JExpression if_expr ) 30 { 31 _ifStatement = new JIfStatement( if_expr ); 32 _elseifStatements = new Vector(); 33 _elseStatement = new JElseStatement(); 34 } 35 36 public void addIfStatement( JStatement s ) 37 { 38 _ifStatement.addStatement( s ); 39 } 40 41 public JIfStatement getIfStatement() 42 { 43 return _ifStatement; 44 } 45 46 public Vector getIfStatements() 47 { 48 return _ifStatement.getStatements(); 49 } 50 51 public void addElseStatement( JStatement s ) 52 { 53 _elseStatement.addStatement( s ); 54 } 55 56 public JElseStatement getElseStatement() 57 { 58 return _elseStatement; 59 } 60 61 public Vector getElseStatements() 62 { 63 return _elseStatement.getStatements(); 64 } 65 66 public JElseIfStatement getElseIf( JExpression e ) 67 { 68 JElseIfStatement rc = null; 69 int index = _elseifStatements.indexOf( e ); 70 71 if (index >= 0) 72 { 73 rc = (JElseIfStatement)_elseifStatements.get( index ); 74 } 75 76 return rc; 77 } 78 79 public JElseIfStatement newElseIf( JExpression e ) 80 { 81 JElseIfStatement rc = getElseIf( e ); 82 83 if (rc == null) 84 { 85 rc = new JElseIfStatement( e ); 86 _elseifStatements.add(rc); 87 } 88 89 return rc; 90 } 91 92 public void addCatchStatement( JExpression e, JStatement s ) 93 { 94 JElseIfStatement eis = getElseIf( e ); 95 96 if (eis == null) 97 { 98 eis = newElseIf( e ); 99 } 100 101 eis.addStatement( s ); 102 } 103 104 public Vector getElseIfs() 105 { 106 return _elseifStatements; 107 } 108 } 109 | Popular Tags |