2020-09-08 01:24:57 -07:00
|
|
|
#include "MethodCall.h"
|
|
|
|
|
|
2024-01-16 17:55:42 +01:00
|
|
|
|
2020-09-08 01:24:57 -07:00
|
|
|
#include <utility>
|
|
|
|
|
|
2021-02-25 16:53:22 +01:00
|
|
|
#include "bscript/compiler/ast/MethodCallArgumentList.h"
|
|
|
|
|
#include "bscript/compiler/ast/NodeVisitor.h"
|
2020-09-08 01:24:57 -07:00
|
|
|
#include "compilercfg.h"
|
|
|
|
|
|
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
|
|
|
{
|
|
|
|
|
MethodCall::MethodCall( const SourceLocation& source_location, std::unique_ptr<Expression> lhs,
|
|
|
|
|
std::string methodname,
|
|
|
|
|
std::unique_ptr<MethodCallArgumentList> argument_list )
|
|
|
|
|
: Expression( source_location ),
|
|
|
|
|
methodname( std::move( methodname ) ),
|
|
|
|
|
known_method( compilercfg.OptimizeObjectMembers
|
|
|
|
|
? getKnownObjMethod( this->methodname.c_str() )
|
|
|
|
|
: nullptr )
|
|
|
|
|
{
|
|
|
|
|
children.reserve( 2 );
|
|
|
|
|
children.push_back( std::move( lhs ) );
|
|
|
|
|
children.push_back( std::move( argument_list ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MethodCall::accept( NodeVisitor& visitor )
|
|
|
|
|
{
|
|
|
|
|
visitor.visit_method_call( *this );
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 06:51:44 +01:00
|
|
|
void MethodCall::describe_to( std::string& w ) const
|
2020-09-08 01:24:57 -07:00
|
|
|
{
|
2024-01-12 06:51:44 +01:00
|
|
|
fmt::format_to( std::back_inserter( w ), "method-call({})", methodname );
|
2020-09-08 01:24:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned MethodCall::argument_count() const
|
|
|
|
|
{
|
2024-01-12 06:51:44 +01:00
|
|
|
return static_cast<unsigned>( children.at( 1 )->children.size() );
|
2020-09-08 01:24:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Pol::Bscript::Compiler
|