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