Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/psi/zsysvm.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
17
/* System VM and VM-specific operators */
18
#include "ghost.h"
19
#include "oper.h"
20
#include "ialloc.h"
21
#include "ivmspace.h"
22
#include "store.h"    /* for make_bool */
23
24
/*
25
 * These operators allow creation of objects in a specific VM --
26
 * local, global, or system.  System VM, which is not a standard PostScript
27
 * facility, is not subject to save and restore; objects in system VM
28
 * may only refer to simple objects or to other (composite) objects
29
 * in system VM.
30
 */
31
32
/* Execute an operator with a specific VM selected as current VM. */
33
static int
34
specific_vm_op(i_ctx_t *i_ctx_p, op_proc_t opproc, uint space)
35
5.34M
{
36
5.34M
    uint save_space = icurrent_space;
37
5.34M
    int code;
38
39
5.34M
    ialloc_set_space(idmemory, space);
40
5.34M
    code = opproc(i_ctx_p);
41
5.34M
    ialloc_set_space(idmemory, save_space);
42
5.34M
    return code;
43
5.34M
}
44
45
/* <int> .globalvmarray <array> */
46
static int
47
zglobalvmarray(i_ctx_t *i_ctx_p)
48
0
{
49
0
    return specific_vm_op(i_ctx_p, zarray, avm_global);
50
0
}
51
52
/* <int> .globalvmdict <dict> */
53
static int
54
zglobalvmdict(i_ctx_t *i_ctx_p)
55
0
{
56
0
    return specific_vm_op(i_ctx_p, zdict, avm_global);
57
0
}
58
59
/* <obj_0> ... <obj_n-1> <n> .globalvmpackedarray <packedarray> */
60
static int
61
zglobalvmpackedarray(i_ctx_t *i_ctx_p)
62
0
{
63
0
    return specific_vm_op(i_ctx_p, zpackedarray, avm_global);
64
0
}
65
66
/* <int> .globalvmstring <string> */
67
static int
68
zglobalvmstring(i_ctx_t *i_ctx_p)
69
0
{
70
0
    return specific_vm_op(i_ctx_p, zstring, avm_global);
71
0
}
72
73
/* <int> .localvmarray <array> */
74
static int
75
zlocalvmarray(i_ctx_t *i_ctx_p)
76
68.0k
{
77
68.0k
    return specific_vm_op(i_ctx_p, zarray, avm_local);
78
68.0k
}
79
80
/* <int> .localvmdict <dict> */
81
static int
82
zlocalvmdict(i_ctx_t *i_ctx_p)
83
1.49M
{
84
1.49M
    return specific_vm_op(i_ctx_p, zdict, avm_local);
85
1.49M
}
86
87
/* <obj_0> ... <obj_n-1> <n> .localvmpackedarray <packedarray> */
88
static int
89
zlocalvmpackedarray(i_ctx_t *i_ctx_p)
90
487k
{
91
487k
    return specific_vm_op(i_ctx_p, zpackedarray, avm_local);
92
487k
}
93
94
/* <int> .localvmstring <string> */
95
static int
96
zlocalvmstring(i_ctx_t *i_ctx_p)
97
0
{
98
0
    return specific_vm_op(i_ctx_p, zstring, avm_local);
99
0
}
100
101
/* <int> .systemvmarray <array> */
102
static int
103
zsystemvmarray(i_ctx_t *i_ctx_p)
104
1.13M
{
105
1.13M
    return specific_vm_op(i_ctx_p, zarray, avm_system);
106
1.13M
}
107
108
/* <int> .systemvmdict <dict> */
109
static int
110
zsystemvmdict(i_ctx_t *i_ctx_p)
111
0
{
112
0
    return specific_vm_op(i_ctx_p, zdict, avm_system);
113
0
}
114
115
/* <obj_0> ... <obj_n-1> <n> .systemvmpackedarray <packedarray> */
116
static int
117
zsystemvmpackedarray(i_ctx_t *i_ctx_p)
118
0
{
119
0
    return specific_vm_op(i_ctx_p, zpackedarray, avm_system);
120
0
}
121
122
/* <int> .systemvmstring <string> */
123
static int
124
zsystemvmstring(i_ctx_t *i_ctx_p)
125
974k
{
126
974k
    return specific_vm_op(i_ctx_p, zstring, avm_system);
127
974k
}
128
129
/* <name_string> <access_string> .systemvmfile <file> */
130
static int
131
zsystemvmfile(i_ctx_t *i_ctx_p)
132
0
{
133
0
    return specific_vm_op(i_ctx_p, zfile, avm_system);
134
0
}
135
136
/* <string> .systemvmlibfile <file> true */
137
/* <string> .systemvmlibfile <string> false */
138
static int
139
zsystemvmlibfile(i_ctx_t *i_ctx_p)
140
208k
{
141
208k
    return specific_vm_op(i_ctx_p, zlibfile, avm_system);
142
208k
}
143
144
/* <source> <EODcount> <EODstring> .systemvmSFD <file> */
145
/* <source> <dict> <EODcount> <EODstring> .systemvmSFD <file> */
146
/* <source> <dict> .systemvmSFD <file> *//* (LL3 only) */
147
static int
148
zsystemvmSFD(i_ctx_t *i_ctx_p)
149
974k
{
150
974k
    return specific_vm_op(i_ctx_p, zSFD, avm_system);
151
974k
}
152
153
/* <any> .systemvmcheck <bool> */
154
static int
155
zsystemvmcheck(i_ctx_t *i_ctx_p)
156
0
{
157
0
    os_ptr op = osp;
158
159
0
    make_bool(op, (r_space(op) == avm_system ? true : false));
160
0
    return 0;
161
0
}
162
163
/* ------ Initialization procedure ------ */
164
165
const op_def zsysvm_op_defs[] =
166
{
167
    {"1.globalvmarray", zglobalvmarray},
168
    {"1.globalvmdict", zglobalvmdict},
169
    {"1.globalvmpackedarray", zglobalvmpackedarray},
170
    {"1.globalvmstring", zglobalvmstring},
171
    {"1.localvmarray", zlocalvmarray},
172
    {"1.localvmdict", zlocalvmdict},
173
    {"1.localvmpackedarray", zlocalvmpackedarray},
174
    {"1.localvmstring", zlocalvmstring},
175
    {"1.systemvmarray", zsystemvmarray},
176
    {"1.systemvmcheck", zsystemvmcheck},
177
    {"1.systemvmdict", zsystemvmdict},
178
    {"1.systemvmpackedarray", zsystemvmpackedarray},
179
    {"1.systemvmstring", zsystemvmstring},
180
    {"1.systemvmfile", zsystemvmfile},
181
    {"1.systemvmlibfile", zsystemvmlibfile},
182
    {"2.systemvmSFD", zsystemvmSFD},
183
    op_def_end(0)
184
};