1 19 package gcc.generator; 20 21 import gcc.generator.JBlockStatement; 22 import gcc.generator.JEntity; 23 import gcc.generator.JExpression; 24 import gcc.generator.JLocalVariable; 25 26 import java.util.Vector; 27 import java.lang.reflect.Modifier; 28 29 public class JMethod extends JEntity 30 { 31 protected JReturnType _rt; 32 protected JParameter _parms[]; 33 protected Class _thrown[]; 34 35 protected Vector _statements; 36 protected JBlockStatement _bodyBlockStatement; 37 38 protected String _body; 40 protected JMethod( String name ) 41 { 42 super( name, Modifier.PUBLIC ); 43 44 _statements = new Vector(); 45 _bodyBlockStatement = new JBlockStatement(); 46 } 47 48 protected JMethod( JReturnType rt, String name, JParameter parms[], Class thrown[] ) 49 { 50 this( name ); 51 52 setRT( rt ); 53 setParms( parms ); 54 setThrown( thrown ); 55 } 56 57 public void setRT( JReturnType jt ) 58 { 59 _rt = jt; 60 } 61 62 public JReturnType getRT() 63 { 64 return _rt; 65 } 66 67 public void setParms( JParameter parms[] ) 68 { 69 _parms = parms; 70 } 71 72 public JParameter[] getParms() 73 { 74 return _parms; 75 } 76 77 public void setThrown( Class thrown[] ) 78 { 79 _thrown = thrown; 80 81 96 } 97 98 public Class[] getThrown() 99 { 100 return _thrown; 101 } 102 103 115 116 public void setBody( String body ) 117 { 118 _body = body; 119 } 120 121 public String getBody() 122 { 123 return _body; 124 } 125 126 public JLocalVariable newLocalVariable( Class type, String name ) 127 { 128 return _bodyBlockStatement.newLocalVariable( type, name ); 129 } 130 131 public JLocalVariable newLocalVariable( Class type, String name, JExpression initExpr ) 132 { 133 return _bodyBlockStatement.newLocalVariable( type, name, initExpr ); 134 } 135 136 public void deleteLocalVariable( JLocalVariable f ) 137 { 138 _bodyBlockStatement.deleteLocalVariable( f ); 139 } 140 141 public Vector getLocalVariables() 142 { 143 return _bodyBlockStatement.getLocalVariables(); 144 } 145 146 public void addStatement( JStatement s ) 147 { 148 _statements.add( s ); 149 } 150 151 public Vector getStatements() 152 { 153 return _statements; 154 } 155 } 156 | Popular Tags |