polserver/pol-core/bscript/compiler/ast/FunctionCall.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

54 lines
1.6 KiB
C++

#include "FunctionCall.h"
#include <map>
#include <utility>
#include "bscript/compiler/ast/Argument.h"
#include "bscript/compiler/ast/FunctionParameterDeclaration.h"
#include "bscript/compiler/ast/ModuleFunctionDeclaration.h"
#include "bscript/compiler/ast/NodeVisitor.h"
#include "bscript/compiler/file/SourceLocation.h"
#include "bscript/compiler/model/FunctionLink.h"
namespace Pol::Bscript::Compiler
{
FunctionCall::FunctionCall( const SourceLocation& source_location, std::string scope,
std::string name, std::vector<std::unique_ptr<Argument>> children )
: Expression( source_location, std::move( children ) ),
function_link( std::make_shared<FunctionLink>( source_location ) ),
scope( std::move( scope ) ),
method_name( std::move( name ) )
{
}
void FunctionCall::accept( NodeVisitor& visitor )
{
visitor.visit_function_call( *this );
}
void FunctionCall::describe_to( std::string& w ) const
{
fmt::format_to( std::back_inserter( w ), "function-call({})", method_name );
}
std::vector<std::unique_ptr<Argument>> FunctionCall::take_arguments()
{
std::vector<std::unique_ptr<Argument>> args;
args.reserve( children.size() );
for ( auto& child : children )
{
args.emplace_back( static_unique_pointer_cast<Argument, Node>( std::move( child ) ) );
}
return args;
}
std::vector<std::reference_wrapper<FunctionParameterDeclaration>> FunctionCall::parameters() const
{
if ( auto fn = function_link->function() )
return fn->parameters();
else
internal_error( "function has not been resolved" );
}
} // namespace Pol::Bscript::Compiler