2020-08-23 15:01:39 -07:00
|
|
|
#include "FunctionParameterDeclaration.h"
|
|
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
|
|
#include "clib/logfacility.h"
|
2021-02-25 16:53:22 +01:00
|
|
|
#include "bscript/compiler/ast/NodeVisitor.h"
|
|
|
|
|
#include "bscript/compiler/ast/Expression.h"
|
2020-08-23 15:01:39 -07:00
|
|
|
|
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
|
|
|
{
|
|
|
|
|
FunctionParameterDeclaration::FunctionParameterDeclaration(
|
|
|
|
|
const SourceLocation& source_location, std::string name, bool byref, bool unused,
|
|
|
|
|
std::unique_ptr<Expression> default_value )
|
|
|
|
|
: Node( source_location, std::move( default_value ) ),
|
|
|
|
|
name( std::move( name ) ),
|
|
|
|
|
byref( byref ),
|
|
|
|
|
unused( unused )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FunctionParameterDeclaration::FunctionParameterDeclaration( const SourceLocation& source_location,
|
|
|
|
|
std::string name, bool byref,
|
|
|
|
|
bool unused )
|
|
|
|
|
: Node( source_location ), name( std::move( name ) ), byref( byref ), unused( unused )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FunctionParameterDeclaration::accept( NodeVisitor& visitor )
|
|
|
|
|
{
|
|
|
|
|
visitor.visit_function_parameter_declaration( *this );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FunctionParameterDeclaration::describe_to( fmt::Writer& w ) const
|
|
|
|
|
{
|
|
|
|
|
w << "function-parameter-declaration(" << name;
|
|
|
|
|
if ( byref )
|
|
|
|
|
w << ", byref";
|
|
|
|
|
if ( unused )
|
|
|
|
|
w << ", unused";
|
|
|
|
|
w << ")";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Expression* FunctionParameterDeclaration::default_value()
|
|
|
|
|
{
|
|
|
|
|
return children.empty() ? nullptr : &child<Expression>( 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Pol::Bscript::Compiler
|