home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnusmalltalk / mstinterp.h < prev    next >
C/C++ Source or Header  |  1992-02-15  |  5KB  |  136 lines

  1. /***********************************************************************
  2.  *
  3.  *    Byte Code interpreter declarations.
  4.  *
  5.  ***********************************************************************/
  6.  
  7. /***********************************************************************
  8.  *
  9.  * Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
  10.  * Written by Steve Byrne.
  11.  *
  12.  * This file is part of GNU Smalltalk.
  13.  *
  14.  * GNU Smalltalk is free software; you can redistribute it and/or modify it
  15.  * under the terms of the GNU General Public License as published by the Free
  16.  * Software Foundation; either version 1, or (at your option) any later 
  17.  * version.
  18.  * 
  19.  * GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  20.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  21.  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  22.  * more details.
  23.  * 
  24.  * You should have received a copy of the GNU General Public License along with
  25.  * GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  26.  * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  27.  *
  28.  ***********************************************************************/
  29.  
  30.  
  31. /*
  32.  *    Change Log
  33.  * ============================================================================
  34.  * Author      Date       Change 
  35.  * sbb         24 Nov 91      Context size increased to 64 (still not enough), to
  36.  *              prevent inadvertent stomping of memory past the end
  37.  *              of the stack.
  38.  *
  39.  * sbb         14 Sep 91      Increased number of literals to 256, number of
  40.  *              temporaries to 64, and number of allowable primitives
  41.  *              to 1024 (overkill?)
  42.  *
  43.  * sbyrne     7 Jan 89      Created.
  44.  *
  45.  */
  46.  
  47.  
  48. #ifndef __MSTINTERP__
  49. #define __MSTINTERP__
  50.  
  51. #define CONTEXT_STACK_SIZE        64 /* words/OOPS in a context */
  52. #define NUM_PRIORITIES            8
  53.  
  54. /* These next three defines are the number of bits in a method header for
  55.    the number of literals, the number of temporaries, and the number of
  56.    arguments that the method takes.  If the representation is changed, these
  57.    definitions need to be altered too */
  58. #define NUM_LITERALS_BITS        8
  59. #define NUM_TEMPS_BITS            6
  60. #define NUM_ARGS_BITS            5
  61. #define NUM_PRIM_BITS            10
  62.  
  63. #define MAX_NUM_LITERALS        ((1 << NUM_LITERALS_BITS) - 1)
  64. #define MAX_NUM_TEMPS            ((1 << NUM_TEMPS_BITS) - 1)
  65. #define MAX_NUM_ARGS            ((1 << NUM_ARGS_BITS) - 1)
  66.  
  67. /*
  68. This is the organization of a method header.  The 1 bit in the high end of
  69. the word indicates that this is an integer, so that the GC won't be tempted
  70. to try to scan the contents of this field, and so we can do bitwise operations
  71. on this value to extract component pieces.
  72.  
  73. ### no longer valid 
  74.  
  75.    3                   2                   1 
  76.  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  77. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  78. |1|.|.|.|.|.|flg| prim index    | #args   | #temps  | #literals |
  79. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  80.  
  81. each of args temps literals and flags could have another bit
  82.  
  83. literals 6 0..5
  84. temporarycount 5 6..10
  85. args 5 11..15
  86. largeContext?
  87. primitiveIndex 8 16..23
  88. flags 2 24-25
  89. flags 0 -- use arguments as they are, ignore prim index
  90. flags 1 -- return self
  91. flags 2 -- return instance variable
  92. flags 3 -- call the primitive indexed by primIndex
  93. */
  94.  
  95. typedef struct MethodHeaderStruct {
  96. #ifdef BIG_ENDIAN
  97.   unsigned    intMark            : 1; /* flag this as an Int */
  98. #ifdef unused /* Sat Sep 14 23:40:03 1991 */
  99. /**/  unsigned                : 5; /* unused */
  100. #endif /* unused Sat Sep 14 23:40:03 1991 */
  101.   unsigned    headerFlag        : 2; /* numargs, prim self, etc. */
  102.   unsigned    primitiveIndex        : NUM_PRIM_BITS; /* index of primitve, or 0 */
  103.   unsigned    numArgs            : NUM_ARGS_BITS;
  104.   unsigned    numTemps        : NUM_TEMPS_BITS;
  105.   unsigned    numLiterals        : NUM_LITERALS_BITS;
  106. #else
  107.   unsigned    numLiterals        : NUM_LITERALS_BITS;
  108.   unsigned    numTemps        : NUM_TEMPS_BITS;
  109.   unsigned    numArgs            : NUM_ARGS_BITS;
  110.   unsigned    primitiveIndex        : NUM_PRIM_BITS; /* index of primitve, or 0 */
  111.   unsigned    headerFlag        : 2; /* numargs, prim self, etc. */
  112. #ifdef unused /* Sat Sep 14 23:40:13 1991 */
  113. /**/  unsigned                : 5; /* unused */
  114. #endif /* unused Sat Sep 14 23:40:13 1991 */
  115.   unsigned    intMark            : 1; /* flag this as an Int */
  116. #endif
  117. } MethodHeader;
  118.  
  119. extern OOP            methodLiteralExt(), 
  120.                 finishExecutionEnvironment();
  121. extern void            interpret(), sendMessage(), initInterpreter(),
  122.                 prepareExecutionEnvironment(), 
  123.                 storeMethodLiteralExt(), setFileStreamFile(),
  124.                 updateMethodCache(), initSignals(),
  125.                 storeMethodLiteralNoGC(),
  126.                   realizeMethodContexts();
  127. extern Boolean            equal();
  128. extern long            hash();
  129. extern MethodHeader        getMethodHeaderExt();
  130.  
  131. extern long            byteCodeCounter;
  132. extern Boolean            executionTracing;
  133. extern Boolean            makeCoreFile;
  134.  
  135. #endif /* __MSTINTERP__ */
  136.