#include "FunctionCall.h" #include #include #include #include "compiler/ast/Argument.h" #include "compiler/ast/FunctionParameterDeclaration.h" #include "compiler/ast/ModuleFunctionDeclaration.h" #include "compiler/ast/NodeVisitor.h" #include "compiler/file/SourceLocation.h" #include "compiler/model/FunctionLink.h" namespace Pol::Bscript::Compiler { FunctionCall::FunctionCall( const SourceLocation& source_location, std::string scope, std::string name, std::vector> children ) : Expression( source_location, std::move( children ) ), function_link( std::make_shared( 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( fmt::Writer& w ) const { w << "function-call(" << method_name << ")"; } std::vector> FunctionCall::take_arguments() { std::vector> args; args.reserve( children.size() ); for ( auto& child : children ) { args.emplace_back( static_unique_pointer_cast( std::move( child ) ) ); } return args; } std::vector> FunctionCall::parameters() const { if ( auto fn = function_link->function() ) return fn->parameters(); else internal_error( "function has not been resolved" ); } } // namespace Pol::Bscript::Compiler