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
|
//#define XERR
#include "semval.ih"
// the lhs value is pushed first, the rhs value pushed 2nd
SemVal SemVal::binary(Opcode::Byte opcode, SemVal &&rhs)
{
xerr("lhs type: " << d_type << ", rhs type: " << rhs.d_type);
if (accept(rhs, opcode))
{
if
(
(d_type & rhs.type() & e_const) // lhs, rhs both constants
and // but older,younger are
opcode != Opcode::older // always run-time checked
and
opcode != Opcode::younger
)
constBinary(opcode, rhs);
else
{
rhs.push();
push();
*this << rhs << opcode;
// comparison operations
// return int values
if (Opcode::eq <= opcode and opcode <= Opcode::greq)
d_type = e_int;
stackType();
}
}
return move(*this);
}
|