         Edinburgh IMP77 Compiler - Version 8.4

    1  %begin
    2  
    3    %recordformat small rec fm(%integer i, %real r)
    4    %recordformat big rec fm(%integer i, %real r, %string(255) s)
    5    
    6    %record (small rec fm) small rec, small rec 2
    7    %record (big rec fm) big rec
    8  
    9    %record (small rec fm) %name small ptr
   10  
   11    small rec_i = 123 ; small rec_r = 234.56
   12    big rec_i = 123 ; big rec_r = 234.56 ; big rec_s = "A String"
   13  
   14  ! regular record assignments. These work OK.
   15  
   16    small ptr == small rec 2
   17  
   18    small ptr = small rec
   19  
   20    small rec = small ptr
   21  
   22    small rec <- small ptr
   23  
   24  ! These generate bad code:
   25  
   26  ! RECORD() on RHS
   27  
   28    small ptr == RECORD(ADDR(big rec))
   29  
   30    small ptr == RECORD(ADDR(small rec))
   31  
   32    small rec 2 = RECORD(ADDR(big rec))
   33  
   34    small rec 2 <- RECORD(ADDR(big rec))
   35  
   36    small ptr = RECORD(ADDR(big rec))
   37  
   38    small ptr <- RECORD(ADDR(big rec))
   39  
   40  ! RECORD() on LHS
   41  
   42    RECORD(ADDR(big rec)) = small rec
   43  
   44    RECORD(ADDR(big rec)) <- small rec
   45  
   46    RECORD(ADDR(small rec)) = big rec
   47  
   48    RECORD(ADDR(small rec)) <- big rec
   49  
   50    
   51  %endofprogram

   26 Statements compiled
