Beispiel #1
0
void CParser::RelExpr()
{
	BoolExpr();
	while (true)
	{
		switch (mLookahead)
		{
			case '&': Match('&'); BoolExpr(); AddToken(opAND); break;
			case '|': Match('|'); BoolExpr(); AddToken(opOR); break;
			default: return;
		}
	}
} // CParser::RelExpr
Beispiel #2
0
 BoolExpr
 element(const BoolVarArgs& b, const LinExpr& idx) {
   BElementExpr* be = new BElementExpr(b.size());
   for (int i=b.size(); i--;)
     new (&be->a[i]) BoolExpr(b[i]);
   be->idx = idx;
   return BoolExpr(be);
 }
Beispiel #3
0
unsigned Test (unsigned Label, int Invert)
/* Evaluate a boolean test expression and jump depending on the result of
** the test and on Invert. The function returns one of the TESTEXPR_xx codes
** defined above. If the jump is always true, a warning is output.
*/
{
    ExprDesc Expr;
    unsigned Result;

    /* Read a boolean expression */
    BoolExpr (hie0, &Expr);

    /* Check for a constant expression */
    if (ED_IsConstAbs (&Expr)) {

        /* Result is constant, so we know the outcome */
        Result = (Expr.IVal != 0);

        /* Constant rvalue */
        if (!Invert && Expr.IVal == 0) {
            g_jump (Label);
            Warning ("Unreachable code");
        } else if (Invert && Expr.IVal != 0) {
            g_jump (Label);
        }

    } else {

        /* Result is unknown */
        Result = TESTEXPR_UNKNOWN;

        /* If the expr hasn't set condition codes, set the force-test flag */
        if (!ED_IsTested (&Expr)) {
            ED_MarkForTest (&Expr);
        }

        /* Load the value into the primary register */
        LoadExpr (CF_FORCECHAR, &Expr);

        /* Generate the jump */
        if (Invert) {
            g_truejump (CF_NONE, Label);
        } else {
            g_falsejump (CF_NONE, Label);
        }
    }

    /* Return the result */
    return Result;
}
Beispiel #4
0
static void JumpCond( TREEPTR expr,
                      LABEL_INDEX label,
                      opr_code jump_opcode,
                      opr_code jump_opposite )
{
    TREEPTR     tree;

    tree = BoolExpr( expr );
    if( tree->op.opr == OPR_NOT ) {
        tree->op.opr = jump_opposite;
    } else {
        tree = ExprNode( 0, jump_opcode, tree );
    }
    tree->op.label_index = label;
    AddStmt( tree );
}
Beispiel #5
0
void CParser::BoolExpr()
{
	if (mLookahead == '!')
	{
		Match('!');
		BoolExpr();
		AddToken(opNOT);
	}
	else
	{
		Expr();
		if (mLookahead == RELOP)
		{
			int savedRelop = mRelop;
			Match(RELOP);
			Expr();
			AddToken(savedRelop);
		}
	}
} // CParser::BoolExpr
Beispiel #6
0
 BoolExpr
 operator >=(const SetCmpRel& r, const SetExpr& l) {
   return BoolExpr(r) && BoolExpr(r.r >= l);
 }
Beispiel #7
0
 BoolExpr
 operator ==(const BoolExpr& l, const BoolExpr& r) {
   return BoolExpr(l, BoolExpr::NT_EQV, r);
 }
Beispiel #8
0
 BoolExpr
 operator !(const BoolExpr& e) {
   return BoolExpr(e,BoolExpr::NT_NOT);
 }
Beispiel #9
0
 BoolExpr
 operator ^(const BoolExpr& l, const BoolExpr& r) {
   return BoolExpr(BoolExpr(l,BoolExpr::NT_EQV,r),BoolExpr::NT_NOT);
 }
Beispiel #10
0
 BoolExpr
 operator ||(const BoolExpr& l, const BoolExpr& r) {
   return BoolExpr(l,BoolExpr::NT_OR,r);
 }
Beispiel #11
0
 BoolExpr
 operator &&(const BoolExpr& l, const BoolExpr& r) {
   return BoolExpr(l,BoolExpr::NT_AND,r);
 }