/* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises. All rights reserved.
Distributed by Free Software Foundation, Inc.
This file is part of Ghostscript.
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 Ghostscript General Public License for full details.
Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License. A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
/* Array operators for GhostScript */
/* The generic operators (copy, get, put, getinterval, putinterval, */
/* length, and forall) are implemented in zgeneric.c. */
private int make_array(P4(os_ptr
, int, int, const char *));
zarray(register os_ptr op
)
{ int code
= make_array(op
, t_array
, a_all
, "array");
if ( code
< 0 ) return code
;
refset_null(op
->value
.refs
, r_size(op
));
zaload(register os_ptr op
)
switch ( (type
= r_type(&aref
)) )
default: return e_typecheck
;
case t_array
: case t_mixedarray
: case t_shortarray
: ;
#define asize r_size(&aref)
if ( asize
> ostop
- op
) return e_rangecheck
;
memcpy((char *)op
, (char *)aref
.value
.refs
,
ushort
*packed
= aref
.value
.packed
;
for ( i
= 0; i
< asize
; i
++, pdest
++ )
packed_get(packed
, pdest
),
packed
= packed_next(packed
);
zastore(register os_ptr op
)
check_type(*op
, t_array
);
if ( size
> op
- osbot
) return e_stackunderflow
;
refcpy_to_old(op
->value
.refs
, op
- size
, size
, "astore");
/* ------ Initialization procedure ------ */
op_def zarray_op_defs
[] = {
/* ------ Internal procedures ------ */
/* Make an array from the operand stack. */
make_array(register os_ptr op
, int type
, int attrs
, const char *client_name
)
check_type(*op
, t_integer
);
if ( op
->value
.intval
< 0 ||
op
->value
.intval
> max_uint
/ sizeof(ref
) - 1
abody
= alloc_refs(size
, client_name
);
if ( abody
== 0 ) return e_VMerror
;
make_tasv(op
, type
, attrs
, size
, refs
, abody
);