picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

structures (9244B)


      1 # 11jun13abu
      2 # (c) Software Lab. Alexander Burger
      3 
      4 
      5    ### Primary data types ###
      6 
      7    cnt   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxS010
      8    big   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxS100
      9    sym   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1000
     10    pair  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0000
     11 
     12 
     13          Bignum
     14          |
     15          V
     16       +-----+-----+
     17       | DIG |  |  |
     18       +-----+--+--+
     19                |
     20                V
     21             +-----+-----+
     22             | DIG |  |  |
     23             +-----+--+--+
     24                      |
     25                      V
     26                   +-----+-----+
     27                   | DIG | CNT |
     28                   +-----+-----+
     29 
     30 
     31       Pair
     32       |
     33       V
     34       +-----+-----+
     35       | CAR | CDR |
     36       +-----+-----+
     37 
     38 
     39             Symbol
     40             |
     41             V
     42       +-----+-----+                                +-----+-----+
     43       |  |  | VAL |                                |'cba'|'fed'|
     44       +--+--+-----+                                +-----+-----+
     45          | tail                                       ^
     46          |                                            |
     47          V                                            | name
     48          +-----+-----+     +-----+-----+     +-----+--+--+
     49          |  |  |  ---+---> | KEY |  ---+---> |  |  |  |  |
     50          +--+--+-----+     +-----+-----+     +--+--+-----+
     51             |                                   |
     52             V                                   V
     53             +-----+-----+                       +-----+-----+
     54             | VAL | KEY |                       | VAL | KEY |
     55             +-----+-----+                       +-----+-----+
     56 
     57 
     58       NIL:  /
     59             |
     60             V
     61       +-----+-----+-----+-----+
     62       |'LIN'|  /  |  /  |  /  |
     63       +-----+--+--+-----+-----+
     64 
     65 
     66    Symbol tail
     67       Internal/Transient
     68          0010 Short name
     69          0100 Long name
     70          0000 Properties
     71 
     72       External
     73          1010 Short name
     74          1000 Properties
     75 
     76    Name final short
     77       Internals, Transients
     78          0000.xxxxxxx.xxxxxxx.xxxxxxx.xxxxxxx.xxxxxxx.xxxxxxx.xxxxxxx0010
     79            60      52      44      36      28      20      12       4
     80 
     81       Externals
     82          42 bit Object (4 Tera objects)
     83          16 bit File (64 K files)
     84           2 bit Status
     85             Loaded    01........
     86             Dirty     10........
     87             Deleted   11........
     88 
     89          1+2 Bytes: 1 file, 64K objects                  {177777}
     90          1+3 Bytes: 16 files, 1M objects               {O3777777}
     91          1+4 Bytes: 256 files, 16M objects           {OO77777777}
     92          1+5 Bytes: 256 files, 4G objects         {OO37777777777}
     93          1+6 Bytes: 65536 files, 4G objects     {OOOO37777777777}
     94          1+8 Bytes: 65536 files, 4T objects  {OOOO77777777777777}
     95          (2 + 10 + 8 + 12 + 8 + 20)
     96          xx.xxxxxxxxx.xxxxxxx.xxxxxxxxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxE010
     97            obj       file    obj         file    obj
     98                      ^6      ^5      ^4      ^3      ^2
     99 
    100 
    101    ### Heap ###
    102 
    103       Heaps       Avail
    104       |           |
    105       |           |  +-----------------------+
    106       |           |  |                       |
    107       V           V  |                       V
    108       +-----+-----+--+--+-----+-----+-----+-----+-----+---     ---+-----+
    109       |           |  |  |     |           |  /  |     |    ...    |  |  |
    110       +-----+-----+-----+-----+-----+-----+-----+-----+---     ---+--+--+
    111                                                                      |
    112                                                                      |
    113                                                                      +----->
    114 
    115 
    116    ### Stack ###
    117 
    118       Saved values:
    119                         ^
    120                         |
    121          +---> LINK ----+
    122          |     val1
    123          |     val2
    124          |     ...
    125          |     valN
    126          +---- LINK  <-- L
    127 
    128 
    129       Bind frame:
    130                         ^
    131               [exe]     |
    132                Bind     |
    133          +---> LINK ----+
    134          |     val1
    135          |     sym1
    136          |     ...
    137          |     valN
    138          |     symN
    139          +---- LINK  <-- L <-- Bind
    140                eswp
    141 
    142 
    143       VarArgs frame:
    144                         ^
    145               [exe]     |
    146                Bind     |
    147          +---> LINK ----+
    148          |     val1
    149          |     sym1
    150          |     ...
    151          |     valN
    152          |     symN
    153          +---- LINK <---+  <-- Bind
    154                eswp     |
    155                Next     |
    156                Args     |
    157          +---> LINK ----+  <-- Next
    158          |     arg1
    159          |     ...
    160          |     argN        <-- Args
    161          +---- LINK  <-- L
    162 
    163 
    164       Apply args:
    165                         ^
    166                         |
    167          +---> LINK ----+
    168          |     ...
    169          |     fun         <-- Y
    170          |     arg1
    171          |     ...
    172          |     argN        <-- Z
    173          |     ...
    174          +---- LINK <-- L
    175 
    176 
    177       Apply frame:
    178                         ^
    179                Apply    |
    180          +---> LINK ----+
    181          |     ...
    182          |     valN <-+       (gc)
    183          |     zero   |
    184          |     NIL    |       (gc)
    185          |     carN --+ <-+
    186          |     ...        |
    187          |     val1 <-+   |   (gc)
    188          |     zero   |   |
    189          |     cdr1 --|---+   (gc)
    190          | +-> car1 --+
    191          | +-- cdr            (gc)
    192          |     fun         <-- exe
    193          +---- LINK  <-- L <-- Apply
    194 
    195 
    196       Catch frame:
    197                         ^
    198                X        |
    199                Y        |
    200                Z        |
    201                L        |
    202          <III> [env]    |
    203          <II>  fin      |
    204          <I>   tag      |
    205                LINK ----+  <-- Catch
    206 
    207 
    208       I/O frame:
    209                         ^
    210          <III> put/get  |
    211          <II>  pid      |
    212          <I>   fd       |
    213                LINK ----+  <-- inFrames, outFrames, errFrames, ctlFrames
    214 
    215 
    216       Coroutine frame:
    217                         ^
    218                X        |
    219                Y        |
    220                Z        |
    221                L        |
    222          <III> [env]    |
    223          <II>  seg -----|-----------------+
    224          <I>   lim      |                 |
    225                LINK ----+  <-- co7        |
    226                                           |
    227                                           |
    228       Stack segment:       <--------------+
    229          <-I>  tag      # Tag
    230          <-II> stk      # Stack pointer --+
    231                [env]    # Environment     |
    232                Stack ...                  |
    233                X                          |
    234                Y                          |
    235                Z                          |
    236                L  <-----------------------+
    237 
    238 
    239    ### Memory ###
    240 
    241       inFile:
    242          -->   fd       # File descriptor
    243          <I>   ix       # Read index
    244          <II>  cnt      # Buffer count
    245          <III> next     # Next character
    246          <IV>  line     # Line number
    247          <V>   src      # Source line number
    248          <VI>  name     # Filename
    249          <VII> buf      # Buffer [BUFSIZ]
    250 
    251       outFile:
    252          -->   fd       # File descriptor
    253          <I>   ix       # Read index
    254          <II>  tty      # TTY flag
    255          <III> buf      # Buffer [BUFSIZ]
    256 
    257 
    258       child:
    259          -->   pid      # Process ID
    260          <I>   hear     # Pipe read end
    261          <II>  tell     # Pipe write end
    262          <III> ofs      # Buffer offset
    263          <IV>  cnt      # Buffer count
    264          <V>   buf      # Buffer pointer
    265 
    266                   +--------------------------+ Mic
    267                   |
    268                   |  +-----------------+ Tell         <Child>
    269                   |  |
    270                   |  +-----------------> Hear
    271       <Parent>    |  |
    272                   |  |
    273          Spkr <---+  |
    274                   |  |
    275                   |  |
    276                   |  +-----------------+ Tell
    277                   |  |
    278                   |  +-----------------> Hear         <Child>
    279                   |
    280                   +--------------------------+ Mic
    281 
    282 
    283    ### Database file ###
    284 
    285                   +-------------+-+-------------+-+----+
    286       Block 0:    |   Free       0|   Next       0| << |
    287                   +-------------+-+-------------+-+----+
    288                   0               BLK                  2*Blk+1
    289 
    290 
    291                   +-------------+-+
    292       Free:       |   Link       0|
    293                   +-------------+-+
    294                   0
    295 
    296 
    297                   +-------------+-+----
    298       ID-Block:   |   Link       1| Data
    299                   +-------------+-+----
    300                   0              BLK
    301 
    302 
    303                   +-------------+-+----
    304       EXT-Block:  |   Link       n| Data
    305                   +-------------+-+----
    306                   0              BLK
    307 
    308 
    309       dbFile:  # Size VIII (64 bytes)
    310          -->   fd       # File descriptor
    311          <I>   db       # File number
    312          <II>  sh       # Block shift
    313          <III> siz      # Block size (64 << sh)
    314          <IV>  flgs     # Flags: Lock(0), Dirty(1)
    315          <V>   marks    # Mark vector size
    316          <VI>  mark     # Mark bit vector
    317          <VII> fluse    # Free list use count
    318 
    319 
    320    ### Assumptions ###
    321 
    322    - 8 bit per byte
    323    - 64 bit per word
    324    - Stack grows downwards, aligned to 64 bit
    325    - Memory access legal also at 4-byte boundaries