mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-26 22:21:52 +00:00
Reorder comparison with constant
This commit is contained in:
parent
cc48928827
commit
6fcbce8d30
@ -132,6 +132,14 @@ PrintC::PrintC(Architecture *g,const string &nm) : PrintLanguage(g,nm)
|
||||
greater_equal.negate = &less_than;
|
||||
equal.negate = ¬_equal;
|
||||
not_equal.negate = &equal;
|
||||
|
||||
// Set the swap tokens
|
||||
less_than.lrswap = &greater_than;
|
||||
less_equal.lrswap = &greater_equal;
|
||||
greater_than.lrswap = &less_than;
|
||||
greater_equal.lrswap = &less_equal;
|
||||
equal.lrswap = &equal;
|
||||
not_equal.lrswap = ¬_equal;
|
||||
|
||||
castStrategy = new CastStrategyC();
|
||||
resetDefaultsPrintC();
|
||||
|
@ -549,11 +549,18 @@ void PrintLanguage::opBinary(const OpToken *tok,const PcodeOp *op)
|
||||
if (tok == (const OpToken *)0)
|
||||
throw LowlevelError("Could not find fliptoken");
|
||||
}
|
||||
const Varnode *lhs = op->getIn(0);
|
||||
const Varnode *rhs = op->getIn(1);
|
||||
if (op->getIn(0)->isConstant() && tok->lrswap != (const OpToken *)0) {
|
||||
tok = tok->lrswap;
|
||||
lhs = op->getIn(1);
|
||||
rhs = op->getIn(0);
|
||||
}
|
||||
pushOp(tok,op); // Push on reverse polish notation
|
||||
// implied vn's pushed on in reverse order for efficiency
|
||||
// see PrintLanguage::pushVnImplied
|
||||
pushVn(op->getIn(1),op,mods);
|
||||
pushVn(op->getIn(0),op,mods);
|
||||
pushVn(rhs,op,mods);
|
||||
pushVn(lhs,op,mods);
|
||||
}
|
||||
|
||||
/// Push an operator onto the stack that has a normal unary format.
|
||||
|
@ -101,6 +101,7 @@ public:
|
||||
int4 spacing; ///< Spaces to print around operator
|
||||
int4 bump; ///< Spaces to indent if we break here
|
||||
OpToken *negate; ///< The token representing the negation of this token
|
||||
OpToken *lrswap; ///< The token representing the token used if the left-hand and right-hand sides are swapped
|
||||
};
|
||||
|
||||
/// \brief The base class API for emitting a high-level language
|
||||
|
Loading…
Reference in New Issue
Block a user