PtrDesc.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**********************************************************************/
  2. /* Pointer Descriptor class for J2CPS */
  3. /* */
  4. /* (c) copyright QUT */
  5. /**********************************************************************/
  6. package J2CPS;
  7. import java.io.*;
  8. import java.util.*;
  9. public class PtrDesc extends TypeDesc {
  10. TypeDesc boundType;
  11. public PtrDesc(TypeDesc baseType) {
  12. typeOrd = TypeDesc.arrPtr;
  13. boundType = baseType;
  14. if (boundType != null) { setName(); }
  15. }
  16. public PtrDesc(int inNum, int baseNum) {
  17. typeOrd = TypeDesc.arrPtr;
  18. inTypeNum = inNum;
  19. inBaseTypeNum = baseNum;
  20. }
  21. public void Init(TypeDesc baseType) {
  22. boundType = baseType;
  23. if (boundType != null) { setName(); }
  24. }
  25. public void AddImport(ClassDesc thisClass) {
  26. if (boundType instanceof ClassDesc) {
  27. thisClass.AddImport((ClassDesc)boundType);
  28. } else if (boundType instanceof ArrayDesc) {
  29. ((ArrayDesc)boundType).AddImport(thisClass);
  30. }
  31. }
  32. public void setName() {
  33. name = "POINTER TO " + boundType.name;
  34. }
  35. public void writeType(DataOutputStream out, PackageDesc thisPack)
  36. throws IOException {
  37. out.writeByte(SymbolFile.ptrSy);
  38. SymbolFile.writeTypeOrd(out,boundType);
  39. }
  40. }