Blang/src/lib/src/Statement/ForStatement.cpp

84 lines
1.6 KiB
C++

#include "Expr.hpp"
#include "ForStatement.h"
ForStatement::ForStatement(SourceLocation forLocation, AssignStatement *init, Expr *cond, Statement *body,
Expr *inc):
_forLocation(forLocation)
{
_subStmts[INIT] = init;
_subStmts[COND] = cond;
_subStmts[BODY] = body;
if(inc)
_subStmts[INC] = inc;
}
AssignStatement *ForStatement::getInit()
{
return reinterpret_cast<AssignStatement *>(_subStmts.at(INIT));
}
const AssignStatement *ForStatement::getInit() const
{
return reinterpret_cast<AssignStatement *>(_subStmts.at(INIT));
}
void ForStatement::setInit(AssignStatement *init)
{
_subStmts[INIT] = init;
}
Expr *ForStatement::getCond()
{
return reinterpret_cast<Expr *>(_subStmts.at(COND));
}
const Expr *ForStatement::getCond() const
{
return reinterpret_cast<Expr *>(_subStmts.at(COND));
}
void ForStatement::setCond(Expr *cond)
{
_subStmts[COND] = cond;
}
Expr *ForStatement::getInc()
{
return reinterpret_cast<Expr *>(_subStmts.at(INC));
}
const Expr *ForStatement::getInc() const
{
return reinterpret_cast<Expr *>(_subStmts.at(INC));
}
void ForStatement::setInc(Expr *inc)
{
_subStmts[INC] = inc;
}
Statement *ForStatement::getBody()
{
return _subStmts.at(BODY);
}
const Statement *ForStatement::getBody() const
{
return _subStmts.at(BODY);
}
void ForStatement::setBody(Statement *body)
{
_subStmts[BODY] = body;
}
SourceLocation ForStatement::getForLocation() const
{
return _forLocation;
}
void ForStatement::setForLocation(SourceLocation loc)
{
_forLocation = loc;
}