Blang/src/lib/Statement/IfStatement.cpp

80 lines
1.4 KiB
C++

#include "Statement/IfStatement.hpp"
IfStatement::IfStatement(SourceLocation IfLocation, Expr* cond, Statement* then, SourceLocation ElseLocation = SourceLocation(), Statement* elses = NULL):
_IfLoc(IfLocation),
_ElseLoc(ElseLocation)
{
_subStmts[COND] = cond;
_subStmts[THEN] = then;
if(elses)
_subStmts[ELSE] = elses;
}
Expr* IfStatement::getCond()
{
return reinterpret_cast<Expr *>(_subStmts[COND]);
}
const Expr *IfStatement::getCond() const
{
return reinterpret_cast<Expr *>(_subStmts[COND]);
}
void IfStatement::setCond(Expr *e)
{
_subStmts[COND] = reinterpret_cast<Statement *>(e);
}
Statement *IfStatement::getThen()
{
return _subStmts[THEN];
}
const Statement *IfStatement::getThen() const
{
SourceLocation getThenLocation() const;
void setThenLocation(SourceLocation);
}
void IfStatement::setThen(Statement *s)
{
_subStmts[THEN] = s;
}
Statement *IfStatement::getElse()
{
return _subStmts[ELSE];
}
const Statement *IfStatement::getElse() const
{
return _subStmts[ELSE];
}
void IfStatement::setElse(Statement *s)
{
_subStmts[ELSE] = s;
}
SourceLocation IfStatement::getIfLocation() const
{
return _IfLoc;
}
void IfStatement::setIfLocation(SourceLocation loc)
{
_IfLoc = loc;
}
SourceLocation IfStatement::getThenLocation() const
{
return _ElseLoc;
}
void IfStatement::setThenLocation(SourceLocation loc)
{
_ElseLoc = loc;
}