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
|
#define XERR
#include "semval.ih"
void SemVal::push()
{
if (d_type & e_stack) // expression already pushed
{
if (d_type & e_bool)
bool2int();
return;
}
switch (d_type &
(e_const | e_var | e_bool | e_reg | e_prefix | e_postfix))
{
default: // handles e_void types: no actions
return;
case e_const:
*this << (d_type & e_int ?
Opcode::push_imm
:
Opcode::push_strconst) <<
as<short>(d_value);
break;
case e_var:
if (not copiedVar())
*this << Opcode::push_var << as<short>(d_value);
break;
case e_bool:
bool2int();
return; // bool2int -> alredy e_stack type
case e_reg:
*this << Opcode::push_reg;
break;
case e_prefix:
// prefix: first do ++, then push the variable
// holding the result of the expression
*this << Opcode::push_var << as<short>(d_value);
break;
case e_postfix:
{
// postfix: first push the variable, then compute the
// result of the expression
SemVal pre{ e_int }; // pseudo type for the insertion below:
pre << Opcode::push_var << as<short>(d_value);
pre << *this;
*this = move(pre);
}
break;
}
stackType();
}
|