2026-07-25 23:01:18 +02:00
|
|
|
#include "bscript/compiler/ast/DoWhileLoop.h"
|
2020-09-06 02:26:41 -07:00
|
|
|
|
|
|
|
|
|
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-06 02:26:41 -07:00
|
|
|
|
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
|
|
|
{
|
|
|
|
|
DoWhileLoop::DoWhileLoop( 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 DoWhileLoop::accept( NodeVisitor& visitor )
|
|
|
|
|
{
|
|
|
|
|
visitor.visit_do_while_loop( *this );
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 06:51:44 +01:00
|
|
|
void DoWhileLoop::describe_to( std::string& w ) const
|
2020-09-06 02:26:41 -07:00
|
|
|
{
|
2024-01-12 06:51:44 +01:00
|
|
|
w += "do-while-loop";
|
2020-09-06 02:26:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Block& DoWhileLoop::block()
|
|
|
|
|
{
|
|
|
|
|
return child<Block>( 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Expression& DoWhileLoop::predicate()
|
|
|
|
|
{
|
|
|
|
|
return child<Expression>( 1 );
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-10 22:32:29 +02:00
|
|
|
std::unique_ptr<Block> DoWhileLoop::take_block()
|
|
|
|
|
{
|
|
|
|
|
return take_child<Block>( 0 );
|
|
|
|
|
}
|
2020-09-06 02:26:41 -07:00
|
|
|
} // namespace Pol::Bscript::Compiler
|