Blang/src/lib/src/Statement/BinaryOperatorExpr.cpp

54 lines
970 B
C++

#include "BinaryOperatorExpr.h"
std::string BinaryOperatorExpr::getOpcodeStr(BinaryOperatorExpr::Opcode opc)
{
switch (opc) {
#define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling;
#include "Statement/OperationKinds.def"
}
}
BinaryOperatorExpr::BinaryOperatorExpr(Expr *lhs, Expr *rhs, BinaryOperatorExpr::Opcode opc):
_opc(opc)
{
_subExprs[LHS]= lhs;
_subExprs[RHS]= rhs;
}
Expr *BinaryOperatorExpr::getLHS() const
{
return _subExprs.at(LHS);
}
void BinaryOperatorExpr::setLHS(Expr *E)
{
_subExprs[LHS] = E;
}
Expr *BinaryOperatorExpr::getRHS() const
{
return _subExprs.at(RHS);
}
void BinaryOperatorExpr::setRHS(Expr *E)
{
_subExprs[RHS] = E;
}
BinaryOperatorExpr::Opcode BinaryOperatorExpr::getOpcode() const
{
return _opc;
}
void BinaryOperatorExpr::setOpcode(BinaryOperatorExpr::Opcode O)
{
_opc = O;
}
std::string BinaryOperatorExpr::getOpcodeStr() const
{
return getOpcodeStr(_opc);
}