home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / PowerMacInterface / structure.icl < prev    next >
Encoding:
Modula Implementation  |  1996-03-01  |  3.5 KB  |  96 lines  |  [TEXT/3PRM]

  1. implementation module structure;
  2.  
  3. import mac_types;
  4.  
  5. ::    Structure :== (!Handle,!Ptr);
  6.                                                                                       
  7. DereferenceHandle :: !Handle !Toolbox -> (!Ptr,!Toolbox);
  8. DereferenceHandle h tb = (DereferenceHandle1 h,tb);
  9.  
  10. DereferenceHandle1 :: !Handle -> Ptr;
  11. DereferenceHandle1 h = code (h=U)(pointer=A0){
  12.     instruction    0x83180000    |    lwz    r24,0(r24)
  13. };
  14.  
  15. HandleToStructure :: !Handle -> Structure;
  16. HandleToStructure h = code (h=D0)(new_h=A0,pointer=A0){
  17.     instruction    0x7F19C378    |    mr    r25,r24
  18.     instruction    0x83180000    |    lwz    r24,0(r24)
  19. };
  20.  
  21. Append_long :: !Structure !Int !Toolbox -> (!Structure,!Toolbox);
  22. Append_long hp l tb = (AppendLong hp l,tb);
  23.  
  24. AppendLong :: !Structure !Int -> Structure;
  25. AppendLong  (h,p) l = code (h=U,p=U,l=U)(new_h=A0,new_p=A0){
  26.     instruction    0x93190000    |    stw        r24,0(r25)
  27.     instruction 0x3B190004    |    addi    r24,r25,4
  28.     instruction    0x7F59D378    |    mr        r25,r26
  29. };
  30.  
  31. Append_word :: !Structure !Int !Toolbox -> (!Structure,!Toolbox);
  32. Append_word hp w tb = (AppendWord hp w,tb);
  33.  
  34. AppendWord :: !Structure !Int -> Structure;
  35. AppendWord (h,p) w = code (h=U,p=U,w=U) (new_h=A0,new_p=A0){
  36.     instruction    0xB3190000    |    sth        r24,0(r25)
  37.     instruction    0x3B190002    |    addi    r24,r25,2
  38.     instruction    0x7F59D378    |    mr        r25,r26
  39. };
  40.  
  41. Append_byte :: !Structure !Int !Toolbox -> (!Structure,!Toolbox);
  42. Append_byte hp b tb = (AppendByte hp b,tb);
  43.  
  44. AppendByte :: !Structure !Int -> Structure;
  45. AppendByte (h,p) b = code (h=U,p=U,b=U)(new_h=A0,new_p=A0){
  46.     instruction    0x9B190000    |    stb        r24,0(r25)
  47.     instruction    0x3B190001    |    addi    r24,r25,1
  48.     instruction    0x7F59D378    |    mr        r25,r26
  49. };
  50.  
  51. Append_zero_and_rect :: !Structure !Rect !Toolbox -> (!Structure,!Toolbox);
  52. Append_zero_and_rect hp rect tb = (Append_zero_and_rect1 hp rect,tb);
  53.  
  54. Append_zero_and_rect1 :: !Structure !Rect -> Structure;
  55. Append_zero_and_rect1 (h,p) (left,top,right,bottom) = code (h=U,p=U,left=U,top=U,right=U,bottom=U)(new_h=A0,new_p=A0){
  56.     instruction    0x38600000    |    li        r3,0
  57.     instruction 0x907C0000    |    stw        r3,0(r28)
  58.     instruction 0xB35C0004    |    sth        r26,4(r28)
  59.     instruction 0xB37C0006    |    sth        r27,6(r28)
  60.     instruction    0xB31C0008    |    sth        r24,8(r28)
  61.     instruction    0xB33C000A    |    sth        r25,10(r28)
  62.     instruction    0x3B1C000C    |    addi    r24,r28,12
  63.     instruction    0x7FB9EB78    |    mr        r25,r29
  64. };
  65.  
  66. Append_string_and_align :: !Structure !{#Char} !Toolbox -> (!Structure,!Toolbox);
  67. Append_string_and_align hp string tb = (Append_string_and_align1 hp string,tb);
  68.  
  69. Append_string_and_align1 :: !Structure !{#Char} -> Structure;
  70. Append_string_and_align1 (h,p) string = code (h=U,p=U,string=U)(new_h=A0,new_p=A0){                                               
  71.     instruction    0x8F570007    |        lbzu    r26,7(r23)
  72.     instruction    0x9B580000    |        stb        r26,0(r24)
  73.     instruction    0x4800000C    |        b        l2
  74.     instruction    0x8C770001    |    l1:    lbzu    r3,1(r23)
  75.     instruction    0x9C780001    |        stbu    r3,1(r24)
  76.     instruction    0x375AFFFF    |    l2:    subic.    r26,r26,1    
  77.     instruction    0x4080FFF4    |        bge        l1
  78.     instruction    0x3B180002    |        addi    r24,r24,2
  79.     instruction    0x5718003C    |        clrrwi    r24,r24,1
  80. };
  81.  
  82. Append_string :: !Structure !{#Char} !Toolbox -> (!Structure,!Toolbox);
  83. Append_string hp string tb = (AppendString hp string,tb);
  84.  
  85. AppendString :: !Structure !{#Char} -> Structure;
  86. AppendString (h,p) string = code (h=U,p=U,string=U)(new_h=A0,new_p=A0){                                               
  87.     instruction    0x8F570007    |        lbzu    r26,7(r23)
  88.     instruction    0x3B18FFFF    |        addi    r24,r24,-1
  89.     instruction    0x4800000C    |        b        l2
  90.     instruction    0x8C770001    |    l1:    lbzu    r3,1(r23)
  91.     instruction    0x9C780001    |        stbu    r3,1(r24)
  92.     instruction    0x375AFFFF    |    l2:    subic.    r26,r26,1    
  93.     instruction    0x4080FFF4    |        bge        l1
  94.     instruction    0x3B180001    |        addi    r24,r24,1
  95. };
  96.