File: binary.cc

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (38 lines) | stat: -rw-r--r-- 1,041 bytes parent folder | download | duplicates (3)
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);
}