/* Copyright (c) 1979 Regents of the University of California */
static char sccsid
[] = "@(#)stkrval.c 1.3 %G%";
* stkrval Rvalue - an expression, and coerce it to be a stack quantity.
* Contype is the type that the caller would prefer, nand is important
* if constant sets or constant strings are involved, the latter
* because of string padding.
* for the obj version, this is a copy of rvalue hacked to use fancy new
* push-onto-stack-and-convert opcodes.
* for the pc version, i just call rvalue and convert if i have to,
* based on the return type of rvalue.
stkrval(r
, contype
, required
)
* The root of the tree tells us what sort of expression we have.
putleaf( P2ICON
, 0 , 0 , P2INT
, 0 );
if (p
== NIL
|| p
->class == BADUSE
)
return(stklval(r
, NOFLAGS
));
put(2, O_RV8
| bn
<< 8+INDX
, p
->value
[0]);
put(2, O_RV4
| bn
<< 8+INDX
, p
->value
[0]);
put(2, O_RV24
| bn
<< 8+INDX
, p
->value
[0]);
put(2, O_RV14
| bn
<< 8+INDX
, p
->value
[0]);
put(3, O_RV
| bn
<< 8+INDX
, p
->value
[0], w
);
return rvalue( r
, contype
, required
);
* might consider a rvalue.
if ( required
== RREQ
) {
putop( P2UNARY P2MUL
, p2type( q
) );
error("%s is a constant and cannot be qualified", r
[2]);
* Find the size of the string
if (contype
!= NIL
&& !opt('s')) {
if (width(contype
) < c
&& classify(contype
) == TSTR
) {
error("Constant string too long");
put(2, O_LVCON
, lenstr(cp1
, w
));
putCONG( cp1
, c
+ w
, LREQ
);
* Define the string temporarily
* so later people can know its
put(2, O_CONC4
, p
->value
[0]);
putleaf( P2ICON
, p
-> value
[0] , 0 , P2CHAR
, 0 );
* Every other kind of constant here
put(2, O_CON4
, p
->range
[0]);
put(2, O_CON24
, (short)p
->range
[0]);
put(2, O_CON14
, (short)p
->range
[0]);
return rvalue( r
, contype
, required
);
error("Can't qualify a function result value");
if (classify(q
) == TSTR
) {
put(2, O_LVCON
, even(c
+1));
error("Type names (e.g. %s) allowed only in declarations", p
->symbol
);
error("Procedure %s found where expression required", p
->symbol
);
p
= rvalue(r
, contype
, required
);
p
= rvalue(r
, contype
, required
);
if (f
> MAXINT
|| f
< MININT
) {
error("Constant too large for this implementation");
put(2, O_CON24
, (short)l
);
putleaf( P2ICON
, (short) l
, 0 , P2INT
, 0 );
putleaf( P2ICON
, l
, 0 , P2INT
, 0 );
* A floating point number
put(2, O_CON8
, atof(r
[2]));
* Constant strings. Note that constant characters
* are constant strings of length one; there is
* no constant string of length one.
putleaf( P2ICON
, cp
[0] , 0 , P2CHAR
, 0 );