home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / brklyprl.lha / Emulator / memory.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-14  |  3.6 KB  |  133 lines

  1.  
  2. /* Copyright (C) 1988, 1989 Herve' Touati, Aquarius Project, UC Berkeley */
  3.  
  4. /* Copyright Herve' Touati, 1988, Aquarius Project, UC Berkeley */
  5.  
  6. /*
  7.  
  8.   |--------------------------------------| <- B0
  9.   |                                      |
  10.   |         Choice Point Stack           |
  11.   |                                      |
  12.   |-----------------|--------------------| <- B
  13.   |                \|/                   |
  14.   |                                      |
  15.   |                                      |
  16.   |                /|\                   |
  17.   |-----------------|--------------------| <- E
  18.   |                                      |
  19.   |        Environment Stack             |
  20.   |                                      | <- E0
  21.   |--------------------------------------| <- HMAXHARD
  22.   |                                      | <- HMAXSOFT
  23.   |         New Space                    |
  24.   |                                      | <- HMIN
  25.   |--------------------------------------|
  26.   |          Marking Area                |
  27.   |                                      |
  28.   |--------------------------------------| <- MKMIN
  29.   |                                      | <- TR0
  30.   |            Trail Stack               |
  31.   |                                      |
  32.   |-----------------|--------------------|  <- TR
  33.   |                \|/                   |
  34.   |                                      |
  35.   |                                      |
  36.   |                /|\                   |
  37.   |-----------------|--------------------|  <- H2
  38.   |                                      |
  39.   |         Global Stack                 |
  40.   |                                      |
  41.   |--------------------------------------|  <- H0
  42.  
  43. */
  44.  
  45. extern CellPtr S;
  46. extern CellPtr B0;
  47. extern CellPtr B;
  48. extern CellPtr E0;
  49. extern CellPtr E;
  50. extern CellPtr TR;
  51. extern CellPtr TR0;
  52. extern CellPtr H0;
  53. extern CellPtr H;
  54. extern CellPtr R;
  55. extern CellPtr R0;
  56. extern InstrPtr P0;
  57. extern InstrPtr P;
  58.  
  59. #ifdef WITH_GC
  60. extern CellPtr H2;
  61. extern CellPtr TR2;
  62. extern CellPtr E2;
  63. extern CellPtr HMIN;
  64. extern CellPtr HMAXSOFT;
  65. extern CellPtr HMAXHARD;
  66. const int HMAX_SECURITY = 256;
  67. extern unsigned char* MKMIN;
  68. #endif 
  69.  
  70.  /* points to an escape that signals successful termination */
  71. extern InstrPtr CP0;
  72.  /* points to a fail instruction */
  73. extern InstrPtr FP0;
  74.  /* points to an escape that signals unsuccessful termination */
  75. extern InstrPtr NP0;
  76.  /* points to the metacall escape */
  77. extern  InstrPtr MP0;
  78. extern  int next_instruction;
  79. enum {
  80. #define use(Name,ID,Coeff,Reg,Type)\
  81.   ID,
  82. #include "memory_sizes.h"
  83. #undef use
  84.   LAST_SIZE
  85.   };
  86. extern int memory_sizes[];
  87. extern Cell NIL;
  88. extern Cell LIST_FUNCTOR;
  89.  
  90. class Memory {
  91.  public:
  92.   void init();
  93.   StringTable* ST;
  94.   Memory(StringTable& table);
  95.   void allocate();
  96. };
  97.  
  98. #define NUMBER_OF_REGISTERS 8
  99. extern Cell X[];
  100.  
  101.  /* layout of an environment */
  102.  /* B   E   P   Y1   Y2   Y3 ... */
  103.  /*-3  -2  -1    0    1    2     */
  104. enum {
  105.   B_ENV_OFFSET = -3,
  106.   E_ENV_OFFSET = -2,
  107.   P_ENV_OFFSET = -1,
  108.   Y1_ENV_OFFSET = 0,
  109.   };
  110.  
  111.  /* position of E above the top of the stack when an env is created */
  112. enum {
  113.   E_TOP_OFFSET = 3
  114.   };
  115.  
  116.  /* Layout of a choice point */
  117.  /* E   H   TR   P   SIZE X1   X2   X3 ...  */
  118.  /* 1   2   3    4   5    6    7    8   9       */
  119.  /* the CP stack grows donwards, so Xi are the first pushed on the stack */
  120.  /* and B points at the top of the stack */
  121.  /* A is the top of the environment stack */
  122.  /* always equals to E except for those stupid intra-clause choice */
  123.  /* points */
  124. enum {
  125.   E_CP_OFFSET = 1,
  126.   H_CP_OFFSET = 2,
  127.   TR_CP_OFFSET = 3,
  128.   P_CP_OFFSET = 4,
  129.   SIZE_CP_OFFSET = 5,
  130.   X1_CP_OFFSET = 6,
  131.   FIXED_CP_SIZE = 5
  132.   };
  133.