polserver/pol-core/bscript/compiler/ast/BranchSelector.cpp
turleypol d848deae18
POLLOG* macros use the new formatting (#598)
* POLLOG* macros use the new formatting
removed all old logging functions

* removed old fmt lib from everything except StreamWriter
removed unneeded functions

* fixed review comments
2024-01-16 17:55:42 +01:00

40 lines
1.1 KiB
C++

#include "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