home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / program / gs300sr1 / gs300sr1.exe / IVMSPACE.H < prev    next >
Text File  |  1994-07-27  |  3KB  |  65 lines

  1. /* Copyright (C) 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* ivmspace.h */
  20. /* Local/global space management */
  21. /* Requires imemory.h */
  22. /* Requires ialloc.h if testing/setting allocator state */
  23.  
  24. /*
  25.  * According to the PostScript language specification, attempting to store
  26.  * a reference to a local object into a global object must produce an
  27.  * invalidaccess error.  However, systemdict must be able to refer to
  28.  * a number of local dictionaries such as userdict and errordict.
  29.  * Therefore, we implement a special hack in 'def' that allows such stores
  30.  * if the dictionary being stored into is systemdict (which is normally
  31.  * only writable during initialization) or a dictionary that appears
  32.  * in systemdict (such as level2dict), and the current save level is zero
  33.  * (to guarantee that we can't get dangling pointers).
  34.  * We could allow this for any global dictionary, except that the garbage
  35.  * collector must treat any such dictionaries as roots when collecting
  36.  * local VM without collecting global VM.
  37.  *
  38.  * We must check for local-into-global stores in three categories of places:
  39.  *
  40.  *    - The scanner, when it encounters a //name inside {}.
  41.  *
  42.  *    - All operators that allocate ref-containing objects and also
  43.  *    store into them:
  44.  *        packedarray  gstate  makepattern?
  45.  *        makefont  scalefont  definefont  filter?
  46.  *
  47.  *    - All operators that store refs into existing objects
  48.  *    ("operators" marked with * are actually PostScript procedures):
  49.  *        put(array)  putinterval(array)  astore  copy(to array)
  50.  *        def  store*  put(dict)  copy(dict)
  51.  *        dictstack  execstack  makeoperator
  52.  *        currentgstate  defineusername?
  53.  */
  54.  
  55. /* Test whether an object is local/global. */
  56. #define r_is_local(rp) r_has_attr(rp, a_local)
  57. #define r_is_global(rp) !r_is_local(rp)
  58. #define check_global(rf)\
  59.   if ( !r_is_global(&rf) ) return_error(e_invalidaccess)
  60. /* The following is a shortcut for checking */
  61. /* r_is_global(&rdest) && r_is_local(rcont) */
  62. #define check_store_space(rdest,rcont)\
  63.   if ( ~r_type_attrs(&(rdest)) & r_type_attrs(&(rcont)) & a_local )\
  64.     return_error(e_invalidaccess)
  65.