home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / tile-forth-2.1-bin.lha / lib / tile-forth / internals.f83 < prev    next >
Text File  |  1996-10-12  |  4KB  |  130 lines

  1. \
  2. \  INTERNAL TILE FORTH DATA STRUCTURES
  3. \
  4. \  Copyright (C) 1988-1990 by Mikael R.K. Patel
  5. \
  6. \  Computer Aided Design Laboratory (CADLAB)
  7. \  Department of Computer and Information Science
  8. \  Linkoping University
  9. \  S-581 83 LINKOPING
  10. \  SWEDEN
  11. \
  12. \  Email: mip@ida.liu.se
  13. \
  14. \  Started on: 30 June 1988
  15. \
  16. \  Last updated on: 27 July 1990
  17. \
  18. \  Dependencies:
  19. \       (forth) forth, string, enumerates, bitfields, structures,
  20. \               blocks, lists, sets
  21. \
  22. \  Description:
  23. \       High level extensions to the forth kernel. Implementation
  24. \       dependent sections such as entry and vocabulary structures.
  25. \
  26. \  Copying:
  27. \       This program is free software; you can redistribute it and\or modify
  28. \       it under the terms of the GNU General Public License as published by
  29. \       the Free Software Foundation; either version 1, or (at your option)
  30. \       any later version.
  31. \
  32. \       This program is distributed in the hope that it will be useful,
  33. \       but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. \       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  35. \       GNU General Public License for more details.
  36. \
  37. \       You should have received a copy of the GNU General Public License
  38. \       along with this program; see the file COPYING.  If not, write to
  39. \       the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  40.  
  41. .( Loading Internal definitions...) cr
  42.  
  43. #include enumerates.f83
  44. #include bitfields.f83
  45. #include structures.f83
  46. #include blocks.f83
  47. #include lists.f83
  48. #include sets.f83
  49.  
  50. sets lists blocks bitfields structures enumerates string forth definitions
  51.  
  52. ( Memory word size and integer range)
  53.  
  54. 8                      constant BITS/BYTE ( -- int)
  55. cell                   constant BYTES/WORD ( -- int)
  56. BYTES/WORD BITS/BYTE * constant BITS/WORD ( -- int)
  57.  
  58. 1 BITS/WORD 1- << constant MIN_INT ( -- int)
  59. MIN_INT 1-        constant MAX_INT ( -- int)
  60.  
  61. ( Entry and vocabulary structures)
  62.  
  63. struct.type ENTRY ( -- )
  64.   ptr  +link ( entry -- addr)        ( Pointer to previous entry)
  65.   ptr  +name ( entry -- addr)        ( Pointer to null-ended string)
  66.   long +mode ( entry -- addr)        ( Mode bit field)
  67.   long +code ( entry -- addr)        ( Code type or pointer to code)
  68.   long +parameter ( entry -- addr)    ( Parameter field or pointer to dito)
  69. struct.end
  70.  
  71. bitfield.type ENTRY-MODES ( -- )
  72.   bit  IMMEDIATE ( -- pos width)    ( Execution always)
  73.   bit  EXECUTION ( -- pos width)    ( Execution only)
  74.   bit  COMPILATION ( -- pos width)    ( Compilation only)
  75.   bit  PRIVATE ( -- pos width)        ( Private only)
  76. 4 bits RESERVED ( -- pos width)        ( Bit fields reserved for future use)
  77. bitfield.end                ( Bit 8-31 are free for applications)
  78.  
  79. enum.type ENTRY-CODES ( -- )
  80.   enum CODE ( -- enum)            ( Primitive code)
  81.   enum COLON ( -- enum)            ( Colon definition)
  82.   enum VARIABLE ( -- enum)        ( Variable)
  83.   enum CONSTANT ( -- enum)        ( Constant)
  84.   enum VOCABULARY ( -- enum)        ( Vocabulary)
  85.   enum CREATE ( -- enum)        ( Created symbol)
  86.   enum USER ( -- enum)            ( User variable local to task)
  87.   enum LOCAL ( -- enum)            ( Local frame variable)
  88.   enum FORWARD ( -- enum)        ( Forward reference)
  89.   enum FIELD ( -- enum)            ( Field access variable)
  90.   enum EXCEPTION ( -- enum)        ( Exception variable)
  91. enum.end                ( Otherwise forth level manager)
  92.   
  93. : .entry ( entry -- )
  94.   ." entry#" dup . cr            ( Print entry address)
  95.   ." link: " dup +link @ . cr        ( Print link)
  96.   ." name: " dup +name @ $print cr    ( Print name)
  97.   ." mode: " dup +mode @ . cr        ( Print mode)
  98.   ." code: " dup +code @ . cr        ( Print code)
  99.   ." parameter: " +parameter @ .     ( Print parameter field)
  100. ;
  101.  
  102. : .context ( -- )
  103.   ." context: " context            ( Access context vocabulary set)
  104.   block[ ( entry -- )
  105.     .name space                ( Print name of all vocabularies)
  106.   ]; 
  107.   map-set
  108. ;
  109.  
  110. : .current ( -- )
  111.   ." current: " current @ .name space     ( Print name of current vocabulary)
  112. ;
  113.  
  114. : .entries ( code -- )
  115.   context                ( Access search vocabularies)
  116.   block[ ( code vocabulary -- code)
  117.     +parameter @            ( Access list of entries)
  118.     block[ ( code entry -- code)
  119.       2dup +code @ =            ( Check if the entry is a vocabulary)
  120.       if .name space            ( Print its name and continue)
  121.       else drop then    
  122.     ]; 
  123.     map-list
  124.   ];
  125.   map-set
  126.   drop
  127. ;
  128.  
  129. forth only
  130.