84 lines
1.6 KiB
C++
84 lines
1.6 KiB
C++
#include <Statement/Expr.hpp>
|
|
#include "Statement/ForStatement.hpp"
|
|
|
|
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[INIT]);
|
|
}
|
|
|
|
const AssignStatement *ForStatement::getInit() const
|
|
{
|
|
return reinterpret_cast<AssignStatement *>(_subStmts[INIT]);
|
|
}
|
|
|
|
void ForStatement::setInit(AssignStatement *init)
|
|
{
|
|
_subStmts[INIT] = init;
|
|
}
|
|
|
|
Expr *ForStatement::getCond()
|
|
{
|
|
return reinterpret_cast<Expr *>(_subStmts[COND]);
|
|
}
|
|
|
|
const Expr *ForStatement::getCond() const
|
|
{
|
|
return reinterpret_cast<Expr *>(_subStmts[COND]);
|
|
}
|
|
|
|
void ForStatement::setCond(Expr *cond)
|
|
{
|
|
_subStmts[COND] = cond;
|
|
}
|
|
|
|
Expr *ForStatement::getInc()
|
|
{
|
|
return reinterpret_cast<Expr *>(_subStmts[INC]);
|
|
}
|
|
|
|
const Expr *ForStatement::getInc() const
|
|
{
|
|
return reinterpret_cast<Expr *>(_subStmts[INC]);
|
|
}
|
|
|
|
void ForStatement::setInc(Expr *inc)
|
|
{
|
|
_subStmts[INC] = inc;
|
|
}
|
|
|
|
Statement *ForStatement::getBody()
|
|
{
|
|
return _subStmts[BODY];
|
|
}
|
|
|
|
const Statement *ForStatement::getBody() const
|
|
{
|
|
return _subStmts[BODY];
|
|
}
|
|
|
|
void ForStatement::setBody(Statement *body)
|
|
{
|
|
_subStmts[BODY] = body;
|
|
}
|
|
|
|
SourceLocation ForStatement::getForLocation() const
|
|
{
|
|
return _forLocation;
|
|
}
|
|
|
|
void ForStatement::setForLocation(SourceLocation loc)
|
|
{
|
|
_forLocation = loc;
|
|
} |