* Copyright (c) 1980 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)printval.c 5.3 (Berkeley) %G%";
* Print out the value at the top of the stack using the given type.
if (t
== t_char
|| (t
->class == RANGE
&& t
->type
== t_char
)) {
printf("'%.*s'", len
, sp
);
error("can't print out variant records");
printordinal(popsmall(s
), rtype(s
->type
));
error("missing record specification");
printordinal(popsmall(s
), s
);
a
= fparamaddr(pop(long));
if (s
->class < BADUSE
|| s
->class > VARNT
) {
panic("printval: bad class %d", s
->class);
error("don't know how to print a %s", classname(s
));
* Print out an ordinal value (either an integer, character, or
* an enumeration constant).
while (c
!= NIL
&& c
->symvalue
.iconval
!= iv
) {
printf("(scalar = %d)", iv
);
} else if (t
== t_char
) {
} else if (t
== t_boolean
) {
printf("%s", (iv
== TRUE
) ? "true" : "false");
* Print out the value of a record, field by field.
if ((t
= s
->chain
) == NIL
) {
error("record has no fields");
* Print out a field, first printing out other fields.
* This is done because the fields are chained together backwards.
printf("%s = ", s
->symbol
);
sp
+= (s
->symvalue
.offset
+ size(s
->type
));
* Print out the contents of an array.
* Haven't quite figured out what the best format is.
* This is rather inefficient.
* The "2*elsize" is there since "printval" drops the stack by elsize.
savesp
= (STACK
*)(((int)sp
+ 3) & ~3);
if (eltype
->class == ARRAY
)
if (elsize
< sizeof(int)) {
register char *cp
= sp
- ((size(a
) + 3) & ~3);
register char *cp1
, *end
= cp
+ size(a
);
cp1
= (char *)&psh
+ sizeof(int) - elsize
;
while (cp1
< (char *)&psh
+ sizeof psh
)
if (end
- size(a
) != cp
- elsize
) {
savestack
= *(short *)sp
;
*(short *)sp
= savestack
;
panic("bad size on runtime stack");
for (sp
+= elsize
, alignstack(); sp
<= savesp
; sp
+= 2*elsize
) {
if (sp
- 2*elsize
>= newsp
) {
if (eltype
->class == ARRAY
) {
for (sp
+= elsize
; sp
<= savesp
; sp
+= 2*elsize
) {
if (sp
- elsize
!= newsp
) {
* Print out the value of a real number.
* Pascal notation is somewhat different that what one gets
} else if (buf
[0] == '-' && buf
[1] == '.') {
if (index(buf
, '.') == NIL
) {