MethodInfo.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**********************************************************************/
  2. /* Method Info class for J2CPS */
  3. /* */
  4. /* (c) copyright QUT */
  5. /**********************************************************************/
  6. package J2CPS;
  7. import java.io.DataInputStream;
  8. import java.io.IOException;
  9. public class MethodInfo extends MemberInfo {
  10. public TypeDesc[] parTypes;
  11. public TypeDesc retType;
  12. public String userName;
  13. public boolean deprecated = false;
  14. public int retTypeFixUp = 0;
  15. public int[] parFixUps;
  16. public boolean overridding = false;
  17. public boolean isInitProc = false;
  18. public boolean isCLInitProc = false;
  19. public MethodInfo(ConstantPool cp,DataInputStream stream,
  20. ClassDesc thisClass) throws IOException {
  21. super(cp,stream,thisClass);
  22. parTypes = TypeDesc.GetParTypes(signature);
  23. retType = TypeDesc.GetType(signature,signature.indexOf(')')+1);
  24. if (name.equals("<init>")) {
  25. userName = "Init";
  26. isInitProc = true;
  27. if (!ConstantPool.isStatic(accessFlags)) {
  28. accessFlags = (accessFlags + ConstantPool.ACC_STATIC);
  29. }
  30. if ((parTypes.length == 0) && (!ConstantPool.isPrivate(accessFlags))) {
  31. thisClass.hasNoArgConstructor = true;
  32. }
  33. retType = thisClass;
  34. } else if (name.equals("<clinit>")) {
  35. userName="CLInit";
  36. isCLInitProc = true;
  37. }
  38. if (ClassDesc.verbose) {
  39. System.out.println("Method has " + parTypes.length + " parameters");
  40. }
  41. //AddImport(thisClass);
  42. for (int i=0; i < parTypes.length; i++)
  43. thisClass.TryImport(parTypes[i]);
  44. thisClass.TryImport(retType);
  45. }
  46. public MethodInfo(ClassDesc thisClass,String name,String jName,int acc) {
  47. super(thisClass,acc,jName);
  48. userName = name;
  49. if (name.equals("<init>")) {
  50. if (userName == null) { userName = "Init";}
  51. isInitProc = true;
  52. }
  53. }
  54. // public void AddImport(ClassDesc thisClass) {
  55. // for (int i=0; i < parTypes.length; i++)
  56. // thisClass.TryImport(parTypes[i]);
  57. // thisClass.TryImport(retType);
  58. // }
  59. @Override
  60. public String toString() {
  61. return ConstantPool.GetAccessString(accessFlags) + " " + name + " " +
  62. signature;
  63. }
  64. }