home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / scode.h < prev    next >
Text File  |  1999-01-02  |  6KB  |  177 lines

  1. /* -*-C-*-
  2.  
  3. Copyright (c) 1987, 1988, 1989, 1999 Massachusetts Institute of Technology
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or (at
  8. your option) any later version.
  9.  
  10. This program is distributed in the hope that it will be useful, but
  11. WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. /* $Id: scode.h,v 9.26 1999/01/02 06:11:34 cph Exp $
  21.  *
  22.  * Format of the SCode representation of programs.  Each of these
  23.  * is described in terms of the slots in the data structure.
  24.  *
  25.  */
  26.  
  27. /* Here are the definitions of the the executable operations for the
  28.    interpreter.  This file should parallel the file SCODE.SCM in the
  29.    runtime system.  The interpreter dispatches on the type code of a
  30.    pointer to determine what operation to perform.  The format of the
  31.    storage block this points to is described below.  Offsets are the
  32.    number of cells from the location pointed to by the operation. */
  33.  
  34. /* ALPHABETICALLY LISTED BY TYPE CODE NAME */
  35.  
  36. /* ACCESS operation: */
  37. #define ACCESS_ENVIRONMENT    0
  38. #define ACCESS_NAME        1
  39.  
  40. /* ASSIGNMENT operation: */
  41. #define ASSIGN_NAME        0
  42. #define ASSIGN_VALUE        1
  43.  
  44. /* COMBINATIONS come in several formats */
  45.  
  46. /* General combinations are vector-like: */
  47. #define COMB_VECTOR_HEADER    0
  48. #define COMB_FN_SLOT        1
  49. #define COMB_ARG_1_SLOT        2
  50.  
  51. /* Short non-primitive combinations: */
  52. #define COMB_1_FN        0
  53. #define COMB_1_ARG_1        1
  54.  
  55. #define COMB_2_FN        0
  56. #define COMB_2_ARG_1        1
  57. #define COMB_2_ARG_2        2
  58.  
  59. /* COMMENT operation: */
  60. #define COMMENT_EXPRESSION    0
  61. #define COMMENT_TEXT        1
  62.  
  63. /* CONDITIONAL operation (used for COND, IF, AND): */
  64. #define COND_PREDICATE        0
  65. #define COND_CONSEQUENT        1
  66. #define COND_ALTERNATIVE    2
  67.  
  68. /* DEFINITION operation: */
  69. #define DEFINE_NAME        0
  70. #define DEFINE_VALUE        1
  71.  
  72. /* DELAY operation: */
  73. #define DELAY_OBJECT        0
  74. #define DELAY_UNUSED        1
  75.  
  76. /* DISJUNCTION or OR operation: */
  77. #define OR_PREDICATE        0
  78. #define OR_ALTERNATIVE        1
  79.  
  80. /* EXTENDED_LAMBDA operation:
  81.  * Support for optional parameters and auxiliary local variables.  The
  82.  * Extended Lambda is similar to LAMBDA, except that it has an extra
  83.  * word called the ARG_COUNT.  This contains an 8-bit count of the
  84.  * number of optional arguments, an 8-bit count of the number of
  85.  * required (formal) parameters, and a bit to indicate that additional
  86.  * (rest) arguments are allowed.  The vector of argument names
  87.  * contains, of course, a size count which allows the calculation of
  88.  * the number of auxiliary variables required.  Auxiliary variables
  89.  * are created for any internal DEFINEs which are found at syntax time
  90.  * in the body of a LAMBDA-like special form.
  91.  */
  92.  
  93. #define ELAMBDA_SCODE      0
  94. #define ELAMBDA_NAMES      1
  95. #define ELAMBDA_ARG_COUNT  2
  96.  
  97. /* Masks.  The infomation on the number of each type of argument is
  98.  * separated at byte boundaries for easy extraction in the 68000 code.
  99.  */
  100.  
  101. #define EL_OPTS_MASK        0xFF
  102. #define EL_FORMALS_MASK        0xFF00
  103. #define EL_REST_MASK        0x10000
  104. #define EL_FORMALS_SHIFT    8
  105. #define EL_REST_SHIFT        16
  106.  
  107. /* Selectors */
  108.  
  109. #define Get_Body_Elambda(Addr)  (FAST_MEMORY_REF (Addr, ELAMBDA_SCODE))
  110. #define Get_Names_Elambda(Addr) (FAST_MEMORY_REF (Addr, ELAMBDA_NAMES))
  111. #define Get_Count_Elambda(Addr) (FAST_MEMORY_REF (Addr, ELAMBDA_ARG_COUNT))
  112. #define Elambda_Formals_Count(Addr) \
  113.      ((((long) Addr) & EL_FORMALS_MASK) >> EL_FORMALS_SHIFT)
  114. #define Elambda_Opts_Count(Addr) \
  115.      (((long) Addr) & EL_OPTS_MASK)
  116. #define Elambda_Rest_Flag(Addr) \
  117.      ((((long) Addr) & EL_REST_MASK) >> EL_REST_SHIFT)
  118.  
  119. /* IN-PACKAGE operation: */
  120. #define IN_PACKAGE_ENVIRONMENT    0
  121. #define IN_PACKAGE_EXPRESSION    1
  122.  
  123. /* LAMBDA operation:
  124.  * Object representing a LAMBDA expression with a fixed number of
  125.  * arguments.  It consists of a list of the names of the arguments
  126.  * (the first is the name by which the procedure refers to itself) and
  127.  * the SCode for the procedure.
  128.  */
  129.  
  130. #define LAMBDA_SCODE        0
  131. #define LAMBDA_FORMALS        1
  132.  
  133. /* LEXPR
  134.  * Same as LAMBDA (q.v.) except additional arguments are permitted
  135.  * beyond those indicated in the LAMBDA_FORMALS list.
  136.  */
  137.  
  138. /* Primitive combinations with 0 arguments are not pointers */
  139.  
  140. /* Primitive combinations, 1 argument: */
  141. #define PCOMB1_FN_SLOT        0
  142. #define PCOMB1_ARG_SLOT        1
  143.  
  144. /* Primitive combinations, 2 arguments: */
  145. #define PCOMB2_FN_SLOT        0
  146. #define PCOMB2_ARG_1_SLOT    1
  147. #define PCOMB2_ARG_2_SLOT    2
  148.  
  149. /* Primitive combinations, 3 arguments are vector-like: */
  150. #define PCOMB3_FN_SLOT        1
  151. #define PCOMB3_ARG_1_SLOT    2
  152. #define PCOMB3_ARG_2_SLOT    3
  153. #define PCOMB3_ARG_3_SLOT    4
  154.  
  155. /* SCODE_QUOTE returns itself */
  156. #define SCODE_QUOTE_OBJECT    0
  157. #define SCODE_QUOTE_IGNORED    1
  158.  
  159. /* SEQUENCE operations (two forms: SEQUENCE_2 and SEQUENCE_3) */
  160. #define SEQUENCE_1        0
  161. #define SEQUENCE_2        1
  162. #define SEQUENCE_3        2
  163.  
  164. /* VARIABLE operation.
  165.  * Corresponds to a variable lookup or variable reference. Contains the
  166.  * symbol referenced, and (if it has been compiled) the frame and
  167.  * offset in the frame in which it was found.  One of these cells is
  168.  * multiplexed by having its type code indicate one of several modes
  169.  * of reference: not yet compiled, local reference, formal reference,
  170.  * auxiliary reference, or global value reference.
  171.  * There are extra definitions in lookup.h.
  172.  */
  173. #define VARIABLE_SYMBOL        0
  174. #define VARIABLE_FRAME_NO    1
  175. #define VARIABLE_OFFSET        2
  176. #define VARIABLE_COMPILED_TYPE    1
  177.