File: zsysvm.c

package info (click to toggle)
gs 3.33-7
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 7,436 kB
  • ctags: 15,511
  • sloc: ansic: 92,150; asm: 684; sh: 486; makefile: 91
file content (135 lines) | stat: -rw-r--r-- 3,670 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* Copyright (C) 1994, 1995 Aladdin Enterprises.  All rights reserved.
  
  This file is part of GNU Ghostscript.
  
  GNU Ghostscript is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility to
  anyone for the consequences of using it or for whether it serves any
  particular purpose or works at all, unless he says so in writing.  Refer
  to the GNU Ghostscript General Public License for full details.
  
*/

/* zsysvm.c */
/* System VM and VM-specific operators */
#include "ghost.h"
#include "oper.h"
#include "ialloc.h"
#include "ivmspace.h"
#include "store.h"			/* for make_bool */

/*
 * These operators allow creation of objects in a specific VM --
 * local, global, or system.  System VM, which is not a standard PostScript
 * facility, is not subject to save and restore; objects in system VM
 * may only refer to simple objects or to other (composite) objects
 * in system VM.
 */

/* Execute an operator with a specific VM selected as current VM. */
private int
specific_vm_op(os_ptr op, int (*opproc)(P1(os_ptr)), uint space)
{	uint save_space = icurrent_space;
	int code;
	ialloc_set_space(idmemory, space);
	code = (*opproc)(op);
	ialloc_set_space(idmemory, save_space);
	return code;
}

/* <int> .globalvmarray <array> */
private int
zglobalvmarray(os_ptr op)
{	return specific_vm_op(op, zarray, avm_global);
}

/* <int> .globalvmdict <dict> */
private int
zglobalvmdict(os_ptr op)
{	return specific_vm_op(op, zdict, avm_global);
}

/* <obj_0> ... <obj_n-1> <n> .globalvmpackedarray <packedarray> */
private int
zglobalvmpackedarray(os_ptr op)
{	return specific_vm_op(op, zpackedarray, avm_global);
}

/* <int> .globalvmstring <string> */
private int
zglobalvmstring(os_ptr op)
{	return specific_vm_op(op, zstring, avm_global);
}

/* <int> .localvmarray <array> */
private int
zlocalvmarray(os_ptr op)
{	return specific_vm_op(op, zarray, avm_local);
}

/* <int> .localvmdict <dict> */
private int
zlocalvmdict(os_ptr op)
{	return specific_vm_op(op, zdict, avm_local);
}

/* <obj_0> ... <obj_n-1> <n> .localvmpackedarray <packedarray> */
private int
zlocalvmpackedarray(os_ptr op)
{	return specific_vm_op(op, zpackedarray, avm_local);
}

/* <int> .localvmstring <string> */
private int
zlocalvmstring(os_ptr op)
{	return specific_vm_op(op, zstring, avm_local);
}

/* <int> .systemvmarray <array> */
private int
zsystemvmarray(os_ptr op)
{	return specific_vm_op(op, zarray, avm_system);
}

/* <int> .systemvmdict <dict> */
private int
zsystemvmdict(os_ptr op)
{	return specific_vm_op(op, zdict, avm_system);
}

/* <obj_0> ... <obj_n-1> <n> .systemvmpackedarray <packedarray> */
private int
zsystemvmpackedarray(os_ptr op)
{	return specific_vm_op(op, zpackedarray, avm_system);
}

/* <int> .systemvmstring <string> */
private int
zsystemvmstring(os_ptr op)
{	return specific_vm_op(op, zstring, avm_system);
}

/* <any> .systemvmcheck <bool> */
private int
zsystemvmcheck(register os_ptr op)
{	make_bool(op, (r_space(op) == avm_system ? true : false));
	return 0;
}

/* ------ Initialization procedure ------ */

BEGIN_OP_DEFS(zsysvm_op_defs) {
	{"1.globalvmarray", zglobalvmarray},
	{"1.globalvmdict", zglobalvmdict},
	{"1.globalvmpackedarray", zglobalvmpackedarray},
	{"1.globalvmstring", zglobalvmstring},
	{"1.localvmarray", zlocalvmarray},
	{"1.localvmdict", zlocalvmdict},
	{"1.localvmpackedarray", zlocalvmpackedarray},
	{"1.localvmstring", zlocalvmstring},
	{"1.systemvmarray", zsystemvmarray},
	{"1.systemvmcheck", zsystemvmcheck},
	{"1.systemvmdict", zsystemvmdict},
	{"1.systemvmpackedarray", zsystemvmpackedarray},
	{"1.systemvmstring", zsystemvmstring},
END_OP_DEFS(0) }