polserver/pol-core/bscript/compiler/ast/BranchSelector.cpp
turleypol 1463b76c7c
Includes are now all relative to pol-core basefolder (#906)
* all except pol

* pol and includes under defines

* something weird has happened

* remove own folder from include searchpath

* fixed remaining, adapted include style for external headers

* missing include
2026-07-25 23:01:18 +02:00

40 lines
1.2 KiB
C++

#include "bscript/compiler/ast/BranchSelector.h"
#include "bscript/compiler/ast/Expression.h"
#include "bscript/compiler/ast/NodeVisitor.h"
#include "bscript/compiler/model/FlowControlLabel.h"
namespace Pol::Bscript::Compiler
{
BranchSelector::BranchSelector( const SourceLocation& source_location, BranchType branch_type,
std::unique_ptr<Expression> predicate )
: Node( source_location, std::move( predicate ) ),
branch_type( branch_type ),
flow_control_label( std::make_shared<FlowControlLabel>() )
{
}
BranchSelector::BranchSelector( const SourceLocation& source_location, BranchType branch_type )
: Node( source_location ),
branch_type( branch_type ),
flow_control_label( std::make_shared<FlowControlLabel>() )
{
}
void BranchSelector::accept( NodeVisitor& visitor )
{
visitor.visit_branch_selector( *this );
}
void BranchSelector::describe_to( std::string& w ) const
{
fmt::format_to( std::back_inserter( w ), "branch-selector({})", fmt::underlying( branch_type ) );
}
Expression* BranchSelector::predicate()
{
return children.empty() ? nullptr : &child<Expression>( 0 );
}
} // namespace Pol::Bscript::Compiler