PtrDesc.java 1.5 KB

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