mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* 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
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#include "bscript/compiler/ast/VarStatement.h"
|
|
|
|
|
|
#include <utility>
|
|
|
|
#include "bscript/compiler/ast/Expression.h"
|
|
#include "bscript/compiler/ast/NodeVisitor.h"
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
VarStatement::VarStatement( const SourceLocation& source_location, std::string scope,
|
|
std::string name, std::unique_ptr<Expression> initializer )
|
|
: Statement( source_location, std::move( initializer ) ),
|
|
scope( std::move( scope ) ),
|
|
name( std::move( name ) )
|
|
{
|
|
}
|
|
|
|
VarStatement::VarStatement( const SourceLocation& source_location, std::string scope,
|
|
std::string name )
|
|
: Statement( source_location ), scope( std::move( scope ) ), name( std::move( name ) )
|
|
{
|
|
}
|
|
|
|
VarStatement::VarStatement( const SourceLocation& source_location, std::string scope,
|
|
std::string name, bool initialize_as_empty_array )
|
|
: Statement( source_location ),
|
|
scope( std::move( scope ) ),
|
|
name( std::move( name ) ),
|
|
initialize_as_empty_array( initialize_as_empty_array )
|
|
{
|
|
}
|
|
|
|
void VarStatement::accept( NodeVisitor& visitor )
|
|
{
|
|
visitor.visit_var_statement( *this );
|
|
}
|
|
|
|
void VarStatement::describe_to( std::string& w ) const
|
|
{
|
|
auto scope_prefix = scope.empty() ? "" : fmt::format( "{}::", scope );
|
|
fmt::format_to( std::back_inserter( w ), "var-statement({}{}", scope_prefix, name );
|
|
if ( initialize_as_empty_array )
|
|
w += ", initialize-as-empty-array";
|
|
w += ")";
|
|
}
|
|
|
|
} // namespace Pol::Bscript::Compiler
|