2020-09-07 10:28:26 -07:00
|
|
|
#include "RepeatUntilLoop.h"
|
|
|
|
|
|
|
|
|
|
|
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-07 10:28:26 -07:00
|
|
|
|
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
|
|
|
{
|
|
|
|
|
RepeatUntilLoop::RepeatUntilLoop( const SourceLocation& source_location, std::string label,
|
|
|
|
|
std::unique_ptr<Block> block,
|
|
|
|
|
std::unique_ptr<Expression> expression )
|
|
|
|
|
: LoopStatement( source_location, std::move( label ) )
|
|
|
|
|
{
|
|
|
|
|
children.reserve( 2 );
|
|
|
|
|
children.push_back( std::move( block ) );
|
|
|
|
|
children.push_back( std::move( expression ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RepeatUntilLoop::accept( NodeVisitor& visitor )
|
|
|
|
|
{
|
|
|
|
|
visitor.visit_repeat_until_loop( *this );
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 06:51:44 +01:00
|
|
|
void RepeatUntilLoop::describe_to( std::string& w ) const
|
2020-09-07 10:28:26 -07:00
|
|
|
{
|
2024-01-12 06:51:44 +01:00
|
|
|
w += "repeat-until-loop";
|
2020-09-07 10:28:26 -07:00
|
|
|
if ( !get_label().empty() )
|
2024-01-12 06:51:44 +01:00
|
|
|
fmt::format_to( std::back_inserter( w ), "(label:{})", get_label() );
|
2020-09-07 10:28:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Block& RepeatUntilLoop::block()
|
|
|
|
|
{
|
|
|
|
|
return child<Block>( 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Expression& RepeatUntilLoop::expression()
|
|
|
|
|
{
|
|
|
|
|
return child<Expression>( 1 );
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-10 22:32:29 +02:00
|
|
|
std::unique_ptr<Block> RepeatUntilLoop::take_block()
|
|
|
|
|
{
|
|
|
|
|
return take_child<Block>( 0 );
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-07 10:28:26 -07:00
|
|
|
} // namespace Pol::Bscript::Compiler
|