home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / runtime / fxvis.ri < prev    next >
Text File  |  1996-03-22  |  2KB  |  70 lines

  1. /*
  2.  * fxvis.ri -- functions to support program visualization.
  3.  */
  4.  
  5. "serial(x) - return serial number of structure."
  6. function {0,1} serial(x)
  7.    abstract {
  8.       return integer
  9.       }
  10.  
  11.    type_case x of {
  12.       list:   inline {
  13.          return C_integer BlkLoc(x)->list.id;
  14.          }
  15.       set:   inline {
  16.          return C_integer BlkLoc(x)->set.id;
  17.          }
  18.       table:   inline {
  19.          return C_integer BlkLoc(x)->table.id;
  20.          }
  21.       record:   inline {
  22.          return C_integer BlkLoc(x)->record.id;
  23.          }
  24.       default:
  25.          inline { fail; }
  26.       }
  27. end
  28.  
  29. "structure(x) -- generate all structures allocated in program x"
  30. function {*} structure(x)
  31.  
  32.    if !is:coexpr(x) then
  33.        runerr(118, x)
  34.  
  35.    abstract {
  36.       return list ++ set ++ table ++ record
  37.       }
  38.  
  39.    body {
  40.       tended char *bp;
  41.       char *free;
  42.       tended struct descrip descr;
  43.       word type;
  44.  
  45. #ifdef MultiThread
  46.       bp = ((struct b_coexpr *)BlkLoc(x))->program->blockregion->base;
  47.       free = ((struct b_coexpr *)BlkLoc(x))->program->blockregion->free;
  48. #else                    /* MultiThread */
  49.       bp = blkbase;
  50.       free = blkfree;
  51. #endif                    /* MultiThread */
  52.  
  53.       while (bp < free) {
  54.          type = BlkType(bp);
  55.          switch (type) {
  56.             case T_List:
  57.             case T_Set:
  58.             case T_Table:
  59.             case T_Record: {
  60.                BlkLoc(descr) = (union block *)bp;
  61.                descr.dword = type | F_Ptr | D_Typecode;
  62.                suspend descr;
  63.                }
  64.             }
  65.          bp += BlkSize(bp);
  66.          }
  67.       fail;
  68.       }
  69. end
  70.