zsysvm.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* Copyright (C) 1994, 1995, 1999 Aladdin Enterprises. All rights reserved.
  2. This software is provided AS-IS with no warranty, either express or
  3. implied.
  4. This software is distributed under license and may not be copied,
  5. modified or distributed except as expressly authorized under the terms
  6. of the license contained in the file LICENSE in this distribution.
  7. For more information about licensing, please refer to
  8. http://www.ghostscript.com/licensing/. For information on
  9. commercial licensing, go to http://www.artifex.com/licensing/ or
  10. contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  12. */
  13. /* $Id: zsysvm.c,v 1.4 2002/02/21 22:24:54 giles Exp $ */
  14. /* System VM and VM-specific operators */
  15. #include "ghost.h"
  16. #include "oper.h"
  17. #include "ialloc.h"
  18. #include "ivmspace.h"
  19. #include "store.h" /* for make_bool */
  20. /*
  21. * These operators allow creation of objects in a specific VM --
  22. * local, global, or system. System VM, which is not a standard PostScript
  23. * facility, is not subject to save and restore; objects in system VM
  24. * may only refer to simple objects or to other (composite) objects
  25. * in system VM.
  26. */
  27. /* Execute an operator with a specific VM selected as current VM. */
  28. private int
  29. specific_vm_op(i_ctx_t *i_ctx_p, op_proc_t opproc, uint space)
  30. {
  31. uint save_space = icurrent_space;
  32. int code;
  33. ialloc_set_space(idmemory, space);
  34. code = opproc(i_ctx_p);
  35. ialloc_set_space(idmemory, save_space);
  36. return code;
  37. }
  38. /* <int> .globalvmarray <array> */
  39. private int
  40. zglobalvmarray(i_ctx_t *i_ctx_p)
  41. {
  42. return specific_vm_op(i_ctx_p, zarray, avm_global);
  43. }
  44. /* <int> .globalvmdict <dict> */
  45. private int
  46. zglobalvmdict(i_ctx_t *i_ctx_p)
  47. {
  48. return specific_vm_op(i_ctx_p, zdict, avm_global);
  49. }
  50. /* <obj_0> ... <obj_n-1> <n> .globalvmpackedarray <packedarray> */
  51. private int
  52. zglobalvmpackedarray(i_ctx_t *i_ctx_p)
  53. {
  54. return specific_vm_op(i_ctx_p, zpackedarray, avm_global);
  55. }
  56. /* <int> .globalvmstring <string> */
  57. private int
  58. zglobalvmstring(i_ctx_t *i_ctx_p)
  59. {
  60. return specific_vm_op(i_ctx_p, zstring, avm_global);
  61. }
  62. /* <int> .localvmarray <array> */
  63. private int
  64. zlocalvmarray(i_ctx_t *i_ctx_p)
  65. {
  66. return specific_vm_op(i_ctx_p, zarray, avm_local);
  67. }
  68. /* <int> .localvmdict <dict> */
  69. private int
  70. zlocalvmdict(i_ctx_t *i_ctx_p)
  71. {
  72. return specific_vm_op(i_ctx_p, zdict, avm_local);
  73. }
  74. /* <obj_0> ... <obj_n-1> <n> .localvmpackedarray <packedarray> */
  75. private int
  76. zlocalvmpackedarray(i_ctx_t *i_ctx_p)
  77. {
  78. return specific_vm_op(i_ctx_p, zpackedarray, avm_local);
  79. }
  80. /* <int> .localvmstring <string> */
  81. private int
  82. zlocalvmstring(i_ctx_t *i_ctx_p)
  83. {
  84. return specific_vm_op(i_ctx_p, zstring, avm_local);
  85. }
  86. /* <int> .systemvmarray <array> */
  87. private int
  88. zsystemvmarray(i_ctx_t *i_ctx_p)
  89. {
  90. return specific_vm_op(i_ctx_p, zarray, avm_system);
  91. }
  92. /* <int> .systemvmdict <dict> */
  93. private int
  94. zsystemvmdict(i_ctx_t *i_ctx_p)
  95. {
  96. return specific_vm_op(i_ctx_p, zdict, avm_system);
  97. }
  98. /* <obj_0> ... <obj_n-1> <n> .systemvmpackedarray <packedarray> */
  99. private int
  100. zsystemvmpackedarray(i_ctx_t *i_ctx_p)
  101. {
  102. return specific_vm_op(i_ctx_p, zpackedarray, avm_system);
  103. }
  104. /* <int> .systemvmstring <string> */
  105. private int
  106. zsystemvmstring(i_ctx_t *i_ctx_p)
  107. {
  108. return specific_vm_op(i_ctx_p, zstring, avm_system);
  109. }
  110. /* <any> .systemvmcheck <bool> */
  111. private int
  112. zsystemvmcheck(i_ctx_t *i_ctx_p)
  113. {
  114. os_ptr op = osp;
  115. make_bool(op, (r_space(op) == avm_system ? true : false));
  116. return 0;
  117. }
  118. /* ------ Initialization procedure ------ */
  119. const op_def zsysvm_op_defs[] =
  120. {
  121. {"1.globalvmarray", zglobalvmarray},
  122. {"1.globalvmdict", zglobalvmdict},
  123. {"1.globalvmpackedarray", zglobalvmpackedarray},
  124. {"1.globalvmstring", zglobalvmstring},
  125. {"1.localvmarray", zlocalvmarray},
  126. {"1.localvmdict", zlocalvmdict},
  127. {"1.localvmpackedarray", zlocalvmpackedarray},
  128. {"1.localvmstring", zlocalvmstring},
  129. {"1.systemvmarray", zsystemvmarray},
  130. {"1.systemvmcheck", zsystemvmcheck},
  131. {"1.systemvmdict", zsystemvmdict},
  132. {"1.systemvmpackedarray", zsystemvmpackedarray},
  133. {"1.systemvmstring", zsystemvmstring},
  134. op_def_end(0)
  135. };