home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / ESTACK.H < prev    next >
C/C++ Source or Header  |  1992-04-25  |  4KB  |  81 lines

  1. /* Copyright (C) 1989, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* estack.h */
  21. /* Definitions for Ghostscript execution stack */
  22.  
  23. /********************************
  24.  * NOTE: on MS-DOS systems, the execution stack is stored in the data segment.
  25.  * This leads to large performance gains, at the expense of having to swap
  26.  * the stack explicitly when switching contexts or handling segment under-
  27.  * or overflow (none of which are implemented yet!).
  28.  ********************************/
  29. typedef ref _ds *es_ptr;
  30. typedef const ref _ds *const_es_ptr;
  31. extern es_ptr esbot, esp, estop;
  32. /*
  33.  * To improve performance, we cache the currentfile pointer
  34.  * (i.e., `shallow-bind' it in Lisp terminology).  The invariant is as
  35.  * follows: either esfile points to the currentfile slot on the estack
  36.  * (i.e., the topmost slot with an executable file), or it is 0.
  37.  * Note that the following algorithm suffices to maintain the invariant:
  38.  * whenever a routine pushes or pops anything on the estack, if the object
  39.  * *might* be an executable file, set esfile to 0.
  40.  */
  41. extern es_ptr esfile;
  42.  
  43.  
  44. /*
  45.  * The execution stack is used for three purposes:
  46.  *    - Procedures being executed are held here.  They always have
  47.  * type = t_array, t_mixedarray, or t_shortarray, with a_executable set.
  48.  *    - if, ifelse, etc. push arguments to be executed here.
  49.  * They may be any kind of object whatever.
  50.  *    - for, repeat, loop, forall, pathforall, run, and stopped
  51.  * mark the stack by pushing an object with type = t_null,
  52.  * attrs = a_executable, and value.index = 0 for loops, 1 for run/stopped.
  53.  * (Executable null objects can't ever appear on the e-stack otherwise:
  54.  * if a control operator pushes one, it gets popped immediately.)
  55.  * The loop operators also push whatever state they need,
  56.  * followed by an operator object that handles continuing the loop.
  57.  */
  58.  
  59. /* Macro for marking the execution stack */
  60. #define make_mark_estack(ep, idx)\
  61.   make_tav(ep, t_null, a_executable, index, idx)
  62. #define mark_estack(idx)\
  63.   (++esp, make_mark_estack(esp, idx))
  64.  
  65. /* Macro for pushing an operator on the execution stack */
  66. /* to represent a continuation procedure */
  67. #define make_op_estack(ep, proc, idx)\
  68.   make_oper(ep, idx, (dummy_op_proc_p)(proc))
  69. #define push_op_estack(proc, idx)\
  70.   (++esp, make_op_estack(esp, proc, idx))
  71.  
  72. /* Macro to ensure enough room on the execution stack */
  73. #define check_estack(n)\
  74.   if ( esp + (n) > estop ) return e_execstackoverflow
  75.  
  76. /* Define the various kinds of execution stack marks. */
  77. #define es_other 0            /* internal use */
  78. #define es_show 1            /* show operators */
  79. #define es_for 2            /* iteration operators */
  80. #define es_stopped 3            /* stopped operator */
  81.