2020-09-08 01:56:30 -07:00
|
|
|
#include "BasicForLoop.h"
|
|
|
|
|
|
|
|
|
|
#include <format/format.h>
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
2021-02-25 16:53:22 +01:00
|
|
|
#include "bscript/compiler/ast/Block.h"
|
|
|
|
|
#include "bscript/compiler/ast/Expression.h"
|
|
|
|
|
#include "bscript/compiler/ast/NodeVisitor.h"
|
2020-09-08 01:56:30 -07:00
|
|
|
|
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
|
|
|
{
|
|
|
|
|
BasicForLoop::BasicForLoop( const SourceLocation& source_location, std::string label,
|
|
|
|
|
std::string identifier, std::unique_ptr<Expression> first,
|
|
|
|
|
std::unique_ptr<Expression> last, std::unique_ptr<Block> block )
|
|
|
|
|
: LoopStatement( source_location, std::move( label ) ), identifier( std::move( identifier ) )
|
|
|
|
|
{
|
|
|
|
|
children.reserve( 3 );
|
|
|
|
|
children.push_back( std::move( first ) );
|
|
|
|
|
children.push_back( std::move( last ) );
|
|
|
|
|
children.push_back( std::move( block ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BasicForLoop::accept( NodeVisitor& visitor )
|
|
|
|
|
{
|
|
|
|
|
visitor.visit_basic_for_loop( *this );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BasicForLoop::describe_to( fmt::Writer& w ) const
|
|
|
|
|
{
|
|
|
|
|
w << "basic-for-loop";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Expression& BasicForLoop::first()
|
|
|
|
|
{
|
|
|
|
|
return child<Expression>( 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Expression& BasicForLoop::last()
|
|
|
|
|
{
|
|
|
|
|
return child<Expression>( 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Block& BasicForLoop::block()
|
|
|
|
|
{
|
|
|
|
|
return child<Block>( 2 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Pol::Bscript::Compiler
|