File: shiftorprint.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 (21 lines) | stat: -rw-r--r-- 848 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
//#define XERR
#include "parser.ih"

SemVal Parser::shiftOrPrint(SemVal &lhs, 
                            Opcode::Byte opcode, SemVal &rhs) const
{
    if (lhs.type() & e_printMask)               // lhs is a printf expression
    {
        if (opcode == Opcode::shl)              // new printf argument:
            return lhs.printfArg(rhs);          // add it to lhs, and done.

                                                // handle the >> operator:

        if (lhs.nPrintfArgs() > 0)              // printf has arguments: first
            lhs = pushPrint(lhs);               // handle the printf insertion
        else                                    // printf w/o arguments:
            Error::msg(Error::PRINTF_OPCODE);   // 'printf >>' is invalid
    }

    return lhs.binary(opcode, move(rhs));       // perform the >> operation
}