void CParser::RelExpr() { BoolExpr(); while (true) { switch (mLookahead) { case '&': Match('&'); BoolExpr(); AddToken(opAND); break; case '|': Match('|'); BoolExpr(); AddToken(opOR); break; default: return; } } } // CParser::RelExpr
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); }
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; }
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 ); }
void CParser::BoolExpr() { if (mLookahead == '!') { Match('!'); BoolExpr(); AddToken(opNOT); } else { Expr(); if (mLookahead == RELOP) { int savedRelop = mRelop; Match(RELOP); Expr(); AddToken(savedRelop); } } } // CParser::BoolExpr
BoolExpr operator >=(const SetCmpRel& r, const SetExpr& l) { return BoolExpr(r) && BoolExpr(r.r >= l); }
BoolExpr operator ==(const BoolExpr& l, const BoolExpr& r) { return BoolExpr(l, BoolExpr::NT_EQV, r); }
BoolExpr operator !(const BoolExpr& e) { return BoolExpr(e,BoolExpr::NT_NOT); }
BoolExpr operator ^(const BoolExpr& l, const BoolExpr& r) { return BoolExpr(BoolExpr(l,BoolExpr::NT_EQV,r),BoolExpr::NT_NOT); }
BoolExpr operator ||(const BoolExpr& l, const BoolExpr& r) { return BoolExpr(l,BoolExpr::NT_OR,r); }
BoolExpr operator &&(const BoolExpr& l, const BoolExpr& r) { return BoolExpr(l,BoolExpr::NT_AND,r); }